mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 08:52:39 +01:00
Allow hg arc land when no rebase is necessary
Summary: Previously, trying to arc land in a mercurial repo would fail if the local branch was already at the tip of the onto branch (since hg rebase exited with code 1). This change makes it check if a rebase is needed before executing the rebase. Test Plan: hg init foo cd foo hg bookmark master touch a && hg add a && hg commit -ma // setup your .arcconfig cd .. hg clone foo foo2 cd foo2 hg bookmark mybook touch b && hg add b && hg commit -mb arc land --onto master --revision <your rev number> Arc land should succeed. I also tried landing when a rebase was necessary and it still worked. Reviewers: epriestley, dschleimer, bos Reviewed By: epriestley CC: sid0, aran, Korvin Differential Revision: https://secure.phabricator.com/D4588
This commit is contained in:
parent
98fec27752
commit
880964af83
1 changed files with 20 additions and 11 deletions
|
@ -470,17 +470,26 @@ EOTEXT
|
|||
}
|
||||
}
|
||||
} else if ($this->isHg) {
|
||||
// keep branch here so later we can decide whether to remove it
|
||||
$err = $repository_api->execPassthru(
|
||||
'rebase -d %s --keepbranches',
|
||||
$this->onto);
|
||||
if ($err) {
|
||||
throw new ArcanistUsageException(
|
||||
"'hg rebase {$this->onto}' failed. ".
|
||||
"You can abort with 'hg rebase --abort', ".
|
||||
"or resolve conflicts and use 'hg rebase ".
|
||||
"--continue' to continue forward. After resolving the rebase, ".
|
||||
"run 'arc land' again.");
|
||||
$onto_tip = $repository_api->getCanonicalRevisionName($this->onto);
|
||||
$common_ancestor = $repository_api->getCanonicalRevisionName(
|
||||
sprintf("ancestor('%s','%s')",
|
||||
$this->onto,
|
||||
$this->branch));
|
||||
|
||||
// Only rebase if the local branch is not at the tip of the onto branch.
|
||||
if ($onto_tip != $common_ancestor) {
|
||||
// keep branch here so later we can decide whether to remove it
|
||||
$err = $repository_api->execPassthru(
|
||||
'rebase -d %s --keepbranches',
|
||||
$this->onto);
|
||||
if ($err) {
|
||||
throw new ArcanistUsageException(
|
||||
"'hg rebase {$this->onto}' failed. ".
|
||||
"You can abort with 'hg rebase --abort', ".
|
||||
"or resolve conflicts and use 'hg rebase ".
|
||||
"--continue' to continue forward. After resolving the rebase, ".
|
||||
"run 'arc land' again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue