From 014a873773eb00e99b86478bb2b92b05e05afb1a Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 26 Jan 2014 15:29:22 -0800 Subject: [PATCH] Update DifferentialDiff: add repositoryPHID, drop parentRevisionID Summary: Moves away from ArcanistProjects: - Adds storage for diffs to be directly associated with a repository (instead of indirectly, through arcanist projects). Not really populated yet. - Drops `parentRevisionID`, which is obsoleted by the "Depends On" edge. This is not exposed in the UI anywhere and doesn't do anything. Resolves TODO. Test Plan: Ran storage upgrades, browsed around, lots of `grep`. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D8072 --- .../20140126.diff.1.parentrevisionid.sql | 2 + .../20140126.diff.2.repositoryphid.sql | 2 + ...duitAPI_differential_creatediff_Method.php | 44 +++++++++---------- .../differential/storage/DifferentialDiff.php | 3 +- .../ConduitAPI_repository_query_Method.php | 6 +++ 5 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 resources/sql/autopatches/20140126.diff.1.parentrevisionid.sql create mode 100644 resources/sql/autopatches/20140126.diff.2.repositoryphid.sql diff --git a/resources/sql/autopatches/20140126.diff.1.parentrevisionid.sql b/resources/sql/autopatches/20140126.diff.1.parentrevisionid.sql new file mode 100644 index 0000000000..4468e240b4 --- /dev/null +++ b/resources/sql/autopatches/20140126.diff.1.parentrevisionid.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_differential.differential_diff + DROP COLUMN parentRevisionID; diff --git a/resources/sql/autopatches/20140126.diff.2.repositoryphid.sql b/resources/sql/autopatches/20140126.diff.2.repositoryphid.sql new file mode 100644 index 0000000000..336c15f741 --- /dev/null +++ b/resources/sql/autopatches/20140126.diff.2.repositoryphid.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_differential.differential_diff + ADD COLUMN repositoryPHID VARCHAR(64) COLLATE utf8_bin AFTER authorPHID; diff --git a/src/applications/differential/conduit/ConduitAPI_differential_creatediff_Method.php b/src/applications/differential/conduit/ConduitAPI_differential_creatediff_Method.php index e74408a421..df543f7787 100644 --- a/src/applications/differential/conduit/ConduitAPI_differential_creatediff_Method.php +++ b/src/applications/differential/conduit/ConduitAPI_differential_creatediff_Method.php @@ -1,8 +1,5 @@ 'required string', 'branch' => 'required string', 'bookmark' => 'optional string', - 'sourceControlSystem' => 'required enum', + 'sourceControlSystem' => 'required enum', 'sourceControlPath' => 'required string', 'sourceControlBaseRevision' => 'required string', - 'parentRevisionID' => 'optional revisionid', 'creationMethod' => 'optional string', - 'authorPHID' => 'optional phid', 'arcanistProject' => 'optional string', - 'repositoryUUID' => 'optional string', 'lintStatus' => 'required enum', 'unitStatus' => 'required enum', + 'repositoryPHID' => 'optional phid', + + 'parentRevisionID' => 'deprecated', + 'authorPHID' => 'deprecated', + 'repositoryUUID' => 'deprecated', ); } @@ -54,23 +53,23 @@ final class ConduitAPI_differential_creatediff_Method extends ConduitAPIMethod { $diff->setBranch($request->getValue('branch')); $diff->setCreationMethod($request->getValue('creationMethod')); - $diff->setAuthorPHID($request->getValue('authorPHID')); + $diff->setAuthorPHID($request->getViewer()->getPHID()); $diff->setBookmark($request->getValue('bookmark')); - $parent_id = $request->getValue('parentRevisionID'); - if ($parent_id) { - // NOTE: If the viewer can't see the parent revision, just don't set - // a parent revision ID. This isn't used for anything meaningful. - // TODO: Can we delete this entirely? - $parent_rev = id(new DifferentialRevisionQuery()) - ->setViewer($request->getUser()) - ->withIDs(array($parent_id)) - ->execute(); - if ($parent_rev) { - $parent_rev = head($parent_rev); - if (!$parent_rev->isClosed()) { - $diff->setParentRevisionID($parent_id); - } + // TODO: Remove this eventually; for now continue writing the UUID. Note + // that we'll overwrite it below if we identify a repository, and `arc` + // no longer sends it. This stuff is retained for backward compatibility. + $diff->setRepositoryUUID($request->getValue('repositoryUUID')); + + $repository_phid = $request->getValue('repositoryPHID'); + if ($repository_phid) { + $repository = id(new PhabricatorRepositoryQuery()) + ->setViewer($request->getViewer()) + ->withPHIDs(array($repository_phid)) + ->executeOne(); + if ($repository) { + $diff->setRepositoryPHID($repository->getPHID()); + $diff->setRepositoryUUID($repository->getUUID()); } } @@ -96,7 +95,6 @@ final class ConduitAPI_differential_creatediff_Method extends ConduitAPIMethod { } $diff->setArcanistProjectPHID($project_phid); - $diff->setRepositoryUUID($request->getValue('repositoryUUID')); switch ($request->getValue('lintStatus')) { case 'skip': diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php index 7fc796481c..b5f66aea1e 100644 --- a/src/applications/differential/storage/DifferentialDiff.php +++ b/src/applications/differential/storage/DifferentialDiff.php @@ -8,6 +8,7 @@ final class DifferentialDiff protected $revisionID; protected $authorPHID; + protected $repositoryPHID; protected $sourceMachine; protected $sourcePath; @@ -24,7 +25,6 @@ final class DifferentialDiff protected $branch; protected $bookmark; - protected $parentRevisionID; protected $arcanistProjectPHID; protected $creationMethod; protected $repositoryUUID; @@ -223,7 +223,6 @@ final class DifferentialDiff public function getDiffDict() { $dict = array( 'id' => $this->getID(), - 'parent' => $this->getParentRevisionID(), 'revisionID' => $this->getRevisionID(), 'dateCreated' => $this->getDateCreated(), 'dateModified' => $this->getDateModified(), diff --git a/src/applications/repository/conduit/ConduitAPI_repository_query_Method.php b/src/applications/repository/conduit/ConduitAPI_repository_query_Method.php index c27274ccc6..9f17b02c9e 100644 --- a/src/applications/repository/conduit/ConduitAPI_repository_query_Method.php +++ b/src/applications/repository/conduit/ConduitAPI_repository_query_Method.php @@ -22,6 +22,7 @@ final class ConduitAPI_repository_query_Method 'callsigns' => 'optional list', 'vcsTypes' => 'optional list', 'remoteURIs' => 'optional list', + 'uuids' => 'optional list', ); } @@ -63,6 +64,11 @@ final class ConduitAPI_repository_query_Method $query->withRemoteURIs($remote_uris); } + $uuids = $request->getValue('uuids', array()); + if ($uuids) { + $query->withUUIDs($uuids); + } + $repositories = $query->execute(); $results = array();