Differential D20599 Diff 49152 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 392 Lines • ▼ Show 20 Lines | while ($discover) { | ||||
if (empty($seen[$parent])) { | if (empty($seen[$parent])) { | ||||
$seen[$parent] = true; | $seen[$parent] = true; | ||||
$discover[] = $parent; | $discover[] = $parent; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Now, sort them topographically. | // Now, sort them topologically. | ||||
$commits = $this->reduceGraph($graph); | $commits = $this->reduceGraph($graph); | ||||
$refs = array(); | $refs = array(); | ||||
foreach ($commits as $commit) { | foreach ($commits as $commit) { | ||||
$epoch = $stream->getCommitDate($commit); | $epoch = $stream->getCommitDate($commit); | ||||
// If the epoch doesn't fit into a uint32, treat it as though it stores | // If the epoch doesn't fit into a uint32, treat it as though it stores | ||||
// the current time. For discussion, see T11537. | // the current time. For discussion, see T11537. | ||||
Show All 22 Lines | /* -( Internals )---------------------------------------------------------- */ | ||||
private function reduceGraph(array $edges) { | private function reduceGraph(array $edges) { | ||||
foreach ($edges as $commit => $parents) { | foreach ($edges as $commit => $parents) { | ||||
$edges[$commit] = array_keys($parents); | $edges[$commit] = array_keys($parents); | ||||
} | } | ||||
$graph = new PhutilDirectedScalarGraph(); | $graph = new PhutilDirectedScalarGraph(); | ||||
$graph->addNodes($edges); | $graph->addNodes($edges); | ||||
$commits = $graph->getTopographicallySortedNodes(); | $commits = $graph->getNodesInTopologicalOrder(); | ||||
// NOTE: We want the most ancestral nodes first, so we need to reverse the | // NOTE: We want the most ancestral nodes first, so we need to reverse the | ||||
// list we get out of AbstractDirectedGraph. | // list we get out of AbstractDirectedGraph. | ||||
$commits = array_reverse($commits); | $commits = array_reverse($commits); | ||||
return $commits; | return $commits; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 489 Lines • Show Last 20 Lines |