From: durham Date: Tue, 22 Jan 2013 22:29:00 +0000 (-0800) Subject: Allow hg arc land when no rebase is necessary X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=880964af831b9ba7defb3619e3513a029ec3868a;p=arcanist.git 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 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 --- diff --git a/src/workflow/ArcanistLandWorkflow.php b/src/workflow/ArcanistLandWorkflow.php index b9903c8a..c651376b 100644 --- a/src/workflow/ArcanistLandWorkflow.php +++ b/src/workflow/ArcanistLandWorkflow.php @@ -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."); + } } }