From 49b718178066d9f75981039f1a13f4c16f52e116 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 15 Sep 2017 09:22:26 -0700 Subject: [PATCH] Update utility "bin/repository parents" workflow to work with RefPosition Summary: Ref T11823. I think this is the last callsite which relies on the old data format: `bin/repository parents` rebuilds a cache which we don't currently use very heavily. Update it to work with the new data. Test Plan: Ran `bin/repository parents --trace`, saw successful script execution and reasonable-looking output. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T11823 Differential Revision: https://secure.phabricator.com/D18615 --- ...torRepositoryManagementParentsWorkflow.php | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php index 61c5fedf96..671287c3d6 100644 --- a/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php +++ b/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php @@ -54,6 +54,7 @@ final class PhabricatorRepositoryManagementParentsWorkflow ->setViewer($this->getViewer()) ->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH)) ->withRepositoryPHIDs(array($repo->getPHID())) + ->needPositions(true) ->execute(); $graph = array(); @@ -66,23 +67,23 @@ final class PhabricatorRepositoryManagementParentsWorkflow "%s\n", pht('Rebuilding branch "%s"...', $ref->getRefName())); - $commit = $ref->getCommitIdentifier(); - - if ($repo->isGit()) { - $stream = new PhabricatorGitGraphStream($repo, $commit); - } else { - $stream = new PhabricatorMercurialGraphStream($repo, $commit); - } - - $discover = array($commit); - while ($discover) { - $target = array_pop($discover); - if (isset($graph[$target])) { - continue; + foreach ($ref->getPositionIdentifiers() as $commit) { + if ($repo->isGit()) { + $stream = new PhabricatorGitGraphStream($repo, $commit); + } else { + $stream = new PhabricatorMercurialGraphStream($repo, $commit); } - $graph[$target] = $stream->getParents($target); - foreach ($graph[$target] as $parent) { - $discover[] = $parent; + + $discover = array($commit); + while ($discover) { + $target = array_pop($discover); + if (isset($graph[$target])) { + continue; + } + $graph[$target] = $stream->getParents($target); + foreach ($graph[$target] as $parent) { + $discover[] = $parent; + } } } }