diff --git a/scripts/arcanist.php b/scripts/arcanist.php --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -202,6 +202,16 @@ $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(); diff --git a/src/workflow/ArcanistAmendWorkflow.php b/src/workflow/ArcanistAmendWorkflow.php --- a/src/workflow/ArcanistAmendWorkflow.php +++ b/src/workflow/ArcanistAmendWorkflow.php @@ -188,7 +188,7 @@ return 0; } - protected function getSupportedRevisionControlSystems() { + public function getSupportedRevisionControlSystems() { return array('git', 'hg'); } diff --git a/src/workflow/ArcanistBookmarkWorkflow.php b/src/workflow/ArcanistBookmarkWorkflow.php --- a/src/workflow/ArcanistBookmarkWorkflow.php +++ b/src/workflow/ArcanistBookmarkWorkflow.php @@ -25,12 +25,11 @@ ); } + public function getSupportedRevisionControlSystems() { + return array('hg'); + } + public function run() { - $repository_api = $this->getRepositoryAPI(); - if (!($repository_api instanceof ArcanistMercurialAPI)) { - throw new ArcanistUsageException( - 'arc bookmark is only supported under Mercurial.'); - } return parent::run(); } diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php --- a/src/workflow/ArcanistCommitWorkflow.php +++ b/src/workflow/ArcanistCommitWorkflow.php @@ -65,12 +65,6 @@ 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 @@ } } - protected function getSupportedRevisionControlSystems() { + public function getSupportedRevisionControlSystems() { return array('svn'); } diff --git a/src/workflow/ArcanistLandWorkflow.php b/src/workflow/ArcanistLandWorkflow.php --- a/src/workflow/ArcanistLandWorkflow.php +++ b/src/workflow/ArcanistLandWorkflow.php @@ -239,13 +239,6 @@ $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 @@ } } - protected function getSupportedRevisionControlSystems() { + public function getSupportedRevisionControlSystems() { return array('git', 'hg'); } diff --git a/src/workflow/ArcanistRevertWorkflow.php b/src/workflow/ArcanistRevertWorkflow.php --- a/src/workflow/ArcanistRevertWorkflow.php +++ b/src/workflow/ArcanistRevertWorkflow.php @@ -29,7 +29,7 @@ ); } - protected function getSupportedRevisionControlSystems() { + public function getSupportedRevisionControlSystems() { return array('git', 'hg'); } diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -1215,7 +1215,7 @@ return array(); } - protected function getSupportedRevisionControlSystems() { + public function getSupportedRevisionControlSystems() { return array('git', 'hg', 'svn'); }