mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 10:12:41 +01:00
Allow 'arc diff .^' for hg repos
Summary: Previously arc diff for hg only allowed bookmark names, rev numbers, and commit hashes as the input base commit. This was because it escaped all inputs and treated them as raw identifiers. This change makes it treat the input as a revset if the escaped version fails. This allows users to do things like "arc diff .^" when they only want to diff the top commit. Test Plan: Created a stack of commits, master->A->B. hg up B arc diff .^ Verified the diff message only showed B as part of the diff. arc diff .^~ Verified an error occurred ("Commit '.^~' is not a valid Mercurial commit id.") Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2888 Differential Revision: https://secure.phabricator.com/D5638
This commit is contained in:
parent
cf76d2fc1c
commit
7c22017562
1 changed files with 20 additions and 7 deletions
|
@ -96,9 +96,15 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
$commit = $this->getCanonicalRevisionName(
|
$commit = $this->getCanonicalRevisionName(
|
||||||
hgsprintf('ancestor(%s,.)', $symbolic_commit));
|
hgsprintf('ancestor(%s,.)', $symbolic_commit));
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
throw new ArcanistUsageException(
|
// Try it as a revset instead of a commit id
|
||||||
"Commit '{$symbolic_commit}' is not a valid Mercurial commit ".
|
try {
|
||||||
"identifier.");
|
$commit = $this->getCanonicalRevisionName(
|
||||||
|
hgsprintf('ancestor(%R,.)', $symbolic_commit));
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
throw new ArcanistUsageException(
|
||||||
|
"Commit '{$symbolic_commit}' is not a valid Mercurial commit ".
|
||||||
|
"identifier.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setBaseCommitExplanation("it is the greatest common ancestor of ".
|
$this->setBaseCommitExplanation("it is the greatest common ancestor of ".
|
||||||
|
@ -752,14 +758,21 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
return trim($merge_base);
|
return trim($merge_base);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list($err) = $this->execManualLocal(
|
list($err, $commit) = $this->execManualLocal(
|
||||||
'id -r %s',
|
'log --template {node} --rev %s',
|
||||||
$name);
|
hgsprintf('%s', $name));
|
||||||
|
|
||||||
|
if ($err) {
|
||||||
|
list($err, $commit) = $this->execManualLocal(
|
||||||
|
'log --template {node} --rev %s',
|
||||||
|
$name);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$err) {
|
if (!$err) {
|
||||||
$this->setBaseCommitExplanation(
|
$this->setBaseCommitExplanation(
|
||||||
"it is specified by '{$rule}' in your {$source} 'base' ".
|
"it is specified by '{$rule}' in your {$source} 'base' ".
|
||||||
"configuration.");
|
"configuration.");
|
||||||
return $name;
|
return trim($commit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue