mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
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 <repository> --trace`, saw successful script execution and reasonable-looking output. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T11823 Differential Revision: https://secure.phabricator.com/D18615
This commit is contained in:
parent
8982e3e52d
commit
49b7181780
1 changed files with 17 additions and 16 deletions
|
@ -54,6 +54,7 @@ final class PhabricatorRepositoryManagementParentsWorkflow
|
||||||
->setViewer($this->getViewer())
|
->setViewer($this->getViewer())
|
||||||
->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH))
|
->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH))
|
||||||
->withRepositoryPHIDs(array($repo->getPHID()))
|
->withRepositoryPHIDs(array($repo->getPHID()))
|
||||||
|
->needPositions(true)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$graph = array();
|
$graph = array();
|
||||||
|
@ -66,23 +67,23 @@ final class PhabricatorRepositoryManagementParentsWorkflow
|
||||||
"%s\n",
|
"%s\n",
|
||||||
pht('Rebuilding branch "%s"...', $ref->getRefName()));
|
pht('Rebuilding branch "%s"...', $ref->getRefName()));
|
||||||
|
|
||||||
$commit = $ref->getCommitIdentifier();
|
foreach ($ref->getPositionIdentifiers() as $commit) {
|
||||||
|
if ($repo->isGit()) {
|
||||||
if ($repo->isGit()) {
|
$stream = new PhabricatorGitGraphStream($repo, $commit);
|
||||||
$stream = new PhabricatorGitGraphStream($repo, $commit);
|
} else {
|
||||||
} else {
|
$stream = new PhabricatorMercurialGraphStream($repo, $commit);
|
||||||
$stream = new PhabricatorMercurialGraphStream($repo, $commit);
|
|
||||||
}
|
|
||||||
|
|
||||||
$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 = array($commit);
|
||||||
$discover[] = $parent;
|
while ($discover) {
|
||||||
|
$target = array_pop($discover);
|
||||||
|
if (isset($graph[$target])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$graph[$target] = $stream->getParents($target);
|
||||||
|
foreach ($graph[$target] as $parent) {
|
||||||
|
$discover[] = $parent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue