mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-28 17:52:42 +01:00
Trivially update "arc branch/feature" and "arc browse" for Toolsets
Summary: Ref T11968. Ref T13490. These are the workflows which currently use the intermediate-level hardpoint code (which made hardpoints formal, but didn't do the yield stuff). Move toward updating them by doing some basic bookkeeping, with a few compatibility adjustments to the parent Workflow class. Test Plan: Ran "arc branch" and "arc browse" with various arguments. Maniphest Tasks: T13490, T11968 Differential Revision: https://secure.phabricator.com/D21074
This commit is contained in:
parent
f56c6bde2b
commit
391c164313
4 changed files with 120 additions and 114 deletions
|
@ -1019,7 +1019,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistBrowseRevisionURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader',
|
'ArcanistBrowseRevisionURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader',
|
||||||
'ArcanistBrowseURIHardpointLoader' => 'ArcanistHardpointLoader',
|
'ArcanistBrowseURIHardpointLoader' => 'ArcanistHardpointLoader',
|
||||||
'ArcanistBrowseURIRef' => 'ArcanistRef',
|
'ArcanistBrowseURIRef' => 'ArcanistRef',
|
||||||
'ArcanistBrowseWorkflow' => 'ArcanistWorkflow',
|
'ArcanistBrowseWorkflow' => 'ArcanistArcWorkflow',
|
||||||
'ArcanistBuildPlanRef' => 'Phobject',
|
'ArcanistBuildPlanRef' => 'Phobject',
|
||||||
'ArcanistBuildRef' => 'Phobject',
|
'ArcanistBuildRef' => 'Phobject',
|
||||||
'ArcanistBundle' => 'Phobject',
|
'ArcanistBundle' => 'Phobject',
|
||||||
|
@ -1137,7 +1137,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistExternalLinterTestCase' => 'ArcanistLinterTestCase',
|
'ArcanistExternalLinterTestCase' => 'ArcanistLinterTestCase',
|
||||||
'ArcanistExtractUseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistExtractUseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistExtractUseXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
'ArcanistExtractUseXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||||
'ArcanistFeatureWorkflow' => 'ArcanistWorkflow',
|
'ArcanistFeatureWorkflow' => 'ArcanistArcWorkflow',
|
||||||
'ArcanistFileConfigurationSource' => 'ArcanistFilesystemConfigurationSource',
|
'ArcanistFileConfigurationSource' => 'ArcanistFilesystemConfigurationSource',
|
||||||
'ArcanistFileDataRef' => 'Phobject',
|
'ArcanistFileDataRef' => 'Phobject',
|
||||||
'ArcanistFileUploader' => 'Phobject',
|
'ArcanistFileUploader' => 'Phobject',
|
||||||
|
|
|
@ -3,70 +3,62 @@
|
||||||
/**
|
/**
|
||||||
* Browse files or objects in the Phabricator web interface.
|
* Browse files or objects in the Phabricator web interface.
|
||||||
*/
|
*/
|
||||||
final class ArcanistBrowseWorkflow extends ArcanistWorkflow {
|
final class ArcanistBrowseWorkflow
|
||||||
|
extends ArcanistArcWorkflow {
|
||||||
|
|
||||||
public function getWorkflowName() {
|
public function getWorkflowName() {
|
||||||
return 'browse';
|
return 'browse';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandSynopses() {
|
public function getWorkflowInformation() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
$help = pht(<<<EOTEXT
|
||||||
**browse** [__options__] __path__ ...
|
Open a file or object (like a task or revision) in a local web browser.
|
||||||
**browse** [__options__] __object__ ...
|
|
||||||
|
$ arc browse README # Open a file in Diffusion.
|
||||||
|
$ arc browse T123 # View a task.
|
||||||
|
$ arc browse HEAD # View a symbolic commit.
|
||||||
|
|
||||||
|
To choose a browser binary to invoke, use:
|
||||||
|
|
||||||
|
$ arc set-config browser __browser-binary__
|
||||||
|
|
||||||
|
If no browser is set, the command will try to guess which browser to use.
|
||||||
EOTEXT
|
EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $this->newWorkflowInformation()
|
||||||
|
->setSynopsis(pht('Open a file or object in a local web browser.'))
|
||||||
|
->addExample('**browse** [options] -- __target__ ...')
|
||||||
|
->addExample('**browse** -- __file-name__')
|
||||||
|
->addExample('**browse** -- __object-name__')
|
||||||
|
->setHelp($help);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getWorkflowArguments() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
|
||||||
Supports: git, hg, svn
|
|
||||||
Open a file or object (like a task or revision) in your web browser.
|
|
||||||
|
|
||||||
$ arc browse README # Open a file in Diffusion.
|
|
||||||
$ arc browse T123 # View a task.
|
|
||||||
$ arc browse HEAD # View a symbolic commit.
|
|
||||||
|
|
||||||
Set the 'browser' value using 'arc set-config' to select a browser. If
|
|
||||||
no browser is set, the command will try to guess which browser to use.
|
|
||||||
EOTEXT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getArguments() {
|
|
||||||
return array(
|
return array(
|
||||||
'branch' => array(
|
$this->newWorkflowArgument('branch')
|
||||||
'param' => 'branch_name',
|
->setParameter('branch-name')
|
||||||
'help' => pht(
|
->setHelp(
|
||||||
'Default branch name to view on server. Defaults to "%s".',
|
pht(
|
||||||
'master'),
|
'Default branch name to view on server. Defaults to "%s".',
|
||||||
),
|
'master')),
|
||||||
'types' => array(
|
$this->newWorkflowArgument('types')
|
||||||
'param' => 'types',
|
->setParameter('type-list')
|
||||||
'aliases' => array('type'),
|
->setHelp(
|
||||||
'help' => pht(
|
pht(
|
||||||
'Parse arguments with particular types.'),
|
'Force targets to be interpreted as naming particular types of '.
|
||||||
),
|
'resources.')),
|
||||||
'force' => array(
|
$this->newWorkflowArgument('force')
|
||||||
'help' => pht(
|
->setHelp(
|
||||||
'(DEPRECATED) Obsolete, use "--types path" instead.'),
|
pht(
|
||||||
),
|
'(DEPRECATED) Obsolete, use "--types path" instead.')),
|
||||||
'*' => 'targets',
|
$this->newWorkflowArgument('targets')
|
||||||
|
->setIsPathArgument(true)
|
||||||
|
->setWildcard(true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function desiresWorkingCopy() {
|
public function runWorkflow() {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function desiresRepositoryAPI() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run() {
|
|
||||||
$conduit = $this->getConduitEngine();
|
|
||||||
|
|
||||||
$console = PhutilConsole::getConsole();
|
|
||||||
|
|
||||||
$targets = $this->getArgument('targets');
|
$targets = $this->getArgument('targets');
|
||||||
$targets = array_fuse($targets);
|
$targets = array_fuse($targets);
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
class ArcanistFeatureWorkflow
|
||||||
* Displays user's Git branches or Mercurial bookmarks.
|
extends ArcanistArcWorkflow {
|
||||||
*
|
|
||||||
* @concrete-extensible
|
|
||||||
*/
|
|
||||||
class ArcanistFeatureWorkflow extends ArcanistWorkflow {
|
|
||||||
|
|
||||||
private $branches;
|
private $branches;
|
||||||
|
|
||||||
|
@ -13,62 +9,51 @@ class ArcanistFeatureWorkflow extends ArcanistWorkflow {
|
||||||
return 'feature';
|
return 'feature';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandSynopses() {
|
public function getWorkflowArguments() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
|
||||||
**feature** [__options__]
|
|
||||||
**feature** __name__ [__start__]
|
|
||||||
EOTEXT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCommandHelp() {
|
|
||||||
return phutil_console_format(<<<EOTEXT
|
|
||||||
Supports: git, hg
|
|
||||||
A wrapper on 'git branch' or 'hg bookmark'.
|
|
||||||
|
|
||||||
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. Use __start__ to specify where the new
|
|
||||||
branch will start. Use 'arc.feature.start.default' to set the default
|
|
||||||
feature start location.
|
|
||||||
EOTEXT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function requiresRepositoryAPI() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getArguments() {
|
|
||||||
return array(
|
return array(
|
||||||
'view-all' => array(
|
$this->newWorkflowArgument('view-all')
|
||||||
'help' => pht('Include closed and abandoned revisions.'),
|
->setHelp(pht('Include closed and abandoned revisions.')),
|
||||||
),
|
$this->newWorkflowArgument('by-status')
|
||||||
'by-status' => array(
|
->setParameter('status')
|
||||||
'help' => pht('Sort branches by status instead of time.'),
|
->setHelp(pht('Sort branches by status instead of time.')),
|
||||||
),
|
$this->newWorkflowArgument('output')
|
||||||
'output' => array(
|
->setParameter('format')
|
||||||
'param' => 'format',
|
->setHelp(
|
||||||
'support' => array(
|
pht(
|
||||||
'json',
|
'With "json", show features in machine-readable JSON format.')),
|
||||||
),
|
$this->newWorkflowArgument('branch')
|
||||||
'help' => pht(
|
->setWildcard(true),
|
||||||
"With '%s', show features in machine-readable JSON format.",
|
|
||||||
'json'),
|
|
||||||
),
|
|
||||||
'*' => 'branch',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportedRevisionControlSystems() {
|
public function getWorkflowInformation() {
|
||||||
return array('git', 'hg');
|
return $this->newWorkflowInformation()
|
||||||
|
->setSynopsis(pht('Wrapper on "git branch" or "hg bookmark".'))
|
||||||
|
->addExample(pht('**feature** [__options__]'))
|
||||||
|
->addExample(pht('**feature** __name__ [__start__]'))
|
||||||
|
->setHelp(
|
||||||
|
pht(<<<EOHELP
|
||||||
|
A wrapper on 'git branch' or 'hg bookmark'.
|
||||||
|
|
||||||
|
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. Use __start__ to specify where the new branch will start. Use
|
||||||
|
'arc.feature.start.default' to set the default feature start location.
|
||||||
|
EOHELP
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function runWorkflow() {
|
||||||
|
$working_copy = $this->getWorkingCopy();
|
||||||
|
|
||||||
$repository_api = $this->getRepositoryAPI();
|
$repository_api = $this->getRepositoryAPI();
|
||||||
|
if (!$repository_api) {
|
||||||
|
throw new PhutilArgumentUsageException(
|
||||||
|
pht(
|
||||||
|
'This command must be run in a Git or Mercurial working copy.'));
|
||||||
|
}
|
||||||
|
|
||||||
$names = $this->getArgument('branch');
|
$names = $this->getArgument('branch');
|
||||||
if ($names) {
|
if ($names) {
|
||||||
|
|
|
@ -336,6 +336,16 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getConfigFromAnySource($key) {
|
final public function getConfigFromAnySource($key) {
|
||||||
|
$source_list = $this->getConfigurationSourceList();
|
||||||
|
if ($source_list) {
|
||||||
|
$value_list = $source_list->getStorageValueList($key);
|
||||||
|
if ($value_list) {
|
||||||
|
return last($value_list)->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->configurationManager->getConfigFromAnySource($key);
|
return $this->configurationManager->getConfigFromAnySource($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -884,6 +894,14 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getWorkingCopy() {
|
final public function getWorkingCopy() {
|
||||||
|
$configuration_engine = $this->getConfigurationEngine();
|
||||||
|
if ($configuration_engine) {
|
||||||
|
$working_copy = $configuration_engine->getWorkingCopy();
|
||||||
|
$working_path = $working_copy->getWorkingDirectory();
|
||||||
|
|
||||||
|
return ArcanistWorkingCopyIdentity::newFromPath($working_path);
|
||||||
|
}
|
||||||
|
|
||||||
$working_copy = $this->getConfigurationManager()->getWorkingCopyIdentity();
|
$working_copy = $this->getConfigurationManager()->getWorkingCopyIdentity();
|
||||||
if (!$working_copy) {
|
if (!$working_copy) {
|
||||||
$workflow = get_class($this);
|
$workflow = get_class($this);
|
||||||
|
@ -911,6 +929,12 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getRepositoryAPI() {
|
final public function getRepositoryAPI() {
|
||||||
|
$configuration_engine = $this->getConfigurationEngine();
|
||||||
|
if ($configuration_engine) {
|
||||||
|
$working_copy = $configuration_engine->getWorkingCopy();
|
||||||
|
return $working_copy->getRepositoryAPI();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->repositoryAPI) {
|
if (!$this->repositoryAPI) {
|
||||||
$workflow = get_class($this);
|
$workflow = get_class($this);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
@ -2232,7 +2256,7 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
$query->setRepositoryRef($repository_ref);
|
$query->setRepositoryRef($repository_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
$working_copy = $this->getConfigurationManager()->getWorkingCopyIdentity();
|
$working_copy = $this->getWorkingCopy();
|
||||||
if ($working_copy) {
|
if ($working_copy) {
|
||||||
$working_ref = $this->newWorkingCopyStateRef();
|
$working_ref = $this->newWorkingCopyStateRef();
|
||||||
$query->setWorkingCopyRef($working_ref);
|
$query->setWorkingCopyRef($working_ref);
|
||||||
|
@ -2242,12 +2266,17 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getRepositoryRef() {
|
final public function getRepositoryRef() {
|
||||||
if (!$this->getConfigurationManager()->getWorkingCopyIdentity()) {
|
$configuration_engine = $this->getConfigurationEngine();
|
||||||
return null;
|
if ($configuration_engine) {
|
||||||
}
|
// This is a toolset workflow and can always build a repository ref.
|
||||||
|
} else {
|
||||||
|
if (!$this->getConfigurationManager()->getWorkingCopyIdentity()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->repositoryAPI) {
|
if (!$this->repositoryAPI) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->repositoryRef) {
|
if (!$this->repositoryRef) {
|
||||||
|
|
Loading…
Reference in a new issue