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;
|
2013-01-25 20:52:14 +01:00
|
|
|
private $isHgSvn;
|
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;
|
2013-03-01 23:04:05 +01:00
|
|
|
private $branchType;
|
|
|
|
private $ontoType;
|
2013-03-29 18:08:23 +01:00
|
|
|
private $preview;
|
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
|
|
|
|
2014-03-11 23:21:46 +01:00
|
|
|
public function getRevisionDict() {
|
|
|
|
return $this->revision;
|
|
|
|
}
|
|
|
|
|
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',
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('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(
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('Prepare the change to be pushed, but do not actually '.
|
|
|
|
'push it.'),
|
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
|
|
|
),
|
|
|
|
'keep-branch' => array(
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('Keep the feature branch after pushing changes to the '.
|
|
|
|
'remote (by default, it is deleted).'),
|
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
|
|
|
),
|
|
|
|
'remote' => array(
|
|
|
|
'param' => 'origin',
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('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(
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('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(
|
2014-04-09 21:35:31 +02:00
|
|
|
'hg' => pht('Use the --squash strategy when landing in mercurial.'),
|
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-02-20 21:51:14 +01:00
|
|
|
),
|
2012-03-23 02:20:22 +01:00
|
|
|
'squash' => array(
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('Perform a --squash merge, not a --no-ff merge. If the '.
|
|
|
|
'project is marked as having a mutable history, this '.
|
|
|
|
'is the default behavior.'),
|
2012-03-23 02:20:22 +01:00
|
|
|
'conflicts' => array(
|
|
|
|
'merge' => '--merge and --squash are conflicting merge strategies.',
|
|
|
|
),
|
|
|
|
),
|
2012-05-10 21:14:53 +02:00
|
|
|
'delete-remote' => array(
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('Delete the feature branch in the remote after '.
|
|
|
|
'landing it.'),
|
2012-05-10 21:14:53 +02:00
|
|
|
'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(
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('When updating the feature branch, use rebase '.
|
|
|
|
'instead of merge. This might make things work '.
|
|
|
|
'better in some cases. Set arc.land.update.default '.
|
|
|
|
'to \'rebase\' to make this the default.'),
|
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
|
|
|
'conflicts' => array(
|
2014-04-09 21:35:31 +02:00
|
|
|
'merge' => pht('The --merge strategy does not update the feature '.
|
|
|
|
'branch.'),
|
|
|
|
'update-with-merge' => pht('Cannot be used with '.
|
|
|
|
'--update-with-merge.'),
|
2013-04-14 20:48:22 +02:00
|
|
|
),
|
|
|
|
'supports' => array(
|
|
|
|
'git',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'update-with-merge' => array(
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('When updating the feature branch, use merge instead '.
|
|
|
|
'of rebase. This is the default behavior. Setting '.
|
|
|
|
'arc.land.update.default to \'merge\' can also be '.
|
|
|
|
'used to make this the default.'),
|
2013-04-14 20:48:22 +02:00
|
|
|
'conflicts' => array(
|
2014-04-09 21:35:31 +02:00
|
|
|
'merge' => pht('The --merge strategy does not update the feature '.
|
|
|
|
'branch.'),
|
|
|
|
'update-with-rebase' => pht('Cannot be used with '.
|
|
|
|
'--update-with-rebase.'),
|
2013-04-14 20:48:22 +02:00
|
|
|
),
|
|
|
|
'supports' => array(
|
|
|
|
'git',
|
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
|
|
|
),
|
|
|
|
),
|
2012-03-03 01:47:05 +01:00
|
|
|
'revision' => array(
|
|
|
|
'param' => 'id',
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('Use the message from a specific revision, rather than '.
|
|
|
|
'inferring the revision based on branch content.'),
|
2012-03-03 01:47:05 +01:00
|
|
|
),
|
2013-03-29 18:08:23 +01:00
|
|
|
'preview' => array(
|
2014-04-09 21:35:31 +02:00
|
|
|
'help' => pht('Prints the commits that would be landed. Does not '.
|
|
|
|
'actually modify or land the commits.'),
|
2013-03-29 18:08:23 +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
|
|
|
'*' => '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
|
|
|
|
2013-03-29 18:08:23 +01:00
|
|
|
$this->printPendingCommits();
|
|
|
|
if ($this->preview) {
|
|
|
|
$this->restoreBranch();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-02-07 03:44:55 +01:00
|
|
|
if ($this->oldBranch != $this->onto) {
|
|
|
|
// If we were on some branch A and the user ran "arc land B",
|
|
|
|
// switch back to A.
|
|
|
|
if ($this->keepBranch || $this->oldBranch != $this->branch) {
|
|
|
|
$this->restoreBranch();
|
|
|
|
}
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
|
|
|
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht('Done.'), "\n";
|
2012-12-03 22:03:13 +01:00
|
|
|
|
|
|
|
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(
|
2014-04-09 21:35:31 +02:00
|
|
|
pht("'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');
|
|
|
|
}
|
|
|
|
|
2013-01-25 20:52:14 +01:00
|
|
|
if ($this->isHg) {
|
2013-02-19 22:36:02 +01:00
|
|
|
$this->isHgSvn = $repository_api->isHgSubversionRepo();
|
2013-01-25 20:52:14 +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
|
|
|
$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) {
|
2013-03-01 23:04:05 +01:00
|
|
|
$this->branchType = $this->getBranchType($branch);
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht("Landing current %s '%s'.", $this->branchType, $branch), "\n";
|
2012-04-23 23:09:29 +02:00
|
|
|
$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(
|
2014-04-09 21:35:31 +02:00
|
|
|
pht('Specify exactly one branch or bookmark to land changes from.'));
|
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->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');
|
2013-04-14 20:48:22 +02:00
|
|
|
|
2013-10-19 01:10:06 +02:00
|
|
|
$update_strategy = $this->getConfigFromAnySource(
|
2013-04-14 20:48:22 +02:00
|
|
|
'arc.land.update.default',
|
|
|
|
'merge');
|
|
|
|
$this->shouldUpdateWithRebase = $update_strategy == 'rebase';
|
|
|
|
if ($this->getArgument('update-with-rebase')) {
|
|
|
|
$this->shouldUpdateWithRebase = true;
|
|
|
|
} else if ($this->getArgument('update-with-merge')) {
|
|
|
|
$this->shouldUpdateWithRebase = false;
|
|
|
|
}
|
|
|
|
|
2013-03-29 18:08:23 +01:00
|
|
|
$this->preview = $this->getArgument('preview');
|
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
|
|
|
|
2013-03-01 23:04:05 +01:00
|
|
|
if (!$this->branchType) {
|
|
|
|
$this->branchType = $this->getBranchType($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
|
|
|
$onto_default = $this->isGit ? 'master' : 'default';
|
2012-03-23 02:20:22 +01:00
|
|
|
$onto_default = nonempty(
|
2013-10-19 01:10:06 +02:00
|
|
|
$this->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);
|
2013-03-01 23:04:05 +01:00
|
|
|
$this->ontoType = $this->getBranchType($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
|
|
|
|
|
|
|
$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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
$message = pht(
|
|
|
|
"You can not land a %s onto itself -- you are trying ".
|
|
|
|
"to land '%s' onto '%s'. For more information on how to push ".
|
|
|
|
"changes, see 'Pushing and Closing Revisions' in 'Arcanist User ".
|
|
|
|
"Guide: arc diff' in the documentation.",
|
|
|
|
$this->branchType,
|
|
|
|
$this->branch,
|
|
|
|
$this->onto);
|
2012-12-03 22:03:13 +01:00
|
|
|
if (!$this->isHistoryImmutable()) {
|
2014-04-09 21:35:31 +02:00
|
|
|
$message .= ' ' . pht("You may be able to 'arc amend' instead.");
|
2012-05-23 20:40:20 +02:00
|
|
|
}
|
|
|
|
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) {
|
2013-02-19 22:36:02 +01:00
|
|
|
if (!$repository_api->supportsRebase()) {
|
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
|
|
|
throw new ArcanistUsageException(
|
2014-04-09 21:35:31 +02:00
|
|
|
pht("You must enable the rebase extension to use the --squash ".
|
|
|
|
"strategy."));
|
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
|
|
|
|
2013-03-01 23:04:05 +01:00
|
|
|
if ($this->branchType != $this->ontoType) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"Source %s is a %s but destination %s is a %s. When landing a ".
|
|
|
|
"%s, the destination must also be a %s. Use --onto to specify a %s, ".
|
|
|
|
"or set arc.land.onto.default in .arcconfig.",
|
|
|
|
$this->branch,
|
|
|
|
$this->branchType,
|
|
|
|
$this->onto,
|
|
|
|
$this->ontoType,
|
|
|
|
$this->branchType,
|
|
|
|
$this->branchType,
|
|
|
|
$this->branchType));
|
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($err) = $repository_api->execManualLocal(
|
|
|
|
'rev-parse --verify %s',
|
|
|
|
$this->branch);
|
|
|
|
|
|
|
|
if ($err) {
|
|
|
|
throw new ArcanistUsageException(
|
2014-04-09 21:35:31 +02:00
|
|
|
pht("Branch '%s' does not exist.", $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
|
|
|
}
|
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();
|
2013-02-19 22:36:02 +01:00
|
|
|
if ($this->getBranchOrBookmark() != $this->branch) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'checkout %s',
|
|
|
|
$this->branch);
|
|
|
|
}
|
2012-12-04 01:31:45 +01:00
|
|
|
|
|
|
|
echo phutil_console_format(
|
2014-04-09 21:35:31 +02:00
|
|
|
pht("Switched to %s **%s**. Identifying and merging...",
|
|
|
|
$this->branchType,
|
|
|
|
$this->branch).
|
|
|
|
"\n");
|
2012-12-04 01:31:45 +01:00
|
|
|
}
|
|
|
|
|
2013-03-29 18:08:23 +01:00
|
|
|
private function printPendingCommits() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
|
|
|
|
if ($repository_api instanceof ArcanistGitAPI) {
|
|
|
|
list($out) = $repository_api->execxLocal(
|
2013-04-22 05:54:51 +02:00
|
|
|
'log --oneline %s %s --',
|
2013-03-29 18:08:23 +01:00
|
|
|
$this->branch,
|
2013-04-06 08:17:40 +02:00
|
|
|
'^'.$this->onto);
|
2013-03-29 18:08:23 +01:00
|
|
|
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
|
|
|
$common_ancestor = $repository_api->getCanonicalRevisionName(
|
|
|
|
hgsprintf('ancestor(%s,%s)',
|
|
|
|
$this->onto,
|
|
|
|
$this->branch));
|
|
|
|
|
|
|
|
$branch_range = hgsprintf(
|
|
|
|
'reverse((%s::%s) - %s)',
|
|
|
|
$common_ancestor,
|
|
|
|
$this->branch,
|
|
|
|
$common_ancestor);
|
|
|
|
|
|
|
|
list($out) = $repository_api->execxLocal(
|
|
|
|
'log -r %s --template %s',
|
|
|
|
$branch_range,
|
|
|
|
'{node|short} {desc|firstline}\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!trim($out)) {
|
|
|
|
$this->restoreBranch();
|
|
|
|
throw new ArcanistUsageException(
|
2014-04-09 21:35:31 +02:00
|
|
|
pht("No commits to land from %s.", $this->branch));
|
2013-03-29 18:08:23 +01:00
|
|
|
}
|
|
|
|
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht("The following commit(s) will be landed:\n\n%s", $out), "\n";
|
2013-03-29 18:08:23 +01:00
|
|
|
}
|
|
|
|
|
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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"No such revision '%s'!",
|
|
|
|
"D{$revision_id}"));
|
2012-03-03 01:47:05 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
|
|
|
|
$this->getConduit(),
|
2014-04-07 20:44:14 +02:00
|
|
|
array());
|
2012-03-03 01:47:05 +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 (!count($revisions)) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"arc can not identify which revision exists on %s '%s'. Update the '.
|
|
|
|
'revision with recent changes to synchronize the %s name and hashes, '.
|
|
|
|
'or use 'arc amend' to amend the commit message at HEAD, or use ".
|
|
|
|
"'--revision <id>' to select a revision explicitly.",
|
|
|
|
$this->branchType,
|
|
|
|
$this->branch,
|
|
|
|
$this->branchType));
|
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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
$message = pht(
|
|
|
|
"There are multiple revisions on feature %s '%s' which are not ".
|
|
|
|
"present on '%s':\n\n".
|
|
|
|
"%s\n".
|
|
|
|
"Separate these revisions onto different %s, or use --revision <id>' ".
|
|
|
|
"to use the commit message from <id> and land them all.",
|
|
|
|
$this->branchType,
|
|
|
|
$this->branch,
|
|
|
|
$this->onto,
|
|
|
|
$this->renderRevisionList($revisions),
|
|
|
|
$this->branchType.'s');
|
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'];
|
2013-03-07 17:55:34 +01:00
|
|
|
$rev_auxiliary = idx($this->revision, 'auxiliary', array());
|
2012-12-03 22:03:13 +01:00
|
|
|
|
2014-04-07 20:44:14 +02:00
|
|
|
if ($this->revision['authorPHID'] != $this->getUserPHID()) {
|
|
|
|
$other_author = $this->getConduit()->callMethodSynchronous(
|
|
|
|
'user.query',
|
|
|
|
array(
|
|
|
|
'phids' => array($this->revision['authorPHID']),
|
|
|
|
));
|
|
|
|
$other_author = ipull($other_author, 'userName', 'phid');
|
|
|
|
$other_author = $other_author[$this->revision['authorPHID']];
|
2014-04-09 21:35:31 +02:00
|
|
|
$ok = phutil_console_confirm(pht(
|
|
|
|
"This %s has revision '%s' but you are not the author. Land this ".
|
|
|
|
"revision by %s?",
|
|
|
|
$this->branchType,
|
|
|
|
"D{$rev_id}: {$rev_title}",
|
|
|
|
$other_author));
|
2014-04-07 20:44:14 +02:00
|
|
|
if (!$ok) {
|
|
|
|
throw new ArcanistUserAbortException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:03:13 +01:00
|
|
|
if ($rev_status != ArcanistDifferentialRevisionStatus::ACCEPTED) {
|
2014-04-09 21:35:31 +02:00
|
|
|
$ok = phutil_console_confirm(pht(
|
2014-05-07 18:15:14 +02:00
|
|
|
"Revision '%s' has not been accepted. Continue anyway?",
|
2014-04-09 21:35:31 +02:00
|
|
|
"D{$rev_id}: {$rev_title}"));
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-07 17:55:34 +01:00
|
|
|
if ($rev_auxiliary) {
|
|
|
|
$phids = idx($rev_auxiliary, 'phabricator:depends-on', array());
|
2013-03-08 02:21:37 +01:00
|
|
|
if ($phids) {
|
|
|
|
$dep_on_revs = $this->getConduit()->callMethodSynchronous(
|
|
|
|
'differential.query',
|
|
|
|
array(
|
|
|
|
'phids' => $phids,
|
|
|
|
'status' => 'status-open',
|
|
|
|
));
|
|
|
|
|
|
|
|
$open_dep_revs = array();
|
|
|
|
foreach ($dep_on_revs as $dep_on_rev) {
|
|
|
|
$dep_on_rev_id = $dep_on_rev['id'];
|
|
|
|
$dep_on_rev_title = $dep_on_rev['title'];
|
|
|
|
$dep_on_rev_status = $dep_on_rev['status'];
|
|
|
|
$open_dep_revs[$dep_on_rev_id] = $dep_on_rev_title;
|
2013-03-07 17:55:34 +01:00
|
|
|
}
|
|
|
|
|
2013-03-08 02:21:37 +01:00
|
|
|
if (!empty($open_dep_revs)) {
|
|
|
|
$open_revs = array();
|
|
|
|
foreach ($open_dep_revs as $id => $title) {
|
|
|
|
$open_revs[] = " - D".$id.": ".$title;
|
|
|
|
}
|
|
|
|
$open_revs = implode("\n", $open_revs);
|
|
|
|
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht("Revision '%s' depends on open revisions:\n\n%s",
|
|
|
|
"D{$rev_id}: {$rev_title}",
|
|
|
|
$open_revs);
|
2013-03-08 02:21:37 +01:00
|
|
|
|
2014-04-09 21:35:31 +02:00
|
|
|
$ok = phutil_console_confirm(pht("Continue anyway?"));
|
2013-03-08 02:21:37 +01:00
|
|
|
if (!$ok) {
|
|
|
|
throw new ArcanistUserAbortException();
|
|
|
|
}
|
2013-03-07 17:55:34 +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
|
|
|
$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);
|
|
|
|
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht("Landing revision '%s'...",
|
|
|
|
"D{$rev_id}: {$rev_title}"), "\n";
|
2014-04-18 00:59:54 +02:00
|
|
|
|
|
|
|
$diff_phid = idx($this->revision, 'activeDiffPHID');
|
|
|
|
if ($diff_phid) {
|
|
|
|
$this->checkForBuildables($diff_phid);
|
|
|
|
}
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function pullFromRemote() {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
|
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) {
|
2013-02-19 22:36:02 +01:00
|
|
|
$repository_api->execxLocal('checkout %s', $this->onto);
|
|
|
|
|
2014-04-09 21:35:31 +02:00
|
|
|
echo phutil_console_format(pht(
|
2013-02-19 22:36:02 +01:00
|
|
|
"Switched to branch **%s**. Updating branch...\n",
|
2014-04-09 21:35:31 +02:00
|
|
|
$this->onto));
|
2013-02-19 22:36:02 +01:00
|
|
|
|
2013-01-29 00:54:37 +01:00
|
|
|
try {
|
2013-01-31 02:57:06 +01:00
|
|
|
$repository_api->execxLocal('pull --ff-only --no-stat');
|
2013-01-29 00:54:37 +01:00
|
|
|
} catch (CommandException $ex) {
|
|
|
|
if (!$this->isGitSvn) {
|
|
|
|
throw $ex;
|
|
|
|
}
|
2014-04-09 21:35:31 +02:00
|
|
|
}
|
|
|
|
list($out) = $repository_api->execxLocal(
|
|
|
|
'log %s..%s',
|
|
|
|
$this->ontoRemoteBranch,
|
|
|
|
$this->onto);
|
|
|
|
if (strlen(trim($out))) {
|
|
|
|
$local_ahead_of_remote = true;
|
|
|
|
} else if ($this->isGitSvn) {
|
|
|
|
$repository_api->execxLocal('svn rebase');
|
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
|
|
|
}
|
2013-01-29 00:54:37 +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
|
|
|
} else if ($this->isHg) {
|
2014-04-09 21:35:31 +02:00
|
|
|
echo phutil_console_format(pht(
|
|
|
|
"Updating **%s**...",
|
|
|
|
$this->onto) . "\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
|
|
|
|
Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial. Previously it would often leave the repo in a confusing state
if something failed.
- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.
Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land
In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.
Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.
Reviewers: epriestley, dschleimer, sid0
Reviewed By: epriestley
CC: nh, wez, bos, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 23:06:10 +01:00
|
|
|
try {
|
|
|
|
list($out, $err) = $repository_api->execxLocal('pull');
|
|
|
|
|
|
|
|
$divergedbookmark = $this->onto.'@'.$repository_api->getBranchName();
|
|
|
|
if (strpos($err, $divergedbookmark) !== false) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(phutil_console_format(pht(
|
|
|
|
"Local bookmark **%s** has diverged from the server's **%s** ".
|
|
|
|
"(now labeled **%s**). Please resolve this divergence and run ".
|
|
|
|
"'arc land' again.",
|
|
|
|
$this->onto,
|
|
|
|
$this->onto,
|
|
|
|
$divergedbookmark)));
|
Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial. Previously it would often leave the repo in a confusing state
if something failed.
- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.
Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land
In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.
Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.
Reviewers: epriestley, dschleimer, sid0
Reviewed By: epriestley
CC: nh, wez, bos, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 23:06:10 +01:00
|
|
|
}
|
|
|
|
} 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)) {
|
|
|
|
throw $ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pull succeeded. Now make sure master is not on an outgoing change
|
2013-02-19 22:36:02 +01:00
|
|
|
if ($repository_api->supportsPhases()) {
|
|
|
|
list($out) = $repository_api->execxLocal(
|
2013-08-15 03:00:51 +02:00
|
|
|
'log -r %s --template %s', $this->onto, "{phase}");
|
2013-02-19 22:36:02 +01:00
|
|
|
if ($out != 'public') {
|
|
|
|
$local_ahead_of_remote = true;
|
|
|
|
}
|
2013-01-16 21:15:46 +01:00
|
|
|
} else {
|
2013-02-19 22:36:02 +01:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
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 ($local_ahead_of_remote) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"Local %s '%s' is ahead of remote %s '%s', so landing a feature ".
|
|
|
|
"%s would push additional changes. Push or reset the changes in '%s' ".
|
|
|
|
"before running 'arc land'.",
|
|
|
|
$this->ontoType,
|
|
|
|
$this->onto,
|
|
|
|
$this->ontoType,
|
|
|
|
$this->ontoRemoteBranch,
|
|
|
|
$this->ontoType,
|
|
|
|
$this->onto));
|
2012-12-03 22:03:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
echo phutil_console_format(pht(
|
|
|
|
"Rebasing **%s** onto **%s**",
|
2014-01-28 17:53:50 +01:00
|
|
|
$this->branch,
|
2014-04-09 21:35:31 +02:00
|
|
|
$this->onto)."\n");
|
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
|
|
|
$err = phutil_passthru('git rebase %s', $this->onto);
|
|
|
|
if ($err) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"'git rebase %s' 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.",
|
|
|
|
$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
|
|
|
}
|
|
|
|
} else {
|
2014-04-09 21:35:31 +02:00
|
|
|
echo phutil_console_format(pht(
|
|
|
|
"Merging **%s** into **%s**",
|
2014-01-28 17:53:50 +01:00
|
|
|
$this->branch,
|
2014-04-09 21:35:31 +02:00
|
|
|
$this->onto)."\n");
|
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
|
|
|
$err = phutil_passthru(
|
2013-04-06 18:23:41 +02:00
|
|
|
'git merge --no-stat %s -m %s',
|
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->onto,
|
2014-04-09 21:35:31 +02:00
|
|
|
pht("Automatic merge by 'arc land'"));
|
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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"'git merge %s' failed. ".
|
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
|
|
|
"To continue: resolve the conflicts, commit the changes, then run ".
|
2014-04-09 21:35:31 +02:00
|
|
|
"'arc land' again. To abort: run 'git merge --abort'.",
|
|
|
|
$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
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ($this->isHg) {
|
2013-01-22 23:29:00 +01:00
|
|
|
$onto_tip = $repository_api->getCanonicalRevisionName($this->onto);
|
|
|
|
$common_ancestor = $repository_api->getCanonicalRevisionName(
|
2013-01-29 01:28:14 +01:00
|
|
|
hgsprintf("ancestor(%s, %s)",
|
2013-01-22 23:29:00 +01:00
|
|
|
$this->onto,
|
|
|
|
$this->branch));
|
|
|
|
|
|
|
|
// Only rebase if the local branch is not at the tip of the onto branch.
|
|
|
|
if ($onto_tip != $common_ancestor) {
|
|
|
|
// keep branch here so later we can decide whether to remove it
|
|
|
|
$err = $repository_api->execPassthru(
|
|
|
|
'rebase -d %s --keepbranches',
|
|
|
|
$this->onto);
|
|
|
|
if ($err) {
|
Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial. Previously it would often leave the repo in a confusing state
if something failed.
- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.
Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land
In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.
Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.
Reviewers: epriestley, dschleimer, sid0
Reviewed By: epriestley
CC: nh, wez, bos, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 23:06:10 +01:00
|
|
|
echo phutil_console_format("Aborting rebase\n");
|
|
|
|
$repository_api->execManualLocal(
|
|
|
|
'rebase --abort');
|
|
|
|
$this->restoreBranch();
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"'hg rebase %s' failed and the rebase was aborted. ".
|
|
|
|
"This is most likely due to conflicts. Manually rebase %s onto ".
|
|
|
|
"%s, resolve the conflicts, then run 'arc land' again.",
|
|
|
|
$this->onto,
|
|
|
|
$this->branch,
|
|
|
|
$this->onto));
|
2013-01-22 23:29:00 +01:00
|
|
|
}
|
Add an experimental "--mergeup" flag to use a less volatile merge strategy in "arc land"
Summary:
See chatlog from https://secure.phabricator.com/chatlog/channel/%23phabricator/?at=37257
Basically, the install's developers sometimes use "git merge master" instead of "git rebase master" to pull changes from master into their branch. When we run "git rebase master" at the end, this creates a lot of conflicts.
Instead, optionally run "git merge master". This should be equivalent in our case (where we always rebase) and much better in their case (where they sometimes merge).
We're both going to use it for a bit and see if it creates problems. If it improves the "sometimes-merge" workflow without affecting the "always rebase" workflow, we can make it a default. If it improves theirs but damages ours, we can keep it a flag/option. If it's just terrible, we can figure out something else.
Test Plan:
Ran `arc land --mergeup --trace <feature> --keep-branch --hold`, see P624 for output. Observed merge update strategy and general success.
Also verified the conflict:
$ arc land --mergeup --merge
Usage Exception: Arguments '--mergeup' and '--merge' are mutually exclusive: The --merge strategy does not update the feature branch.
Reviewers: btrahan, vrana, DurhamGoode
Reviewed By: btrahan
CC: aran, keir
Differential Revision: https://secure.phabricator.com/D4080
2012-12-13 23:11:52 +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
|
|
|
}
|
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();
|
|
|
|
|
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) {
|
2013-02-19 22:36:02 +01:00
|
|
|
$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
|
|
|
$repository_api->execxLocal(
|
2013-04-06 18:23:41 +02:00
|
|
|
'merge --no-stat --squash --ff-only %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);
|
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(
|
2013-01-29 01:28:14 +01:00
|
|
|
hgsprintf("first((%s::%s)-%s)",
|
2012-12-06 04:31:25 +01:00
|
|
|
$this->onto,
|
|
|
|
$this->branch,
|
|
|
|
$this->onto));
|
|
|
|
|
2013-01-29 01:28:14 +01:00
|
|
|
$branch_range = hgsprintf(
|
2012-12-06 04:31:25 +01:00
|
|
|
"(%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.
|
Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial. Previously it would often leave the repo in a confusing state
if something failed.
- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.
Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land
In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.
Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.
Reviewers: epriestley, dschleimer, sid0
Reviewed By: epriestley
CC: nh, wez, bos, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 23:06:10 +01:00
|
|
|
$err = $repository_api->execPassthru(
|
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);
|
|
|
|
|
Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial. Previously it would often leave the repo in a confusing state
if something failed.
- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.
Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land
In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.
Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.
Reviewers: epriestley, dschleimer, sid0
Reviewed By: epriestley
CC: nh, wez, bos, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 23:06:10 +01:00
|
|
|
if ($err) {
|
|
|
|
$repository_api->execManualLocal(
|
|
|
|
'rebase --abort');
|
|
|
|
$this->restoreBranch();
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"Squashing the commits under {$this->branch} failed. ".
|
|
|
|
"Manually squash your commits and run 'arc land' again.");
|
|
|
|
}
|
|
|
|
|
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(
|
2013-08-15 03:00:51 +02:00
|
|
|
"log -r %s --template %s",
|
|
|
|
hgsprintf("children(%s)", $this->branch),
|
|
|
|
'{node}\n');
|
2012-12-06 04:31:25 +01:00
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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}
|
2013-01-29 01:28:14 +01:00
|
|
|
$alt_branch_revset = hgsprintf(
|
|
|
|
'roots(descendants(%s)-descendants(%s)-%R)',
|
2012-12-06 04:31:25 +01:00
|
|
|
$branch_root,
|
|
|
|
$this->branch,
|
|
|
|
$branch_range);
|
|
|
|
list($alt_branches) = $repository_api->execxLocal(
|
2013-08-15 03:00:51 +02:00
|
|
|
"log --template %s -r %s",
|
|
|
|
'{node}\n',
|
2012-12-06 04:31:25 +01:00
|
|
|
$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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
$input = phutil_console_prompt(pht(
|
|
|
|
"%s '%s' has %s %s(s) forking off of it that would be deleted ".
|
2013-03-01 23:04:05 +01:00
|
|
|
"during a squash. Would you like to keep a non-squashed copy, rebase ".
|
2014-04-09 21:35:31 +02:00
|
|
|
"them on top of '%s', or abort and deal with them yourself? ".
|
|
|
|
"(k)eep, (r)ebase, (a)bort:",
|
|
|
|
ucfirst($this->branchType),
|
|
|
|
$this->branch,
|
|
|
|
$alt_count,
|
|
|
|
$this->branchType,
|
|
|
|
$this->branch));
|
2012-12-06 04:31:25 +01:00
|
|
|
|
|
|
|
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);
|
2014-04-09 21:35:31 +02:00
|
|
|
echo
|
|
|
|
"\n",
|
|
|
|
pht("Remove the %s starting at these revisions and ".
|
|
|
|
"run arc land again:\n%s",
|
|
|
|
$this->branchType.'s',
|
|
|
|
$branch_string),
|
|
|
|
"\n\n";
|
2012-12-06 04:31:25 +01:00
|
|
|
throw new ArcanistUserAbortException();
|
|
|
|
} else {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(
|
|
|
|
pht("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(
|
2013-04-06 18:23:41 +02:00
|
|
|
'git merge --no-stat --no-ff --no-commit %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-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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
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
|
|
|
"'git merge' failed. Your working copy has been left in a partially ".
|
|
|
|
"merged state. You can: abort with 'git merge --abort'; or follow ".
|
2014-04-09 21:35:31 +02:00
|
|
|
"the instructions to complete the merge."));
|
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
|
|
|
}
|
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.
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"--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
|
|
|
|
2013-09-05 21:45:59 +02:00
|
|
|
// these commands can fail legitimately (e.g. commit hooks)
|
|
|
|
try {
|
|
|
|
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
|
|
|
$repository_api->execxLocal(
|
2013-09-05 21:45:59 +02:00
|
|
|
'commit -F %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);
|
2013-09-05 21:45:59 +02:00
|
|
|
} else if ($this->isHg) {
|
|
|
|
// hg rebase produces a commit earlier as part of rebase
|
|
|
|
if (!$this->useSquash) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'commit --logfile %s',
|
|
|
|
$this->messageFile);
|
|
|
|
}
|
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
|
|
|
}
|
2013-09-05 21:45:59 +02:00
|
|
|
// We dispatch this event so we can run checks on the merged revision,
|
|
|
|
// right before it gets pushed out. It's easier to do this in arc land
|
|
|
|
// than to try to hook into git/hg.
|
2013-03-09 03:32:36 +01:00
|
|
|
$this->dispatchEvent(
|
|
|
|
ArcanistEventType::TYPE_LAND_WILLPUSHREVISION,
|
|
|
|
array());
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
$this->executeCleanupAfterFailedPush();
|
|
|
|
throw $ex;
|
|
|
|
}
|
|
|
|
|
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')) {
|
2014-04-09 21:35:31 +02:00
|
|
|
echo phutil_console_format(pht(
|
|
|
|
"Holding change in **%s**: it has NOT been pushed yet.",
|
|
|
|
$this->onto). "\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
|
|
|
} else {
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht('Pushing change...'), "\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
|
|
|
|
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";
|
2013-01-25 20:52:14 +01:00
|
|
|
} else if ($this->isHgSvn) {
|
|
|
|
// hg-svn doesn't support 'push -r', so we do a normal push
|
|
|
|
// which hg-svn modifies to only push the current branch and
|
|
|
|
// ancestors.
|
|
|
|
$err = $repository_api->execPassthru(
|
|
|
|
'push %s',
|
|
|
|
$this->remote);
|
|
|
|
$cmd = "hg push";
|
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
|
|
|
$err = $repository_api->execPassthru(
|
2013-01-25 20:52:14 +01:00
|
|
|
'push -r %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->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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
$failed_str = pht('PUSH FAILED!');
|
|
|
|
echo phutil_console_format("<bg:red>** %s **</bg>\n", $failed_str);
|
2013-03-09 03:32:36 +01:00
|
|
|
$this->executeCleanupAfterFailedPush();
|
2013-01-29 02:05:09 +01:00
|
|
|
if ($this->isGit) {
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"'%s' failed! Fix the error and run 'arc land' again.",
|
|
|
|
$cmd));
|
2013-01-29 02:05:09 +01:00
|
|
|
}
|
2014-04-09 21:35:31 +02:00
|
|
|
throw new ArcanistUsageException(pht(
|
|
|
|
"'%s' failed! Fix the error and push this change manually.",
|
|
|
|
$cmd));
|
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
|
|
|
}
|
|
|
|
|
2014-04-16 22:01:14 +02:00
|
|
|
// If we know which repository we're in, try to tell Phabricator that we
|
|
|
|
// pushed commits to it so it can update. This hint can help pull updates
|
|
|
|
// more quickly, especially in rarely-used repositories.
|
|
|
|
if ($this->getRepositoryCallsign()) {
|
|
|
|
try {
|
|
|
|
$this->getConduit()->callMethodSynchronous(
|
|
|
|
'diffusion.looksoon',
|
|
|
|
array(
|
|
|
|
'callsign' => $this->getRepositoryCallsign(),
|
|
|
|
));
|
|
|
|
} catch (ConduitClientException $ex) {
|
|
|
|
// If we hit an exception, just ignore it. Likely, we are running
|
|
|
|
// against a Phabricator which is too old to support this method.
|
|
|
|
// Since this hint is purely advisory, it doesn't matter if it has
|
|
|
|
// no effect.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2013-03-09 03:32:36 +01:00
|
|
|
private function executeCleanupAfterFailedPush() {
|
Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial. Previously it would often leave the repo in a confusing state
if something failed.
- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.
Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land
In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.
Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.
Reviewers: epriestley, dschleimer, sid0
Reviewed By: epriestley
CC: nh, wez, bos, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 23:06:10 +01:00
|
|
|
$repository_api = $this->getRepositoryAPI();
|
2013-03-09 03:32:36 +01:00
|
|
|
if ($this->isGit) {
|
|
|
|
$repository_api->execxLocal('reset --hard HEAD^');
|
|
|
|
$this->restoreBranch();
|
Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial. Previously it would often leave the repo in a confusing state
if something failed.
- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.
Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land
In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.
Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.
Reviewers: epriestley, dschleimer, sid0
Reviewed By: epriestley
CC: nh, wez, bos, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 23:06:10 +01:00
|
|
|
} else if ($this->isHg) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'--config extensions.mq= strip %s',
|
|
|
|
$this->onto);
|
|
|
|
$this->restoreBranch();
|
2013-03-09 03:32:36 +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
|
|
|
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht('Cleaning up feature %s...', $this->branchType), "\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);
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht('(Use `%s` if you want it back.)', $recovery_command), "\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
|
|
|
$repository_api->execxLocal(
|
|
|
|
'branch -D %s',
|
|
|
|
$this->branch);
|
Make arc land for hg more robust to failures
Summary:
Adds error handling for several kinds of failure in arc land for
mercurial. Previously it would often leave the repo in a confusing state
if something failed.
- Aborts the land if pull brings in a diverged 'onto' branch.
- Aborts the rebase if there is a conflict. This leaves the repo exactly as
it was before, so the user is not left with a half finished rebase.
- Don't delete the original non-squashed branch until the push succeeds.
- If the push fails, strip the temporary squashed commit. This leaves the
'onto' branch back on the latest commit from the server, and leaves the users
original nonsquashed branch around.
- Always leave the user back on their original branch after an error.
Test Plan:
Ran arc land:
- with pull causing a diverged 'onto' bookmark
- with the 'onto' bookmark already diverged
- with the rebase causing conflicts
- with a push that failed due to a commit hook
- with a successful land
- with a successful collapse and land
In all failure cases the repo was left exactly as it was before arc land,
except for the push-failed case, where the only change was that the branch
was correctly on top of the destination branch due to a successful rebase.
Used bookmark name "foo bar-gah" to test that crazy bookmark names still work.
Reviewers: epriestley, dschleimer, sid0
Reviewed By: epriestley
CC: nh, wez, bos, aran, Korvin
Differential Revision: https://secure.phabricator.com/D5394
2013-03-20 23:06:10 +01:00
|
|
|
} else if ($this->isHg) {
|
|
|
|
$common_ancestor = $repository_api->getCanonicalRevisionName(
|
|
|
|
hgsprintf("ancestor(%s,%s)",
|
|
|
|
$this->onto,
|
|
|
|
$this->branch));
|
|
|
|
|
|
|
|
$branch_root = $repository_api->getCanonicalRevisionName(
|
|
|
|
hgsprintf("first((%s::%s)-%s)",
|
|
|
|
$common_ancestor,
|
|
|
|
$this->branch,
|
|
|
|
$common_ancestor));
|
|
|
|
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'--config extensions.mq= strip -r %s',
|
|
|
|
$branch_root);
|
|
|
|
|
|
|
|
if ($repository_api->isBookmark($this->branch)) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'bookmark -d %s',
|
|
|
|
$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 ($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) {
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht('No remote feature %s to clean up.',
|
|
|
|
$this->branchType), "\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
|
|
|
} else {
|
|
|
|
|
|
|
|
// NOTE: In Git, you delete a remote branch by pushing it with a
|
|
|
|
// colon in front of its name:
|
|
|
|
//
|
|
|
|
// git push <remote> :<branch>
|
|
|
|
|
2014-04-09 21:35:31 +02:00
|
|
|
echo pht('Cleaning up remote feature %s...', $this->branchType), "\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
|
|
|
$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
|
|
|
|
2013-03-01 23:04:05 +01:00
|
|
|
private function getBranchType($branch) {
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
if ($this->isHg && $repository_api->isBookmark($branch)) {
|
|
|
|
return "bookmark";
|
|
|
|
}
|
|
|
|
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);
|
2013-09-05 21:45:59 +02:00
|
|
|
if ($this->isGit) {
|
|
|
|
$repository_api->execxLocal(
|
|
|
|
'submodule update --init --recursive');
|
|
|
|
}
|
2012-12-21 23:18:07 +01:00
|
|
|
echo phutil_console_format(
|
2013-03-01 23:04:05 +01:00
|
|
|
"Switched back to {$this->branchType} **%s**.\n",
|
2012-12-21 23:18:07 +01:00
|
|
|
$this->oldBranch);
|
|
|
|
}
|
|
|
|
|
2014-04-18 00:59:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a diff has a running or failed buildable, and prompt the user
|
|
|
|
* before landing if it does.
|
|
|
|
*/
|
|
|
|
private function checkForBuildables($diff_phid) {
|
|
|
|
// NOTE: Since Harbormaster is still beta and this stuff all got added
|
|
|
|
// recently, just bail if we can't find a buildable. This is just an
|
|
|
|
// advisory check intended to prevent human error.
|
|
|
|
|
|
|
|
try {
|
|
|
|
$buildables = $this->getConduit()->callMethodSynchronous(
|
|
|
|
'harbormaster.querybuildables',
|
|
|
|
array(
|
|
|
|
'buildablePHIDs' => array($diff_phid),
|
|
|
|
'manualBuildables' => false,
|
|
|
|
));
|
|
|
|
} catch (ConduitClientException $ex) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$buildables['data']) {
|
|
|
|
// If there's no corresponding buildable, we're done.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$console = PhutilConsole::getConsole();
|
|
|
|
|
|
|
|
$buildable = head($buildables['data']);
|
|
|
|
|
|
|
|
if ($buildable['buildableStatus'] == 'passed') {
|
|
|
|
$console->writeOut(
|
|
|
|
"**<bg:green> %s </bg>** %s\n",
|
|
|
|
pht('BUILDS PASSED'),
|
|
|
|
pht(
|
|
|
|
'Harbormaster builds for the active diff completed successfully.'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($buildable['buildableStatus']) {
|
|
|
|
case 'building':
|
|
|
|
$message = pht(
|
|
|
|
'Harbormaster is still building the active diff for this revision:');
|
|
|
|
$prompt = pht('Land revision anyway, despite ongoing build?');
|
|
|
|
break;
|
|
|
|
case 'failed':
|
|
|
|
$message = pht(
|
|
|
|
'Harbormaster failed to build the active diff for this revision. '.
|
|
|
|
'Build failures:');
|
|
|
|
$prompt = pht('Land revision anyway, despite build failures?');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// If we don't recognize the status, just bail.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$builds = $this->getConduit()->callMethodSynchronous(
|
|
|
|
'harbormaster.querybuilds',
|
|
|
|
array(
|
|
|
|
'buildablePHIDs' => array($buildable['phid']),
|
|
|
|
));
|
|
|
|
|
|
|
|
$console->writeOut($message."\n\n");
|
|
|
|
foreach ($builds['data'] as $build) {
|
|
|
|
switch ($build['buildStatus']) {
|
|
|
|
case 'failed':
|
|
|
|
$color = 'red';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$color = 'yellow';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$console->writeOut(
|
|
|
|
" **<bg:".$color."> %s </bg>** %s: %s\n",
|
|
|
|
phutil_utf8_strtoupper($build['buildStatusName']),
|
|
|
|
pht('Build %d', $build['id']),
|
|
|
|
$build['name']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$console->writeOut(
|
|
|
|
"\n%s\n\n **%s**: __%s__",
|
|
|
|
pht('You can review build details here:'),
|
|
|
|
pht('Harbormaster URI'),
|
|
|
|
$buildable['uri']);
|
|
|
|
|
|
|
|
if (!$console->confirm($prompt)) {
|
|
|
|
throw new ArcanistUserAbortException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|