Differential D21715 Diff 51754 src/applications/repository/management/PhabricatorRepositoryManagementMarkReachableWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/management/PhabricatorRepositoryManagementMarkReachableWorkflow.php
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public function execute(PhutilArgumentParser $args) { | ||||
echo tsprintf( | echo tsprintf( | ||||
"%s\n", | "%s\n", | ||||
pht('Done.')); | pht('Done.')); | ||||
return 0; | return 0; | ||||
} | } | ||||
private function markReachable(PhabricatorRepository $repository) { | private function markReachable(PhabricatorRepository $repository) { | ||||
if (!$repository->isGit()) { | if (!$repository->isGit() && !$repository->isHg()) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht( | pht( | ||||
'Only Git repositories are supported, this repository ("%s") is '. | 'Only Git and Mercurial repositories are supported, unable to '. | ||||
'not a Git repository.', | 'operate on this repository ("%s").', | ||||
$repository->getDisplayName())); | $repository->getDisplayName())); | ||||
} | } | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$commits = id(new DiffusionCommitQuery()) | $commits = id(new DiffusionCommitQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withRepository($repository) | ->withRepository($repository) | ||||
->execute(); | ->execute(); | ||||
$flag = PhabricatorRepositoryCommit::IMPORTED_UNREACHABLE; | $flag = PhabricatorRepositoryCommit::IMPORTED_UNREACHABLE; | ||||
if ($repository->isGit()) { | |||||
$graph = new PhabricatorGitGraphStream($repository); | $graph = new PhabricatorGitGraphStream($repository); | ||||
} else if ($repository->isHg()) { | |||||
$graph = new PhabricatorMercurialGraphStream($repository); | |||||
} | |||||
foreach ($commits as $commit) { | foreach ($commits as $commit) { | ||||
$identifier = $commit->getCommitIdentifier(); | $identifier = $commit->getCommitIdentifier(); | ||||
try { | try { | ||||
$graph->getCommitDate($identifier); | $graph->getCommitDate($identifier); | ||||
$unreachable = false; | $unreachable = false; | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$unreachable = true; | $unreachable = true; | ||||
Show All 27 Lines |