Differential D18615 Diff 44695 src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | final class PhabricatorRepositoryManagementParentsWorkflow | ||||
| private function rebuildRepository(PhabricatorRepository $repo) { | private function rebuildRepository(PhabricatorRepository $repo) { | ||||
| $console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
| $console->writeOut("%s\n", pht('Rebuilding "%s"...', $repo->getMonogram())); | $console->writeOut("%s\n", pht('Rebuilding "%s"...', $repo->getMonogram())); | ||||
| $refs = id(new PhabricatorRepositoryRefCursorQuery()) | $refs = id(new PhabricatorRepositoryRefCursorQuery()) | ||||
| ->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(); | ||||
| foreach ($refs as $ref) { | foreach ($refs as $ref) { | ||||
| if (!$repo->shouldTrackBranch($ref->getRefName())) { | if (!$repo->shouldTrackBranch($ref->getRefName())) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $console->writeOut( | $console->writeOut( | ||||
| "%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); | $discover = array($commit); | ||||
| while ($discover) { | while ($discover) { | ||||
| $target = array_pop($discover); | $target = array_pop($discover); | ||||
| if (isset($graph[$target])) { | if (isset($graph[$target])) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $graph[$target] = $stream->getParents($target); | $graph[$target] = $stream->getParents($target); | ||||
| foreach ($graph[$target] as $parent) { | foreach ($graph[$target] as $parent) { | ||||
| $discover[] = $parent; | $discover[] = $parent; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| $console->writeOut( | $console->writeOut( | ||||
| "%s\n", | "%s\n", | ||||
| pht( | pht( | ||||
| 'Found %s total commit(s); updating...', | 'Found %s total commit(s); updating...', | ||||
| phutil_count($graph))); | phutil_count($graph))); | ||||
| $commit_table = id(new PhabricatorRepositoryCommit()); | $commit_table = id(new PhabricatorRepositoryCommit()); | ||||
| ▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines | |||||