Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15517168
D14428.id34932.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D14428.id34932.diff
View Options
diff --git a/resources/sql/autopatches/20151109.repository.coverage.1.sql b/resources/sql/autopatches/20151109.repository.coverage.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20151109.repository.coverage.1.sql
@@ -0,0 +1,8 @@
+USE {$NAMESPACE}_repository;
+DELETE x FROM repository_coverage x
+LEFT JOIN repository_coverage y
+ ON x.branchID = y.branchID
+ AND x.commitID = y.commitID
+ AND x.pathID = y.pathID
+ AND y.id > x.id
+ WHERE y.id IS NOT NULL;
diff --git a/src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php
--- a/src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php
@@ -20,11 +20,17 @@
}
protected function defineParamTypes() {
+ $modes = array(
+ 'overwrite',
+ 'update',
+ );
+
return array(
'repositoryPHID' => 'required phid',
'branch' => 'required string',
'commit' => 'required string',
'coverage' => 'required map<string, string>',
+ 'mode' => 'optional '.$this->formatStringConstants($modes),
);
}
@@ -77,16 +83,31 @@
$table_name = 'repository_coverage';
$conn->openTransaction();
- queryfx(
- $conn,
- 'DELETE FROM %T WHERE branchID = %d',
- $table_name,
- $branch->getID());
+ $mode = $request->getValue('mode');
+ switch ($mode) {
+ case '':
+ case 'overwrite':
+ // sets the coverage for the whole branch, deleting all previous
+ // coverage information
+ queryfx(
+ $conn,
+ 'DELETE FROM %T WHERE branchID = %d',
+ $table_name,
+ $branch->getID());
+ break;
+ case 'update':
+ // sets the coverage for the provided files on the specified commit
+ break;
+ default:
+ $conn->killTransaction();
+ throw new Exception(pht('Invalid mode "%s".', $mode));
+ }
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn,
- 'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %Q',
+ 'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %Q'.
+ ' ON DUPLICATE KEY UPDATE coverage=VALUES(coverage)',
$table_name,
$chunk);
}
diff --git a/src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php b/src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php
--- a/src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php
+++ b/src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php
@@ -37,6 +37,7 @@
),
'key_path' => array(
'columns' => array('branchID', 'pathID', 'commitID'),
+ 'unique' => true,
),
));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 20, 12:42 AM (3 d, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7652098
Default Alt Text
D14428.id34932.diff (2 KB)
Attached To
Mode
D14428: add "update" mode to Diffusion coverage Conduit
Attached
Detach File
Event Timeline
Log In to Comment