Differential D21715 Diff 51754 src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
Show First 20 Lines • Show All 773 Lines • ▼ Show 20 Lines | private function getGitObservedVersion(PhabricatorRepository $repository) { | ||||
if (!$version) { | if (!$version) { | ||||
return null; | return null; | ||||
} | } | ||||
return (int)$version['version']; | return (int)$version['version']; | ||||
} | } | ||||
private function markUnreachableCommits(PhabricatorRepository $repository) { | private function markUnreachableCommits(PhabricatorRepository $repository) { | ||||
// For now, this is only supported for Git. | if (!$repository->isGit() && !$repository->isHg()) { | ||||
epriestley: You could just remove this comment now; it's no longer accurate, and this operation isn't… | |||||
Done Inline Actions🤦♂️ cspeckmim: 🤦♂️ | |||||
if (!$repository->isGit()) { | |||||
return; | return; | ||||
} | } | ||||
// Find older versions of refs which we haven't processed yet. We're going | // Find older versions of refs which we haven't processed yet. We're going | ||||
// to make sure their commits are still reachable. | // to make sure their commits are still reachable. | ||||
$old_refs = id(new PhabricatorRepositoryOldRef())->loadAllWhere( | $old_refs = id(new PhabricatorRepositoryOldRef())->loadAllWhere( | ||||
'repositoryPHID = %s', | 'repositoryPHID = %s', | ||||
$repository->getPHID()); | $repository->getPHID()); | ||||
// If we don't have any refs to update, bail out before building a graph | // If we don't have any refs to update, bail out before building a graph | ||||
// stream. In particular, this improves behavior in empty repositories, | // stream. In particular, this improves behavior in empty repositories, | ||||
// where `git log` exits with an error. | // where `git log` exits with an error. | ||||
if (!$old_refs) { | if (!$old_refs) { | ||||
return; | return; | ||||
} | } | ||||
// We can share a single graph stream across all the checks we need to do. | // We can share a single graph stream across all the checks we need to do. | ||||
if ($repository->isGit()) { | |||||
$stream = new PhabricatorGitGraphStream($repository); | $stream = new PhabricatorGitGraphStream($repository); | ||||
} else if ($repository->isHg()) { | |||||
$stream = new PhabricatorMercurialGraphStream($repository); | |||||
} | |||||
foreach ($old_refs as $old_ref) { | foreach ($old_refs as $old_ref) { | ||||
$identifier = $old_ref->getCommitIdentifier(); | $identifier = $old_ref->getCommitIdentifier(); | ||||
$this->markUnreachableFrom($repository, $stream, $identifier); | $this->markUnreachableFrom($repository, $stream, $identifier); | ||||
// If nothing threw an exception, we're all done with this ref. | // If nothing threw an exception, we're all done with this ref. | ||||
$old_ref->delete(); | $old_ref->delete(); | ||||
} | } | ||||
} | } | ||||
private function markUnreachableFrom( | private function markUnreachableFrom( | ||||
PhabricatorRepository $repository, | PhabricatorRepository $repository, | ||||
PhabricatorGitGraphStream $stream, | PhabricatorRepositoryGraphStream $stream, | ||||
$identifier) { | $identifier) { | ||||
$unreachable = array(); | $unreachable = array(); | ||||
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( | $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( | ||||
'repositoryID = %s AND commitIdentifier = %s', | 'repositoryID = %s AND commitIdentifier = %s', | ||||
$repository->getID(), | $repository->getID(), | ||||
$identifier); | $identifier); | ||||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |
You could just remove this comment now; it's no longer accurate, and this operation isn't really sensible in SVN so it's now moot.