mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Explicitly check for supported VCS
Summary: Instead of having an `ArcanistWorkflow` subclass explicitly throw an exception when run in an unsupported VCS, consolidate this code and move it to `arcanist.php`. In doing so, we lose some specificity in some of the error messages, but this otherwise feels cleaner. We could consider adding a `getUnsupportedRevisionControlSystemMessage()` method to provide a more tailored error message. Depends on D11604. Test Plan: Ran `arc bookmark` in a `git` working copy: ``` Usage Exception: `arc bookmark` is only supported under hg. ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11550
This commit is contained in:
parent
52277fc06f
commit
e4be031778
7 changed files with 19 additions and 23 deletions
|
@ -202,6 +202,16 @@ try {
|
|||
$workflow->setConduitTimeout($conduit_timeout);
|
||||
}
|
||||
|
||||
$supported_vcs_types = $workflow->getSupportedRevisionControlSystems();
|
||||
if (!in_array($working_copy->getVCSType(), $supported_vcs_types)) {
|
||||
throw new ArcanistUsageException(
|
||||
pht(
|
||||
'`%s %s` is only supported under %s.',
|
||||
'arc',
|
||||
$workflow->getWorkflowName(),
|
||||
implode(', ', $supported_vcs_types)));
|
||||
}
|
||||
|
||||
$need_working_copy = $workflow->requiresWorkingCopy();
|
||||
$need_conduit = $workflow->requiresConduit();
|
||||
$need_auth = $workflow->requiresAuthentication();
|
||||
|
|
|
@ -188,7 +188,7 @@ EOTEXT
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected function getSupportedRevisionControlSystems() {
|
||||
public function getSupportedRevisionControlSystems() {
|
||||
return array('git', 'hg');
|
||||
}
|
||||
|
||||
|
|
|
@ -25,12 +25,11 @@ EOTEXT
|
|||
);
|
||||
}
|
||||
|
||||
public function run() {
|
||||
$repository_api = $this->getRepositoryAPI();
|
||||
if (!($repository_api instanceof ArcanistMercurialAPI)) {
|
||||
throw new ArcanistUsageException(
|
||||
'arc bookmark is only supported under Mercurial.');
|
||||
public function getSupportedRevisionControlSystems() {
|
||||
return array('hg');
|
||||
}
|
||||
|
||||
public function run() {
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
|
|
|
@ -65,12 +65,6 @@ EOTEXT
|
|||
public function run() {
|
||||
$repository_api = $this->getRepositoryAPI();
|
||||
|
||||
if (!($repository_api instanceof ArcanistSubversionAPI)) {
|
||||
throw new ArcanistUsageException(
|
||||
"'arc commit' is only supported under svn.");
|
||||
}
|
||||
|
||||
|
||||
$revision_id = $this->normalizeRevisionID($this->getArgument('revision'));
|
||||
if (!$revision_id) {
|
||||
$revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
|
||||
|
@ -271,7 +265,7 @@ EOTEXT
|
|||
}
|
||||
}
|
||||
|
||||
protected function getSupportedRevisionControlSystems() {
|
||||
public function getSupportedRevisionControlSystems() {
|
||||
return array('svn');
|
||||
}
|
||||
|
||||
|
|
|
@ -239,13 +239,6 @@ EOTEXT
|
|||
$this->isGit = $repository_api instanceof ArcanistGitAPI;
|
||||
$this->isHg = $repository_api instanceof ArcanistMercurialAPI;
|
||||
|
||||
if (!$this->isGit && !$this->isHg) {
|
||||
throw new ArcanistUsageException(
|
||||
pht(
|
||||
"'arc land' only supports Git and Mercurial. For Subversion, try ".
|
||||
"'arc commit'."));
|
||||
}
|
||||
|
||||
if ($this->isGit) {
|
||||
$repository = $this->loadProjectRepository();
|
||||
$this->isGitSvn = (idx($repository, 'vcs') == 'svn');
|
||||
|
@ -1141,7 +1134,7 @@ EOTEXT
|
|||
}
|
||||
}
|
||||
|
||||
protected function getSupportedRevisionControlSystems() {
|
||||
public function getSupportedRevisionControlSystems() {
|
||||
return array('git', 'hg');
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ EOTEXT
|
|||
);
|
||||
}
|
||||
|
||||
protected function getSupportedRevisionControlSystems() {
|
||||
public function getSupportedRevisionControlSystems() {
|
||||
return array('git', 'hg');
|
||||
}
|
||||
|
||||
|
|
|
@ -1215,7 +1215,7 @@ abstract class ArcanistWorkflow extends Phobject {
|
|||
return array();
|
||||
}
|
||||
|
||||
protected function getSupportedRevisionControlSystems() {
|
||||
public function getSupportedRevisionControlSystems() {
|
||||
return array('git', 'hg', 'svn');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue