mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 00:02:40 +01:00
Give Mercurial more plausible marker behavior
Summary: Ref T13546. Fixes some issues where marker selection in Mercurial didn't work, and selects "draft()" as the set of commits to show, which is at least somewhat reasonable. Test Plan: Ran "arc branches" and "arc bookmarks" in Mercurial, got more reasonable output. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21380
This commit is contained in:
parent
8c95dc0d29
commit
4b8a32ee02
4 changed files with 31 additions and 11 deletions
|
@ -1035,4 +1035,24 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
return new ArcanistMercurialCommitGraphQuery();
|
return new ArcanistMercurialCommitGraphQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newPublishedCommitHashes() {
|
||||||
|
$future = $this->newFuture(
|
||||||
|
'log --rev %s --template %s',
|
||||||
|
hgsprintf('parents(draft()) - draft()'),
|
||||||
|
'{node}\n');
|
||||||
|
list($lines) = $future->resolve();
|
||||||
|
|
||||||
|
$lines = phutil_split_lines($lines, false);
|
||||||
|
|
||||||
|
$hashes = array();
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
if (!strlen(trim($line))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$hashes[] = $line;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $hashes;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,9 @@ final class ArcanistMercurialCommitGraphQuery
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'', // Placeholder for "encoding".
|
'', // Placeholder for "encoding".
|
||||||
'{node}',
|
'{node}',
|
||||||
'{parents}',
|
'{p1node} {p2node}',
|
||||||
'{date|rfc822date}',
|
'{date|rfc822date}',
|
||||||
'{description|utf8}',
|
'{desc|utf8}',
|
||||||
);
|
);
|
||||||
|
|
||||||
$template = implode("\2", $fields)."\1";
|
$template = implode("\2", $fields)."\1";
|
||||||
|
@ -123,6 +123,9 @@ final class ArcanistMercurialCommitGraphQuery
|
||||||
$graph = $this->getGraph();
|
$graph = $this->getGraph();
|
||||||
$lines = $this->queryFuture;
|
$lines = $this->queryFuture;
|
||||||
$limit = $this->getLimit();
|
$limit = $this->getLimit();
|
||||||
|
|
||||||
|
$no_parent = str_repeat('0', 40);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!$lines->valid()) {
|
if (!$lines->valid()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -159,9 +162,12 @@ final class ArcanistMercurialCommitGraphQuery
|
||||||
|
|
||||||
if (strlen($parents)) {
|
if (strlen($parents)) {
|
||||||
$parents = explode(' ', $parents);
|
$parents = explode(' ', $parents);
|
||||||
|
|
||||||
$parent_nodes = array();
|
$parent_nodes = array();
|
||||||
foreach ($parents as $parent) {
|
foreach ($parents as $parent) {
|
||||||
|
if ($parent === $no_parent) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$parent_node = $graph->getNode($parent);
|
$parent_node = $graph->getNode($parent);
|
||||||
if (!$parent_node) {
|
if (!$parent_node) {
|
||||||
$parent_node = $graph->newNode($parent);
|
$parent_node = $graph->newNode($parent);
|
||||||
|
|
|
@ -60,7 +60,7 @@ EOTEXT
|
||||||
'You stand in the middle of a small clearing in the woods.'));
|
'You stand in the middle of a small clearing in the woods.'));
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
$hour = (int)date('h', $now);
|
$hour = (int)date('G', $now);
|
||||||
|
|
||||||
if ($hour >= 5 && $hour <= 7) {
|
if ($hour >= 5 && $hour <= 7) {
|
||||||
$time = pht(
|
$time = pht(
|
||||||
|
|
|
@ -16,7 +16,7 @@ abstract class ArcanistMarkersWorkflow
|
||||||
->withMarkerTypes(array($marker_type))
|
->withMarkerTypes(array($marker_type))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$tail_hashes = $this->getTailHashes();
|
$tail_hashes = $api->getPublishedCommitHashes();
|
||||||
|
|
||||||
$heads = mpull($markers, 'getCommitHash');
|
$heads = mpull($markers, 'getCommitHash');
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ abstract class ArcanistMarkersWorkflow
|
||||||
}
|
}
|
||||||
|
|
||||||
$nodes = $query->execute();
|
$nodes = $query->execute();
|
||||||
|
|
||||||
if (count($nodes) > $limit) {
|
if (count($nodes) > $limit) {
|
||||||
|
|
||||||
// TODO: Show what we can.
|
// TODO: Show what we can.
|
||||||
|
@ -168,11 +167,6 @@ abstract class ArcanistMarkersWorkflow
|
||||||
return isset($types[$marker_type]);
|
return isset($types[$marker_type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTailHashes() {
|
|
||||||
$api = $this->getRepositoryAPI();
|
|
||||||
return $api->getPublishedCommitHashes();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function sortSets(
|
private function sortSets(
|
||||||
ArcanistCommitGraph $graph,
|
ArcanistCommitGraph $graph,
|
||||||
array $sets,
|
array $sets,
|
||||||
|
|
Loading…
Reference in a new issue