1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-04-11 03:48:33 +02:00

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
This commit is contained in:
epriestley 2013-02-14 13:57:34 -08:00
parent 7803b7da27
commit 39704f1e49

View file

@ -672,6 +672,11 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
public function resolveBaseCommitRule($rule, $source) { public function resolveBaseCommitRule($rule, $source) {
list($type, $name) = explode(':', $rule, 2); 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) { switch ($type) {
case 'hg': case 'hg':
$matches = null; $matches = null;
@ -728,7 +733,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
"configuration."); "configuration.");
// NOTE: This should be safe because Mercurial doesn't support // NOTE: This should be safe because Mercurial doesn't support
// amend until 2.2. // amend until 2.2.
return '.^'; return $this->getCanonicalRevisionName('.^');
} }
break; break;
case 'bookmark': case 'bookmark':
@ -754,7 +759,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
$this->setBaseCommitExplanation( $this->setBaseCommitExplanation(
"you specified '{$rule}' in your {$source} 'base' ". "you specified '{$rule}' in your {$source} 'base' ".
"configuration."); "configuration.");
return '.^'; return $this->getCanonicalRevisionName('.^');
} }
break; break;
default: default: