]> khamidou — GitHub mirrors - arcanist.git/commitdiff
[Arcanist] add an arc:bookmark base for Mercurial
authordschleimer <dschleimer@fb.com>
Tue, 26 Jun 2012 22:04:35 +0000 (15:04 -0700)
committerdschleimer <dschleimer@fb.com>
Tue, 26 Jun 2012 22:04:35 +0000 (15:04 -0700)
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

src/parser/ArcanistBaseCommitParser.php
src/repository/api/ArcanistMercurialAPI.php

index 21da391107fa0176dbd98a23958ab90ca71f950c..b4a319d6449c7d58d165531692b1289f00ff1729 100644 (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;
index 00371d95a58b040f30e740b3470fa9e815562df5..058707f52c8cd46aff766e9dbc52e47a1d1c68c5 100644 (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: