From 9edff28999e1ce7d60f7285bbcd0d988fd95f1aa Mon Sep 17 00:00:00 2001 From: dschleimer Date: Tue, 26 Jun 2012 15:04:35 -0700 Subject: [PATCH] [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 --- src/parser/ArcanistBaseCommitParser.php | 1 + src/repository/api/ArcanistMercurialAPI.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/parser/ArcanistBaseCommitParser.php b/src/parser/ArcanistBaseCommitParser.php index 21da3911..b4a319d6 100644 --- a/src/parser/ArcanistBaseCommitParser.php +++ b/src/parser/ArcanistBaseCommitParser.php @@ -165,6 +165,7 @@ final class ArcanistBaseCommitParser { case 'empty': case 'upstream': case 'outgoing': + case 'bookmark': return $this->api->resolveBaseCommitRule($rule, $source); default: $matches = null; diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index 00371d95..058707f5 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -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: -- 2.43.0