1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 14:52:40 +01:00

[Arcanist] add an arc:bookmark base for Mercurial

Summary:
This adds a new base option that Does the Right Thing (or as close to
it as I can get) for someone using Mercurial bookmarks as lightweight
branches, and where each branch should be one differential revision.
Specifically, it walks backwards through the ancestors of the working
copy until it finds a revision that is either not outgoing (ie already
in the remote) or that is bookmarked.  This means that bookmarks
effectively act as delimiters, and point at the last revision that
will be included in an arc diff.

Test Plan:
[14:40:54 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ hg log -r '(first(outgoing())^)::' --template='node: {node}\nbookmark: {bookmarks}\n\n' -G
@  node: c8379ef32b0d0e6cf94fe636751ea4fe1353e157
|  bookmark:
|
| o  node: 14f03139049cbda339190b814e52f4ec8b05c431
| |  bookmark: more
| |
| o  node: 6970e9263ab8c6da428420606d1f15c9980da183
| |  bookmark: something
| |
| o  node: 433a93023f03d5f3eddaa243fa973d32a1566aee
|/   bookmark:
|
o  node: f47ccfe34267592dd2e336174a3a311b8783c024
|  bookmark:
|

[14:41:00 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ ~/devtools/arcanist/bin/arc which --show-base --base 'arc:bookmark'
f47ccfe34267592dd2e336174a3a311b8783c024

[14:41:05 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ hg up 14f03139049cbda339190b814e52f4ec8b05c431
3 files updated, 0 files merged, 1 files removed, 0 files unresolved

[14:41:10 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ ~/devtools/arcanist/bin/arc which --show-base --base 'arc:bookmark'
6970e9263ab8c6da428420606d1f15c9980da183

[14:41:14 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1226 $ hg up 6970e9263ab8c6da428420606d1f15c9980da183
0 files updated, 0 files merged, 1 files removed, 0 files unresolved

[14:41:44 Tue Jun 26 2012] dschleimer@dev4022.snc6 ~/hg-dummy
hg-dummy  1227 $ ~/devtools/arcanist/bin/arc which --show-base --base 'arc:bookmark'
f47ccfe34267592dd2e336174a3a311b8783c024

Reviewers: epriestley, bos

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1331

Differential Revision: https://secure.phabricator.com/D2863
This commit is contained in:
dschleimer 2012-06-26 15:04:35 -07:00
parent 31e36fe3fa
commit 9edff28999
2 changed files with 19 additions and 0 deletions

View file

@ -165,6 +165,7 @@ final class ArcanistBaseCommitParser {
case 'empty':
case 'upstream':
case 'outgoing':
case 'bookmark':
return $this->api->resolveBaseCommitRule($rule, $source);
default:
$matches = null;

View file

@ -670,6 +670,24 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
"'base' configuration.");
return trim($outgoing_base);
}
case 'bookmark':
$revset =
'limit('.
' sort('.
' (ancestors(.) and bookmark() - .) or'.
' (ancestors(.) - outgoing()), '.
' -rev),'.
'1)';
list($err, $bookmark_base) = $this->execManualLocal(
'log --template={node} --rev %s',
$revset);
if (!$err) {
$this->setBaseCommitExplanation(
"it is the first ancestor of . that either has a bookmark, or ".
"is already in the remote and it matched the rule {$rule} in ".
"your {$source} 'base' configuration");
return trim($bookmark_base);
}
}
break;
default: