1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 16:22:42 +01:00

Add an experimental "--mergeup" flag to use a less volatile merge strategy in "arc land"

Summary:
See chatlog from https://secure.phabricator.com/chatlog/channel/%23phabricator/?at=37257

Basically, the install's developers sometimes use "git merge master" instead of "git rebase master" to pull changes from master into their branch. When we run "git rebase master" at the end, this creates a lot of conflicts.

Instead, optionally run "git merge master". This should be equivalent in our case (where we always rebase) and much better in their case (where they sometimes merge).

We're both going to use it for a bit and see if it creates problems. If it improves the "sometimes-merge" workflow without affecting the "always rebase" workflow, we can make it a default. If it improves theirs but damages ours, we can keep it a flag/option. If it's just terrible, we can figure out something else.

Test Plan:
Ran `arc land --mergeup --trace <feature> --keep-branch --hold`, see P624 for output. Observed merge update strategy and general success.

Also verified the conflict:

  $ arc land --mergeup --merge
  Usage Exception: Arguments '--mergeup' and '--merge' are mutually exclusive: The --merge strategy does not update the feature branch.

Reviewers: btrahan, vrana, DurhamGoode

Reviewed By: btrahan

CC: aran, keir

Differential Revision: https://secure.phabricator.com/D4080
This commit is contained in:
epriestley 2012-12-13 14:11:52 -08:00
parent 02694d73ab
commit 2d7224f0e3

View file

@ -17,6 +17,7 @@ final class ArcanistLandWorkflow extends ArcanistBaseWorkflow {
private $remote; private $remote;
private $useSquash; private $useSquash;
private $keepBranch; private $keepBranch;
private $shouldUpdateWithRebase;
private $revision; private $revision;
private $messageFile; private $messageFile;
@ -115,6 +116,13 @@ EOTEXT
'keep-branch' => true, 'keep-branch' => true,
), ),
), ),
'update-with-rebase' => array(
'help' => 'When updating the feature branch, use rebase intead of '.
'merge. This might make things work better in some cases.',
'conflicts' => array(
'merge' => 'The --merge strategy does not update the feature branch.',
),
),
'revision' => array( 'revision' => array(
'param' => 'id', 'param' => 'id',
'help' => 'Use the message from a specific revision, rather than '. 'help' => 'Use the message from a specific revision, rather than '.
@ -192,6 +200,7 @@ EOTEXT
} }
$this->branch = head($branch); $this->branch = head($branch);
$this->keepBranch = $this->getArgument('keep-branch'); $this->keepBranch = $this->getArgument('keep-branch');
$this->shouldUpdateWithRebase = $this->getArgument('update-with-rebase');
$onto_default = $this->isGit ? 'master' : 'default'; $onto_default = $this->isGit ? 'master' : 'default';
$onto_default = nonempty( $onto_default = nonempty(
@ -323,7 +332,7 @@ EOTEXT
} else if (count($revisions) > 1) { } else if (count($revisions) > 1) {
$message = $message =
"There are multiple revisions on feature branch '{$this->branch}' ". "There are multiple revisions on feature branch '{$this->branch}' ".
"which are not present on '{$onto}':\n\n". "which are not present on '{$this->onto}':\n\n".
$this->renderRevisionList($revisions)."\n". $this->renderRevisionList($revisions)."\n".
"Separate these revisions onto different branches, or use ". "Separate these revisions onto different branches, or use ".
"'--revision <id>' to select one."; "'--revision <id>' to select one.";
@ -438,23 +447,41 @@ EOTEXT
chdir($repository_api->getPath()); chdir($repository_api->getPath());
if ($this->isGit) { if ($this->isGit) {
$err = phutil_passthru('git rebase %s', $this->onto); if ($this->shouldUpdateWithRebase) {
} $err = phutil_passthru('git rebase %s', $this->onto);
else if ($this->isHg) { if ($err) {
throw new ArcanistUsageException(
"'git rebase {$this->onto}' failed. ".
"You can abort with 'git rebase --abort', ".
"or resolve conflicts and use 'git rebase ".
"--continue' to continue forward. After resolving the rebase, ".
"run 'arc land' again.");
}
} else {
$err = phutil_passthru(
'git merge %s -m %s',
$this->onto,
"Automatic merge by 'arc land'");
if ($err) {
throw new ArcanistUsageException(
"'git merge {$this->onto}' failed. ".
"To continue: resolve the conflicts, commit the changes, then run ".
"'arc land' again. To abort: run 'git merge --abort'.");
}
}
} else if ($this->isHg) {
// keep branch here so later we can decide whether to remove it // keep branch here so later we can decide whether to remove it
$err = $repository_api->execPassthru( $err = $repository_api->execPassthru(
'rebase -d %s --keepbranches', 'rebase -d %s --keepbranches',
$this->onto); $this->onto);
} if ($err) {
throw new ArcanistUsageException(
if ($err) { "'hg rebase {$this->onto}' failed. ".
$command = $repository_api->getSourceControlSystemName(); "You can abort with 'hg rebase --abort', ".
throw new ArcanistUsageException( "or resolve conflicts and use 'hg rebase ".
"'{$command} rebase {$this->onto}' failed. ". "--continue' to continue forward. After resolving the rebase, ".
"You can abort with '{$command} rebase --abort', ". "run 'arc land' again.");
"or resolve conflicts and use '{$command} rebase ". }
"--continue' to continue forward. After resolving the rebase, ".
"run 'arc land' again.");
} }
// Now that we've rebased, the merge-base of origin/master and HEAD may // Now that we've rebased, the merge-base of origin/master and HEAD may