Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lands a branch by rebasing, merging and amending it.
|
|
|
|
*
|
|
|
|
* @group workflow
|
|
|
|
*/
|
2012-01-31 21:07:05 +01:00
|
|
|
final class ArcanistLandWorkflow extends ArcanistBaseWorkflow {
|
2012-12-03 22:03:13 +01:00
|
|
|
private $isGit;
|
2012-12-08 03:13:32 +01:00
|
|
|
private $isGitSvn;
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
private $isHg;
|
2012-12-03 22:03:13 +01:00
|
|
|
|
|
|
|
private $oldBranch;
|
|
|
|
private $branch;
|
|
|
|
private $onto;
|
|
|
|
private $ontoRemoteBranch;
|
|
|
|
private $remote;
|
|
|
|
private $useSquash;
|
|
|
|
private $keepBranch;
|
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
2012-12-13 23:11:52 +01:00
|
|
|
private $shouldUpdateWithRebase;
|
2012-12-03 22:03:13 +01:00
|
|
|
|
|
|
|
private $revision;
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
private $messageFile;
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
Make Arcanist workflow names explicit
Summary:
Currently, adding a new workflow requires you to override ArcanistConfiguration, which is messy. Instead, just load everything that extends ArcanistBaseWorkflow.
Remove all the rules tying workflow names to class names through arcane incantations.
This has a very small performance cost in that we need to load every Workflow class every time now, but we don't hit __init__ and such anymore and it was pretty negligible on my machine (98ms vs 104ms or something).
Test Plan: Ran "arc help", "arc which", "arc diff", etc.
Reviewers: edward, vrana, btrahan
Reviewed By: edward
CC: aran, zeeg
Differential Revision: https://secure.phabricator.com/D3691
2012-10-17 17:35:03 +02:00
|
|
|
public function getWorkflowName() {
|
|
|
|
return 'land';
|
|
|
|
}
|
|
|
|
|
2012-03-05 19:02:37 +01:00
|
|
|
public function getCommandSynopses() {
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
return phutil_console_format(<<<EOTEXT
|
2012-04-23 23:09:29 +02:00
|
|
|
**land** [__options__] [__branch__] [--onto __master__]
|
2012-03-05 19:02:37 +01:00
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandHelp() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
Supports: git, hg
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
|
|
|
Land an accepted change (currently sitting in local feature branch
|
|
|
|
__branch__) onto __master__ and push it to the remote. Then, delete
|
2012-04-23 23:09:29 +02:00
|
|
|
the feature branch. If you omit __branch__, the current branch will
|
|
|
|
be used.
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
|
|
|
In mutable repositories, this will perform a --squash merge (the
|
|
|
|
entire branch will be represented by one commit on __master__). In
|
2012-02-20 21:51:14 +01:00
|
|
|
immutable repositories (or when --merge is provided), it will perform
|
|
|
|
a --no-ff merge (the branch will always be merged into __master__ with
|
|
|
|
a merge commit).
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
|
|
|
|
Under hg, bookmarks can be landed the same way as branches.
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresWorkingCopy() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresConduit() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresAuthentication() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresRepositoryAPI() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArguments() {
|
|
|
|
return array(
|
|
|
|
'onto' => array(
|
|
|
|
'param' => 'master',
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
'help' => "Land feature branch onto a branch other than the default ".
|
|
|
|
"('master' in git, 'default' in hg). You can change the ".
|
|
|
|
"default by setting 'arc.land.onto.default' with ".
|
|
|
|
"`arc set-config` or for the entire project in .arcconfig.",
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
),
|
|
|
|
'hold' => array(
|
|
|
|
'help' => "Prepare the change to be pushed, but do not actually ".
|
|
|
|
"push it.",
|
|
|
|
),
|
|
|
|
'keep-branch' => array(
|
|
|
|
'help' => "Keep the feature branch after pushing changes to the ".
|
|
|
|
"remote (by default, it is deleted).",
|
|
|
|
),
|
|
|
|
'remote' => array(
|
|
|
|
'param' => 'origin',
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
'help' => "Push to a remote other than the default ('origin' in git).",
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
),
|
2012-02-20 21:51:14 +01:00
|
|
|
'merge' => array(
|
|
|
|
'help' => 'Perform a --no-ff merge, not a --squash merge. If the '.
|
|
|
|
'project is marked as having an immutable history, this is '.
|
|
|
|
'the default behavior.',
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
'supports' => array(
|
|
|
|
'git',
|
|
|
|
),
|
|
|
|
'nosupport' => array(
|
|
|
|
'hg' => 'Use the --squash strategy when landing in mercurial.',
|
|
|
|
),
|
2012-02-20 21:51:14 +01:00
|
|
|
),
|
2012-03-23 02:20:22 +01:00
|
|
|
'squash' => array(
|
|
|
|
'help' => 'Perform a --squash merge, not a --no-ff merge. If the '.
|
|
|
|
'project is marked as having a mutable history, this is '.
|
|
|
|
'the default behavior.',
|
|
|
|
'conflicts' => array(
|
|
|
|
'merge' => '--merge and --squash are conflicting merge strategies.',
|
|
|
|
),
|
|
|
|
),
|
2012-05-10 21:14:53 +02:00
|
|
|
'delete-remote' => array(
|
|
|
|
'help' => 'Delete the feature branch in the remote after '.
|
|
|
|
'landing it.',
|
|
|
|
'conflicts' => array(
|
|
|
|
'keep-branch' => true,
|
|
|
|
),
|
|
|
|
),
|
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
2012-12-13 23:11:52 +01:00
|
|
|
'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.',
|
|
|
|
),
|
|
|
|
),
|
2012-03-03 01:47:05 +01:00
|
|
|
'revision' => array(
|
|
|
|
'param' => 'id',
|
|
|
|
'help' => 'Use the message from a specific revision, rather than '.
|
|
|
|
'inferring the revision based on branch content.',
|
|
|
|
),
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
'*' => 'branch',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run() {
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->readArguments();
|
|
|
|
$this->validate();
|
2012-12-21 23:18:07 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
$this->pullFromRemote();
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
$this->restoreBranch();
|
|
|
|
throw $ex;
|
|
|
|
}
|
2012-12-03 22:03:13 +01:00
|
|
|
|
2012-12-04 01:31:45 +01:00
|
|
|
$this->checkoutBranch();
|
|
|
|
$this->findRevision();
|
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
if ($this->useSquash) {
|
|
|
|
$this->rebase();
|
|
|
|
$this->squash();
|
|
|
|
} else {
|
|
|
|
$this->merge();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->push();
|
2012-12-21 23:18:07 +01:00
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
if (!$this->keepBranch) {
|
|
|
|
$this->cleanupBranch();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we were on some branch A and the user ran "arc land B",
|
|
|
|
// switch back to A.
|
|
|
|
if ($this->oldBranch != $this->branch && $this->oldBranch != $this->onto) {
|
2012-12-21 23:18:07 +01:00
|
|
|
$this->restoreBranch();
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "Done.\n";
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function readArguments() {
|
2012-04-23 23:09:29 +02:00
|
|
|
$repository_api = $this->getRepositoryAPI();
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->isGit = $repository_api instanceof ArcanistGitAPI;
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$this->isHg = $repository_api instanceof ArcanistMercurialAPI;
|
2012-12-03 22:03:13 +01:00
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if (!$this->isGit && !$this->isHg) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"'arc land' only supports git and mercurial.");
|
2012-04-23 23:09:29 +02:00
|
|
|
}
|
|
|
|
|
2012-12-08 03:13:32 +01:00
|
|
|
if ($this->isGit) {
|
|
|
|
$repository = $this->loadProjectRepository();
|
|
|
|
$this->isGitSvn = (idx($repository, 'vcs') == 'svn');
|
|
|
|
}
|
|
|
|
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
$branch = $this->getArgument('branch');
|
2012-04-23 23:09:29 +02:00
|
|
|
if (empty($branch)) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$branch = $this->getBranchOrBookmark();
|
2012-12-03 22:03:13 +01:00
|
|
|
|
2012-04-23 23:09:29 +02:00
|
|
|
if ($branch) {
|
|
|
|
echo "Landing current branch '{$branch}'.\n";
|
|
|
|
$branch = array($branch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
if (count($branch) !== 1) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"Specify exactly one branch to land changes from.");
|
|
|
|
}
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->branch = head($branch);
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$this->keepBranch = $this->getArgument('keep-branch');
|
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
2012-12-13 23:11:52 +01:00
|
|
|
$this->shouldUpdateWithRebase = $this->getArgument('update-with-rebase');
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$onto_default = $this->isGit ? 'master' : 'default';
|
2012-03-23 02:20:22 +01:00
|
|
|
$onto_default = nonempty(
|
2012-06-20 21:29:07 +02:00
|
|
|
$this->getWorkingCopy()->getConfigFromAnySource('arc.land.onto.default'),
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$onto_default);
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->onto = $this->getArgument('onto', $onto_default);
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
|
|
|
|
$remote_default = $this->isGit ? 'origin' : '';
|
|
|
|
$this->remote = $this->getArgument('remote', $remote_default);
|
2012-12-03 22:03:13 +01:00
|
|
|
|
|
|
|
if ($this->getArgument('merge')) {
|
|
|
|
$this->useSquash = false;
|
|
|
|
} else if ($this->getArgument('squash')) {
|
|
|
|
$this->useSquash = true;
|
|
|
|
} else {
|
|
|
|
$this->useSquash = !$this->isHistoryImmutable();
|
|
|
|
}
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$this->ontoRemoteBranch = $this->onto;
|
2012-12-08 03:13:32 +01:00
|
|
|
if ($this->isGitSvn) {
|
|
|
|
$this->ontoRemoteBranch = 'trunk';
|
|
|
|
} else if ($this->isGit) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$this->ontoRemoteBranch = $this->remote.'/'.$this->onto;
|
|
|
|
}
|
2012-12-03 22:03:13 +01:00
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$this->oldBranch = $this->getBranchOrBookmark();
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
2012-03-23 02:20:22 +01:00
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
private function validate() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
2012-05-23 20:40:20 +02:00
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
if ($this->onto == $this->branch) {
|
2012-05-23 20:40:20 +02:00
|
|
|
$message =
|
2012-05-10 21:14:53 +02:00
|
|
|
"You can not land a branch onto itself -- you are trying to land ".
|
2012-12-03 22:03:13 +01:00
|
|
|
"'{$this->branch}' onto '{$this->onto}'. For more information on ".
|
|
|
|
"how to push changes, see 'Pushing and Closing Revisions' in ".
|
2012-05-23 20:40:20 +02:00
|
|
|
"'Arcanist User Guide: arc diff' in the documentation.";
|
2012-12-03 22:03:13 +01:00
|
|
|
if (!$this->isHistoryImmutable()) {
|
2012-05-23 20:40:20 +02:00
|
|
|
$message .= " You may be able to 'arc amend' instead.";
|
|
|
|
}
|
|
|
|
throw new ArcanistUsageException($message);
|
2012-05-10 21:14:53 +02:00
|
|
|
}
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($this->isHg) {
|
|
|
|
if ($this->useSquash) {
|
|
|
|
list ($err) = $repository_api->execManualLocal("rebase --help");
|
|
|
|
if ($err) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"You must enable the rebase extension to use ".
|
|
|
|
"the --squash strategy.");
|
|
|
|
}
|
|
|
|
}
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($repository_api->isBookmark($this->branch) &&
|
|
|
|
!$repository_api->isBookmark($this->onto)) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"Source {$this->branch} is a bookmark but destination ".
|
|
|
|
"{$this->onto} is not a bookmark. When landing a bookmark, ".
|
|
|
|
"the destination must also be a bookmark. Use --onto to specify ".
|
|
|
|
"a bookmark, or set arc.land.onto.default in .arcconfig.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($repository_api->isBranch($this->branch) &&
|
|
|
|
!$repository_api->isBranch($this->onto)) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"Source {$this->branch} is a branch but destination {$this->onto} ".
|
|
|
|
"is not a branch. When landing a branch, the destination must also ".
|
|
|
|
"be a branch. Use --onto to specify a branch, or set ".
|
|
|
|
"arc.land.onto.default in .arcconfig.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->isGit) {
|
|
|
|
list($err) = $repository_api->execManualLocal(
|
|
|
|
'rev-parse --verify %s',
|
|
|
|
$this->branch);
|
|
|
|
|
|
|
|
if ($err) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"Branch '{$this->branch}' does not exist.");
|
|
|
|
}
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
}
|
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->requireCleanWorkingCopy();
|
|
|
|
}
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
2012-12-04 01:31:45 +01:00
|
|
|
private function checkoutBranch() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'checkout %s',
|
|
|
|
$this->branch);
|
|
|
|
|
|
|
|
echo phutil_console_format(
|
|
|
|
"Switched to branch **%s**. Identifying and merging...\n",
|
|
|
|
$this->branch);
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
private function findRevision() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
2012-12-17 21:54:08 +01:00
|
|
|
$this->parseBaseCommitArgument(array($this->ontoRemoteBranch));
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
2012-03-03 01:47:05 +01:00
|
|
|
$revision_id = $this->getArgument('revision');
|
|
|
|
if ($revision_id) {
|
|
|
|
$revision_id = $this->normalizeRevisionID($revision_id);
|
|
|
|
$revisions = $this->getConduit()->callMethodSynchronous(
|
|
|
|
'differential.query',
|
|
|
|
array(
|
|
|
|
'ids' => array($revision_id),
|
|
|
|
));
|
|
|
|
if (!$revisions) {
|
|
|
|
throw new ArcanistUsageException("No such revision 'D{$revision_id}'!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
|
|
|
|
$this->getConduit(),
|
|
|
|
array(
|
|
|
|
'authors' => array($this->getUserPHID()),
|
|
|
|
));
|
|
|
|
}
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
|
|
|
if (!count($revisions)) {
|
|
|
|
throw new ArcanistUsageException(
|
2012-12-03 22:03:13 +01:00
|
|
|
"arc can not identify which revision exists on branch ".
|
|
|
|
"'{$this->branch}'. Update the revision with recent changes ".
|
|
|
|
"to synchronize the branch name and hashes, or use 'arc amend' ".
|
|
|
|
"to amend the commit message at HEAD, or use '--revision <id>' ".
|
|
|
|
"to select a revision explicitly.");
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
} else if (count($revisions) > 1) {
|
|
|
|
$message =
|
2012-12-03 22:03:13 +01:00
|
|
|
"There are multiple revisions on feature branch '{$this->branch}' ".
|
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
2012-12-13 23:11:52 +01:00
|
|
|
"which are not present on '{$this->onto}':\n\n".
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
$this->renderRevisionList($revisions)."\n".
|
2012-03-03 01:47:05 +01:00
|
|
|
"Separate these revisions onto different branches, or use ".
|
|
|
|
"'--revision <id>' to select one.";
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
throw new ArcanistUsageException($message);
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->revision = head($revisions);
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
$rev_status = $this->revision['status'];
|
|
|
|
$rev_id = $this->revision['id'];
|
|
|
|
$rev_title = $this->revision['title'];
|
|
|
|
|
|
|
|
if ($rev_status != ArcanistDifferentialRevisionStatus::ACCEPTED) {
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
$ok = phutil_console_confirm(
|
2012-12-03 22:03:13 +01:00
|
|
|
"Revision 'D{$rev_id}: {$rev_title}' has not been ".
|
|
|
|
"accepted. Continue anyway?");
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
if (!$ok) {
|
|
|
|
throw new ArcanistUserAbortException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$message = $this->getConduit()->callMethodSynchronous(
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
'differential.getcommitmessage',
|
|
|
|
array(
|
2012-12-03 22:03:13 +01:00
|
|
|
'revision_id' => $rev_id,
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
));
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$this->messageFile = new TempFile();
|
|
|
|
Filesystem::writeFile($this->messageFile, $message);
|
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
echo "Landing revision 'D{$rev_id}: ".
|
|
|
|
"{$rev_title}'...\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
private function pullFromRemote() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
$repository_api->execxLocal('checkout %s', $this->onto);
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
echo phutil_console_format(
|
|
|
|
"Switched to branch **%s**. Updating branch...\n",
|
|
|
|
$this->onto);
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$local_ahead_of_remote = false;
|
|
|
|
if ($this->isGit) {
|
|
|
|
$repository_api->execxLocal('pull --ff-only');
|
2012-12-03 22:03:13 +01:00
|
|
|
|
2012-12-08 03:13:32 +01:00
|
|
|
if (!$this->isGitSvn) {
|
|
|
|
list($out) = $repository_api->execxLocal(
|
|
|
|
'log %s..%s',
|
|
|
|
$this->ontoRemoteBranch,
|
|
|
|
$this->onto);
|
|
|
|
if (strlen(trim($out))) {
|
|
|
|
$local_ahead_of_remote = true;
|
|
|
|
}
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
}
|
|
|
|
} else if ($this->isHg) {
|
|
|
|
// execManual instead of execx because outgoing returns
|
|
|
|
// code 1 when there is nothing outgoing
|
|
|
|
list($err, $out) = $repository_api->execManualLocal(
|
|
|
|
'outgoing -r %s',
|
|
|
|
$this->onto);
|
|
|
|
|
|
|
|
// $err === 0 means something is outgoing
|
|
|
|
if ($err === 0) {
|
|
|
|
$local_ahead_of_remote = true;
|
2013-01-16 21:15:46 +01:00
|
|
|
} else {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
try {
|
|
|
|
$repository_api->execxLocal('pull -u');
|
|
|
|
} catch (CommandException $ex) {
|
|
|
|
$err = $ex->getError();
|
|
|
|
$stdout = $ex->getStdOut();
|
|
|
|
|
|
|
|
// Copied from: PhabricatorRepositoryPullLocalDaemon.php
|
|
|
|
// NOTE: Between versions 2.1 and 2.1.1, Mercurial changed the
|
|
|
|
// behavior of "hg pull" to return 1 in case of a successful pull
|
|
|
|
// with no changes. This behavior has been reverted, but users who
|
|
|
|
// updated between Feb 1, 2012 and Mar 1, 2012 will have the
|
|
|
|
// erroring version. Do a dumb test against stdout to check for this
|
|
|
|
// possibility.
|
|
|
|
// See: https://github.com/facebook/phabricator/issues/101/
|
|
|
|
|
|
|
|
// NOTE: Mercurial has translated versions, which translate this error
|
|
|
|
// string. In a translated version, the string will be something else,
|
|
|
|
// like "aucun changement trouve". There didn't seem to be an easy way
|
|
|
|
// to handle this (there are hard ways but this is not a common
|
|
|
|
// problem and only creates log spam, not application failures).
|
|
|
|
// Assume English.
|
|
|
|
|
|
|
|
// TODO: Remove this once we're far enough in the future that
|
|
|
|
// deployment of 2.1 is exceedingly rare?
|
|
|
|
if ($err == 1 && preg_match('/no changes found/', $stdout)) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
throw $ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($local_ahead_of_remote) {
|
2012-12-03 22:03:13 +01:00
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"Local branch '{$this->onto}' is ahead of remote branch ".
|
|
|
|
"'{$this->ontoRemoteBranch}', so landing a feature branch ".
|
|
|
|
"would push additional changes. Push or reset the changes ".
|
|
|
|
"in '{$this->onto}' before running 'arc land'.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function rebase() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
|
2012-12-04 01:31:45 +01:00
|
|
|
chdir($repository_api->getPath());
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($this->isGit) {
|
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
2012-12-13 23:11:52 +01:00
|
|
|
if ($this->shouldUpdateWithRebase) {
|
|
|
|
$err = phutil_passthru('git rebase %s', $this->onto);
|
|
|
|
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) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
// keep branch here so later we can decide whether to remove it
|
|
|
|
$err = $repository_api->execPassthru(
|
|
|
|
'rebase -d %s --keepbranches',
|
|
|
|
$this->onto);
|
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
2012-12-13 23:11:52 +01:00
|
|
|
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.");
|
|
|
|
}
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
}
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
|
2012-12-17 21:54:08 +01:00
|
|
|
$repository_api->reloadWorkingCopy();
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function squash() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
$repository_api->execxLocal('checkout %s', $this->onto);
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($this->isGit) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'merge --squash --ff-only %s',
|
|
|
|
$this->branch);
|
2013-01-16 21:15:46 +01:00
|
|
|
} else if ($this->isHg) {
|
2012-12-06 04:31:25 +01:00
|
|
|
// The hg code is a little more complex than git's because we
|
|
|
|
// need to handle the case where the landing branch has child branches:
|
|
|
|
// -a--------b master
|
|
|
|
// \
|
|
|
|
// w--x mybranch
|
|
|
|
// \--y subbranch1
|
|
|
|
// \--z subbranch2
|
|
|
|
//
|
|
|
|
// arc land --branch mybranch --onto master :
|
|
|
|
// -a--b--wx master
|
|
|
|
// \--y subbranch1
|
|
|
|
// \--z subbranch2
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$branch_rev_id = $repository_api->getCanonicalRevisionName($this->branch);
|
|
|
|
|
2012-12-06 04:31:25 +01:00
|
|
|
// At this point $this->onto has been pulled from remote and
|
|
|
|
// $this->branch has been rebased on top of onto(by the rebase()
|
|
|
|
// function). So we're guaranteed to have onto as an ancestor of branch
|
|
|
|
// when we use first((onto::branch)-onto) below.
|
|
|
|
$branch_root = $repository_api->getCanonicalRevisionName(
|
|
|
|
sprintf("first((%s::%s)-%s)",
|
|
|
|
$this->onto,
|
|
|
|
$this->branch,
|
|
|
|
$this->onto));
|
|
|
|
|
|
|
|
$branch_range = sprintf(
|
|
|
|
"(%s::%s)",
|
|
|
|
$branch_root,
|
|
|
|
$this->branch);
|
|
|
|
|
|
|
|
if (!$this->keepBranch) {
|
|
|
|
$this->handleAlternateBranches($branch_root, $branch_range);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Collapse just the landing branch onto master.
|
|
|
|
// Leave its children on the original branch.
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$repository_api->execxLocal(
|
2012-12-06 04:31:25 +01:00
|
|
|
'rebase --collapse --keep --logfile %s -r %s -d %s',
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$this->messageFile,
|
2012-12-06 04:31:25 +01:00
|
|
|
$branch_range,
|
|
|
|
$this->onto);
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($repository_api->isBookmark($this->branch)) {
|
|
|
|
// a bug in mercurial means bookmarks end up on the revision prior
|
|
|
|
// to the collapse when using --collapse with --keep,
|
|
|
|
// so we manually move them to the correct spots
|
|
|
|
// see: http://bz.selenic.com/show_bug.cgi?id=3716
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'bookmark -f %s',
|
|
|
|
$this->onto);
|
|
|
|
|
2012-12-06 04:31:25 +01:00
|
|
|
$repository_api->execxLocal(
|
|
|
|
'bookmark -f %s -r %s',
|
|
|
|
$this->branch,
|
|
|
|
$branch_rev_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if the branch had children
|
|
|
|
list($output) = $repository_api->execxLocal(
|
|
|
|
"log -r %s --template '{node}\\n'",
|
|
|
|
sprintf("children(%s)", $this->branch));
|
|
|
|
|
|
|
|
$child_branch_roots = phutil_split_lines($output, false);
|
|
|
|
$child_branch_roots = array_filter($child_branch_roots);
|
|
|
|
if ($child_branch_roots) {
|
|
|
|
// move the branch's children onto the collapsed commit
|
|
|
|
foreach ($child_branch_roots as $child_root) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$repository_api->execxLocal(
|
2012-12-06 04:31:25 +01:00
|
|
|
'rebase -d %s -s %s --keep --keepbranches',
|
|
|
|
$this->onto,
|
|
|
|
$child_root);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete the old branch if necessary
|
|
|
|
if (!$this->keepBranch) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'strip -r %s',
|
|
|
|
$branch_root);
|
|
|
|
|
|
|
|
if ($repository_api->isBookmark($this->branch)) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'bookmark -d %s',
|
|
|
|
$this->branch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// All the rebases may have moved us to another branch
|
|
|
|
// so we move back.
|
|
|
|
$repository_api->execxLocal('checkout %s', $this->onto);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Detect alternate branches and prompt the user for how to handle
|
|
|
|
* them. An alternate branch is a branch that forks from the landing
|
|
|
|
* branch prior to the landing branch tip.
|
|
|
|
*
|
|
|
|
* In a situation like this:
|
|
|
|
* -a--------b master
|
|
|
|
* \
|
|
|
|
* w--x landingbranch
|
|
|
|
* \ \-- g subbranch
|
|
|
|
* \--y altbranch1
|
|
|
|
* \--z altbranch2
|
|
|
|
*
|
|
|
|
* y and z are alternate branches and will get deleted by the squash,
|
|
|
|
* so we need to detect them and ask the user what they want to do.
|
|
|
|
*
|
|
|
|
* @param string The revision id of the landing branch's root commit.
|
|
|
|
* @param string The revset specifying all the commits in the landing branch.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function handleAlternateBranches($branch_root, $branch_range) {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
|
|
|
|
// Using the tree in the doccomment, the revset below resolves as follows:
|
|
|
|
// 1. roots(descendants(w) - descendants(x) - (w::x))
|
|
|
|
// 2. roots({x,g,y,z} - {g} - {w,x})
|
|
|
|
// 3. roots({y,z})
|
|
|
|
// 4. {y,z}
|
|
|
|
$alt_branch_revset = sprintf(
|
|
|
|
'roots(descendants(%s)-descendants(%s)-%s)',
|
|
|
|
$branch_root,
|
|
|
|
$this->branch,
|
|
|
|
$branch_range);
|
|
|
|
list($alt_branches) = $repository_api->execxLocal(
|
|
|
|
"log --template '{node}\n' -r %s",
|
|
|
|
$alt_branch_revset);
|
|
|
|
|
|
|
|
$alt_branches = phutil_split_lines($alt_branches, false);
|
|
|
|
$alt_branches = array_filter($alt_branches);
|
|
|
|
|
|
|
|
$alt_count = count($alt_branches);
|
|
|
|
if ($alt_count > 0) {
|
|
|
|
$input = phutil_console_prompt(
|
|
|
|
"Branch {$this->branch} has {$alt_count} branch(s) forking off of it ".
|
|
|
|
"that would be deleted during a squash. Would you like to keep a ".
|
|
|
|
"non-squashed copy, rebase them on top of {$this->branch}, or abort ".
|
|
|
|
"and deal with them yourself? (k)eep, (r)ebase, (a)bort:");
|
|
|
|
|
|
|
|
if ($input == 'k' || $input == 'keep') {
|
|
|
|
$this->keepBranch = true;
|
|
|
|
} else if ($input == 'r' || $input == 'rebase') {
|
|
|
|
foreach ($alt_branches as $alt_branch) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'rebase --keep --keepbranches -d %s -s %s',
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$this->branch,
|
2012-12-06 04:31:25 +01:00
|
|
|
$alt_branch);
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
}
|
2012-12-06 04:31:25 +01:00
|
|
|
} else if ($input == 'a' || $input == 'abort') {
|
|
|
|
$branch_string = implode("\n", $alt_branches);
|
|
|
|
echo "\nRemove the branches starting at these revision and ".
|
|
|
|
"run arc land again:\n{$branch_string}\n\n";
|
|
|
|
throw new ArcanistUserAbortException();
|
|
|
|
} else {
|
|
|
|
throw new ArcanistUsageException("Invalid choice. Aborting arc land.");
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
}
|
|
|
|
}
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function merge() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
|
|
|
|
// In immutable histories, do a --no-ff merge to force a merge commit with
|
|
|
|
// the right message.
|
|
|
|
$repository_api->execxLocal('checkout %s', $this->onto);
|
|
|
|
|
|
|
|
chdir($repository_api->getPath());
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($this->isGit) {
|
|
|
|
$err = phutil_passthru(
|
|
|
|
'git merge --no-ff --no-commit %s',
|
|
|
|
$this->branch);
|
2012-12-03 22:03:13 +01:00
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($err) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"'git merge' failed. Your working copy has been left in a partially ".
|
|
|
|
"merged state. You can: abort with 'git merge --abort'; or follow ".
|
|
|
|
"the instructions to complete the merge.");
|
|
|
|
}
|
2013-01-16 21:15:46 +01:00
|
|
|
} else if ($this->isHg) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
// HG arc land currently doesn't support --merge.
|
|
|
|
// When merging a bookmark branch to a master branch that
|
|
|
|
// hasn't changed since the fork, mercurial fails to merge.
|
|
|
|
// Instead of only working in some cases, we just disable --merge
|
|
|
|
// until there is a demand for it.
|
|
|
|
// The user should never reach this line, since --merge is
|
|
|
|
// forbidden at the command line argument level.
|
2012-12-03 22:03:13 +01:00
|
|
|
throw new ArcanistUsageException(
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
"--merge is not currently supported for hg repos.");
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function push() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($this->isGit) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'commit -F %s',
|
|
|
|
$this->messageFile);
|
2012-12-21 23:18:07 +01:00
|
|
|
} else if ($this->isHg) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
// hg rebase produces a commit earlier as part of rebase
|
|
|
|
if (!$this->useSquash) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'commit --logfile %s',
|
|
|
|
$this->messageFile);
|
|
|
|
}
|
|
|
|
}
|
2012-05-03 01:48:44 +02:00
|
|
|
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
if ($this->getArgument('hold')) {
|
|
|
|
echo phutil_console_format(
|
|
|
|
"Holding change in **%s**: it has NOT been pushed yet.\n",
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->onto);
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
} else {
|
|
|
|
echo "Pushing change...\n\n";
|
|
|
|
|
2012-03-23 02:20:22 +01:00
|
|
|
chdir($repository_api->getPath());
|
2012-12-03 22:03:13 +01:00
|
|
|
|
2012-12-08 03:13:32 +01:00
|
|
|
if ($this->isGitSvn) {
|
|
|
|
$err = phutil_passthru('git svn dcommit');
|
2012-12-21 23:18:07 +01:00
|
|
|
$cmd = "git svn dcommit";
|
2012-12-08 03:13:32 +01:00
|
|
|
} else if ($this->isGit) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$err = phutil_passthru(
|
|
|
|
'git push %s %s',
|
|
|
|
$this->remote,
|
|
|
|
$this->onto);
|
2012-12-21 23:18:07 +01:00
|
|
|
$cmd = "git push";
|
|
|
|
} else if ($this->isHg) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$err = $repository_api->execPassthru(
|
|
|
|
'push --new-branch -r %s %s',
|
|
|
|
$this->onto,
|
|
|
|
$this->remote);
|
2012-12-21 23:18:07 +01:00
|
|
|
$cmd = "hg push";
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
}
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
|
|
|
if ($err) {
|
2012-12-21 23:18:07 +01:00
|
|
|
echo phutil_console_format("<bg:red>** PUSH FAILED! **</bg>\n");
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"'{$cmd}' failed! Fix the error and push this change manually.");
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 23:32:43 +01:00
|
|
|
$mark_workflow = $this->buildChildWorkflow(
|
2012-04-17 22:51:10 +02:00
|
|
|
'close-revision',
|
2012-02-01 23:32:43 +01:00
|
|
|
array(
|
|
|
|
'--finalize',
|
|
|
|
'--quiet',
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->revision['id'],
|
2012-02-01 23:32:43 +01:00
|
|
|
));
|
|
|
|
$mark_workflow->run();
|
|
|
|
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
echo "\n";
|
|
|
|
}
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
private function cleanupBranch() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
echo "Cleaning up feature branch...\n";
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
if ($this->isGit) {
|
|
|
|
list($ref) = $repository_api->execxLocal(
|
|
|
|
'rev-parse --verify %s',
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->branch);
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$ref = trim($ref);
|
|
|
|
$recovery_command = csprintf(
|
|
|
|
'git checkout -b %s %s',
|
|
|
|
$this->branch,
|
|
|
|
$ref);
|
|
|
|
echo "(Use `{$recovery_command}` if you want it back.)\n";
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'branch -D %s',
|
|
|
|
$this->branch);
|
|
|
|
}
|
2012-12-06 04:31:25 +01:00
|
|
|
// hg branches/bookmarks were closed earlier
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
|
|
|
|
if ($this->getArgument('delete-remote')) {
|
|
|
|
if ($this->isGit) {
|
|
|
|
list($err, $ref) = $repository_api->execManualLocal(
|
|
|
|
'rev-parse --verify %s/%s',
|
2012-12-03 22:03:13 +01:00
|
|
|
$this->remote,
|
|
|
|
$this->branch);
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
|
|
|
|
if ($err) {
|
|
|
|
echo "No remote feature branch to clean up.\n";
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// NOTE: In Git, you delete a remote branch by pushing it with a
|
|
|
|
// colon in front of its name:
|
|
|
|
//
|
|
|
|
// git push <remote> :<branch>
|
|
|
|
|
|
|
|
echo "Cleaning up remote feature branch...\n";
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'push %s :%s',
|
|
|
|
$this->remote,
|
|
|
|
$this->branch);
|
|
|
|
}
|
2012-12-21 23:18:07 +01:00
|
|
|
} else if ($this->isHg) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
// named branches were closed as part of the earlier commit
|
|
|
|
// so only worry about bookmarks
|
|
|
|
if ($repository_api->isBookmark($this->branch)) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'push -B %s %s',
|
|
|
|
$this->branch,
|
|
|
|
$this->remote);
|
|
|
|
}
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
|
|
|
}
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getSupportedRevisionControlSystems() {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
return array('git', 'hg');
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
}
|
|
|
|
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
private function getBranchOrBookmark() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
if ($this->isGit) {
|
|
|
|
$branch = $repository_api->getBranchName();
|
2012-12-21 23:18:07 +01:00
|
|
|
} else if ($this->isHg) {
|
Add hg support for arc land
Summary:
Makes arc land support hg repositories. Both bookmarks and named branches can be landed. For the most part all the arc land options work, but there are a few caveats:
- bookmarks can only be landed on bookmarks
- branches can only be landed on branches
- landing a named branch with --merge creates a commit to close the branch before the merge.
- since mercurial doesn't start with a default master bookmark, landing a bookmark requires specifying --onto or setting arc.land.onto.default
Test Plan:
Tested arc land with all permutations of --merge, --keep-branch on both bookmark branches and named branches. Also tested --hold, --revision, --onto, --remote.
See https://secure.phabricator.com/P619
Also tested git arc land with --merge and --keep-branch.
Reviewers: dschleimer, sid0, epriestley, bos
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4068
2012-12-04 02:59:12 +01:00
|
|
|
$branch = $repository_api->getActiveBookmark();
|
|
|
|
if (!$branch) {
|
|
|
|
$branch = $repository_api->getBranchName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $branch;
|
|
|
|
}
|
2012-12-21 23:18:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore the original branch, e.g. after a successful land or a failed
|
|
|
|
* pull.
|
|
|
|
*/
|
|
|
|
private function restoreBranch() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'checkout %s',
|
|
|
|
$this->oldBranch);
|
|
|
|
echo phutil_console_format(
|
|
|
|
"Switched back to branch **%s**.\n",
|
|
|
|
$this->oldBranch);
|
|
|
|
}
|
|
|
|
|
Add "arc land" as a first-class workflow
Summary:
This is a fancy version of "land.sh" that uses "git merge --squash" and
"arc which" to cover more cases.
Test Plan:
Ran "arc land" against various repository states (no such branch, not
accepted, valid, etc). Things seemed OK. There are basically an infinite number
of states here so it's hard to test exhaustively.
Reviewers: cpiro, btrahan, jungejason, davidreuss
Reviewed By: davidreuss
CC: zeeg, aran, epriestley, davidreuss
Maniphest Tasks: T787, T723
Differential Revision: https://secure.phabricator.com/D1488
2012-01-26 00:10:59 +01:00
|
|
|
}
|