Page MenuHomePhabricator

D14428.diff
No OneTemporary

D14428.diff

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

Mime Type
text/plain
Expires
Wed, May 22, 3:17 AM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6294117
Default Alt Text
D14428.diff (2 KB)

Event Timeline