From ee709a05432dced9f0986154c366fbce2106637f Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 18 Jul 2012 20:42:06 -0700 Subject: [PATCH] Use Edges to store dependencies between revisions in Differential Summary: See D3006. Move this data to the edge store. Test Plan: - Created dependencies, migrated, verified dependencies were preserved. - Added new dependencies, they worked. Reviewers: vrana, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1162 Differential Revision: https://secure.phabricator.com/D3007 --- .../migrate-differential-dependencies.php | 42 +++++++++++++++++++ ...erentialDependenciesFieldSpecification.php | 8 ++-- .../PhabricatorSearchAttachController.php | 5 ++- .../edges/constants/PhabricatorEdgeConfig.php | 8 ++++ .../patch/PhabricatorBuiltinPatchList.php | 5 +++ 5 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 resources/sql/patches/migrate-differential-dependencies.php diff --git a/resources/sql/patches/migrate-differential-dependencies.php b/resources/sql/patches/migrate-differential-dependencies.php new file mode 100644 index 0000000000..de455172ca --- /dev/null +++ b/resources/sql/patches/migrate-differential-dependencies.php @@ -0,0 +1,42 @@ +getID(); + echo "Revision {$id}: "; + + $deps = $rev->getAttachedPHIDs(PhabricatorPHIDConstants::PHID_TYPE_DREV); + if (!$deps) { + echo "-\n"; + continue; + } + + $editor = new PhabricatorEdgeEditor(); + $editor->setSuppressEvents(true); + foreach ($deps as $dep) { + $editor->addEdge( + $rev->getPHID(), + PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV, + $dep); + } + $editor->save(); + echo "OKAY\n"; +} + +echo "Done.\n"; diff --git a/src/applications/differential/field/specification/DifferentialDependenciesFieldSpecification.php b/src/applications/differential/field/specification/DifferentialDependenciesFieldSpecification.php index ce8a088fff..2987533226 100644 --- a/src/applications/differential/field/specification/DifferentialDependenciesFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialDependenciesFieldSpecification.php @@ -1,7 +1,7 @@ getRevision(); - return $revision->getAttachedPHIDs( - PhabricatorPHIDConstants::PHID_TYPE_DREV); + return PhabricatorEdgeQuery::loadDestinationPHIDs( + $this->getRevision()->getPHID(), + PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV); } } diff --git a/src/applications/search/controller/PhabricatorSearchAttachController.php b/src/applications/search/controller/PhabricatorSearchAttachController.php index ff9d1815b1..5da51c0334 100644 --- a/src/applications/search/controller/PhabricatorSearchAttachController.php +++ b/src/applications/search/controller/PhabricatorSearchAttachController.php @@ -119,7 +119,6 @@ final class PhabricatorSearchAttachController } else { switch ($this->action) { case self::ACTION_ATTACH: - case self::ACTION_DEPENDENCIES: $phids = $object->getAttachedPHIDs($attach_type); break; default: @@ -274,6 +273,7 @@ final class PhabricatorSearchAttachController private function getEdgeType($src_type, $dst_type) { $t_cmit = PhabricatorPHIDConstants::PHID_TYPE_CMIT; $t_task = PhabricatorPHIDConstants::PHID_TYPE_TASK; + $t_drev = PhabricatorPHIDConstants::PHID_TYPE_DREV; $map = array( $t_cmit => array( @@ -283,6 +283,9 @@ final class PhabricatorSearchAttachController $t_cmit => PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT, $t_task => PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, ), + $t_drev => array( + $t_drev => PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV, + ), ); if (empty($map[$src_type][$dst_type])) { diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index 77a5ba78f1..023829225c 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -23,9 +23,13 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { const TYPE_TASK_HAS_COMMIT = 1; const TYPE_COMMIT_HAS_TASK = 2; + const TYPE_TASK_DEPENDS_ON_TASK = 3; const TYPE_TASK_DEPENDED_ON_BY_TASK = 4; + const TYPE_DREV_DEPENDS_ON_DREV = 5; + const TYPE_DREV_DEPENDED_ON_BY_DREV = 6; + const TYPE_TEST_NO_CYCLE = 9000; public static function getInverse($edge_type) { @@ -35,6 +39,9 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { self::TYPE_TASK_DEPENDS_ON_TASK => self::TYPE_TASK_DEPENDED_ON_BY_TASK, self::TYPE_TASK_DEPENDED_ON_BY_TASK => self::TYPE_TASK_DEPENDS_ON_TASK, + + self::TYPE_DREV_DEPENDS_ON_DREV => self::TYPE_DREV_DEPENDED_ON_BY_DREV, + self::TYPE_DREV_DEPENDED_ON_BY_DREV => self::TYPE_DREV_DEPENDS_ON_DREV, ); return idx($map, $edge_type); @@ -44,6 +51,7 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { static $map = array( self::TYPE_TEST_NO_CYCLE => true, self::TYPE_TASK_DEPENDS_ON_TASK => true, + self::TYPE_DREV_DEPENDS_ON_DREV => true, ); return isset($map[$edge_type]); } diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index 4311367798..ecb847ebb6 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -919,6 +919,11 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'php', 'name' => $this->getPatchPath('migrate-maniphest-dependencies.php'), ), + 'migrate-differential-dependencies.php' => array( + 'type' => 'php', + 'name' => $this->getPatchPath( + 'migrate-differential-dependencies.php'), + ), ); }