1
0
Fork 0
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:
durham 2013-03-05 12:48:53 -08:00
parent 263cf9a95f
commit 64bbcda431

View file

@ -25,18 +25,16 @@ EOTEXT
public function getCommandHelp() { public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT return phutil_console_format(<<<EOTEXT
Supports: git, hg Supports: git, hg
A wrapper on 'git branch' or 'hg bookmark'. It pulls data from A wrapper on 'git branch' or 'hg bookmark'.
Differential and displays the revision status next to the branch name.
By default, branches are sorted chronologically. You can sort them Without __name__, it lists the available branches and their revision
by status instead with __--by-status__. status.
By default, branches that are "Closed" or "Abandoned" are not
displayed. You can show them with __--view-all__.
With __name__, it creates or checks out a branch. If the branch 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 __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 EOTEXT
); );
} }
@ -107,16 +105,24 @@ EOTEXT
$err = 1; $err = 1;
$name = $names[0];
if (isset($names[1])) {
$start = $names[1];
} else {
$start = $this->getWorkingCopy()->getConfigFromAnySource(
'arc.land.onto.default');
}
$branches = $api->getAllBranches(); $branches = $api->getAllBranches();
if (in_array(reset($names), ipull($branches, 'name'))) { if (in_array($name, ipull($branches, 'name'))) {
list($err, $stdout, $stderr) = $api->execManualLocal( list($err, $stdout, $stderr) = $api->execManualLocal(
$command, $command,
reset($names)); $name);
} }
if ($err) { if ($err) {
$match = null; $match = null;
if (preg_match('/^D(\d+)$/', reset($names), $match)) { if (preg_match('/^D(\d+)$/', $name, $match)) {
try { try {
$diff = $this->getConduit()->callMethodSynchronous( $diff = $this->getConduit()->callMethodSynchronous(
'differential.getdiff', 'differential.getdiff',
@ -125,10 +131,10 @@ EOTEXT
)); ));
if ($diff['branch'] != '') { if ($diff['branch'] != '') {
$names[0] = $diff['branch']; $name = $diff['branch'];
list($err, $stdout, $stderr) = $api->execManualLocal( list($err, $stdout, $stderr) = $api->execManualLocal(
$command, $command,
reset($names)); $name);
} }
} catch (ConduitException $ex) { } catch (ConduitException $ex) {
} }
@ -138,22 +144,24 @@ EOTEXT
if ($err) { if ($err) {
if ($api instanceof ArcanistMercurialAPI) { if ($api instanceof ArcanistMercurialAPI) {
$rev = ''; $rev = '';
if (isset($names[1])) { if ($start) {
$rev = csprintf('-r %s', $names[1]); $rev = csprintf('-r %s', $start);
} }
$exec = $api->execManualLocal( $exec = $api->execManualLocal(
'bookmark %C %s', 'bookmark %C %s',
$rev, $rev,
$names[0]); $name);
if (!$exec[0] && isset($names[1])) { if (!$exec[0] && $start) {
$api->execxLocal('update %s', $names[0]); $api->execxLocal('update %s', $name);
} }
} else { } else {
$startarg = $start ? csprintf('%s', $start) : '';
$exec = $api->execManualLocal( $exec = $api->execManualLocal(
'checkout --track -b %Ls', 'checkout --track -b %s %C',
$names); $name,
$startarg);
} }
list($err, $stdout, $stderr) = $exec; list($err, $stdout, $stderr) = $exec;