mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Add arcconfig setting for default arc feature start
Summary: Adds arc.feature.start.default arcconfig setting to specify a default value for 'start' in 'arc feature name start'. This lets users always branch from origin/master (or whatever the main branch is). Also cleaned up the 'feature' help text a little. The stuff about sorting and closed/abandoned revisions is explained via the options list already. Test Plan: Ran arc feature with/without a start and with/without the config setting set. Reviewers: epriestley, vrana Reviewed By: epriestley CC: bos, sid0, dschleimer, aran, Korvin Differential Revision: https://secure.phabricator.com/D5184
This commit is contained in:
parent
263cf9a95f
commit
64bbcda431
1 changed files with 28 additions and 20 deletions
|
@ -25,18 +25,16 @@ EOTEXT
|
|||
public function getCommandHelp() {
|
||||
return phutil_console_format(<<<EOTEXT
|
||||
Supports: git, hg
|
||||
A wrapper on 'git branch' or 'hg bookmark'. It pulls data from
|
||||
Differential and displays the revision status next to the branch name.
|
||||
A wrapper on 'git branch' or 'hg bookmark'.
|
||||
|
||||
By default, branches are sorted chronologically. You can sort them
|
||||
by status instead with __--by-status__.
|
||||
|
||||
By default, branches that are "Closed" or "Abandoned" are not
|
||||
displayed. You can show them with __--view-all__.
|
||||
Without __name__, it lists the available branches and their revision
|
||||
status.
|
||||
|
||||
With __name__, it creates or checks out a branch. If the branch
|
||||
__name__ doesn't exist and is in format D123 then the branch of
|
||||
revision D123 is checked out.
|
||||
revision D123 is checked out. Use __start__ to specify where the new
|
||||
branch will start. Using 'arc.land.onto.default' to set the default
|
||||
land location will also set the default feature start location.
|
||||
EOTEXT
|
||||
);
|
||||
}
|
||||
|
@ -107,16 +105,24 @@ EOTEXT
|
|||
|
||||
$err = 1;
|
||||
|
||||
$name = $names[0];
|
||||
if (isset($names[1])) {
|
||||
$start = $names[1];
|
||||
} else {
|
||||
$start = $this->getWorkingCopy()->getConfigFromAnySource(
|
||||
'arc.land.onto.default');
|
||||
}
|
||||
|
||||
$branches = $api->getAllBranches();
|
||||
if (in_array(reset($names), ipull($branches, 'name'))) {
|
||||
if (in_array($name, ipull($branches, 'name'))) {
|
||||
list($err, $stdout, $stderr) = $api->execManualLocal(
|
||||
$command,
|
||||
reset($names));
|
||||
$name);
|
||||
}
|
||||
|
||||
if ($err) {
|
||||
$match = null;
|
||||
if (preg_match('/^D(\d+)$/', reset($names), $match)) {
|
||||
if (preg_match('/^D(\d+)$/', $name, $match)) {
|
||||
try {
|
||||
$diff = $this->getConduit()->callMethodSynchronous(
|
||||
'differential.getdiff',
|
||||
|
@ -125,10 +131,10 @@ EOTEXT
|
|||
));
|
||||
|
||||
if ($diff['branch'] != '') {
|
||||
$names[0] = $diff['branch'];
|
||||
$name = $diff['branch'];
|
||||
list($err, $stdout, $stderr) = $api->execManualLocal(
|
||||
$command,
|
||||
reset($names));
|
||||
$name);
|
||||
}
|
||||
} catch (ConduitException $ex) {
|
||||
}
|
||||
|
@ -138,22 +144,24 @@ EOTEXT
|
|||
if ($err) {
|
||||
if ($api instanceof ArcanistMercurialAPI) {
|
||||
$rev = '';
|
||||
if (isset($names[1])) {
|
||||
$rev = csprintf('-r %s', $names[1]);
|
||||
if ($start) {
|
||||
$rev = csprintf('-r %s', $start);
|
||||
}
|
||||
|
||||
$exec = $api->execManualLocal(
|
||||
'bookmark %C %s',
|
||||
$rev,
|
||||
$names[0]);
|
||||
$name);
|
||||
|
||||
if (!$exec[0] && isset($names[1])) {
|
||||
$api->execxLocal('update %s', $names[0]);
|
||||
if (!$exec[0] && $start) {
|
||||
$api->execxLocal('update %s', $name);
|
||||
}
|
||||
} else {
|
||||
$startarg = $start ? csprintf('%s', $start) : '';
|
||||
$exec = $api->execManualLocal(
|
||||
'checkout --track -b %Ls',
|
||||
$names);
|
||||
'checkout --track -b %s %C',
|
||||
$name,
|
||||
$startarg);
|
||||
}
|
||||
|
||||
list($err, $stdout, $stderr) = $exec;
|
||||
|
|
Loading…
Reference in a new issue