From 39704f1e49f3a2e3453c2ca9cf8f9069b78b2aa0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 14 Feb 2013 13:57:34 -0800 Subject: [PATCH] Fix "arc:this" and "arc:amended" base rules after D4838 Summary: After D4383, we escape the base commit when constructing a command like this: hg log --rev (base::. - base) However, if the base commit is a revset like ".^", we now escape it and Mercurial looks for a commit named ".^" (a valid mercurial branch name) instead. Fix this by returning nodes for these rules instead of revsets. The "arc:this" rule is automatically used in some operations, like "arc amend", so users can hit this during normal workflows, not just with weird `--base` rules. Test Plan: Ran "arc amend" in a Mercurial repository, didn't fatal out. Reviewers: DurhamGoode, sid0 Reviewed By: DurhamGoode CC: tido, aran Differential Revision: https://secure.phabricator.com/D4949 --- src/repository/api/ArcanistMercurialAPI.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index f59d4dc6..93903506 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -672,6 +672,11 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { public function resolveBaseCommitRule($rule, $source) { list($type, $name) = explode(':', $rule, 2); + // NOTE: This function MUST return node hashes or symbolic commits (like + // branch names or the word "tip"), not revsets. This includes ".^" and + // similar, which a revset, not a symbolic commit identifier. If you return + // a revset it will be escaped later and looked up literally. + switch ($type) { case 'hg': $matches = null; @@ -728,7 +733,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { "configuration."); // NOTE: This should be safe because Mercurial doesn't support // amend until 2.2. - return '.^'; + return $this->getCanonicalRevisionName('.^'); } break; case 'bookmark': @@ -754,7 +759,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $this->setBaseCommitExplanation( "you specified '{$rule}' in your {$source} 'base' ". "configuration."); - return '.^'; + return $this->getCanonicalRevisionName('.^'); } break; default: -- 2.43.0