3 final class PhabricatorRepositoryManagementMarkReachableWorkflow
4 extends PhabricatorRepositoryManagementWorkflow
{
6 private $untouchedCount = 0;
8 protected function didConstruct() {
10 ->setName('mark-reachable')
11 ->setExamples('**mark-reachable** [__options__] __repository__ ...')
14 'Rebuild "unreachable" flags for commits in __repository__.'))
24 public function execute(PhutilArgumentParser
$args) {
25 $repos = $this->loadRepositories($args, 'repos');
27 throw new PhutilArgumentUsageException(
29 'Specify one or more repositories to correct reachability status '.
33 foreach ($repos as $repo) {
34 $this->markReachable($repo);
40 'Examined %s commits already in the correct state.',
41 new PhutilNumber($this->untouchedCount
)));
50 private function markReachable(PhabricatorRepository
$repository) {
51 if (!$repository->isGit() && !$repository->isHg()) {
52 throw new PhutilArgumentUsageException(
54 'Only Git and Mercurial repositories are supported, unable to '.
55 'operate on this repository ("%s").',
56 $repository->getDisplayName()));
59 $viewer = $this->getViewer();
61 $commits = id(new DiffusionCommitQuery())
63 ->withRepository($repository)
66 $flag = PhabricatorRepositoryCommit
::IMPORTED_UNREACHABLE
;
68 if ($repository->isGit()) {
69 $graph = new PhabricatorGitGraphStream($repository);
70 } else if ($repository->isHg()) {
71 $graph = new PhabricatorMercurialGraphStream($repository);
74 foreach ($commits as $commit) {
75 $identifier = $commit->getCommitIdentifier();
78 $graph->getCommitDate($identifier);
80 } catch (Exception
$ex) {
84 // The commit has proper reachability, so do nothing.
85 if ($commit->isUnreachable() === $unreachable) {
86 $this->untouchedCount++
;
93 $commit->getMonogram(),
94 pht('Marking commit unreachable.'));
96 $commit->writeImportStatusFlag($flag);
100 $commit->getMonogram(),
101 pht('Marking commit reachable.'));
103 $commit->clearImportStatusFlag($flag);