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
$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();
return 0;
}
- protected function getSupportedRevisionControlSystems() {
+ public function getSupportedRevisionControlSystems() {
return array('git', 'hg');
}
);
}
+ 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();
}
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(
}
}
- protected function getSupportedRevisionControlSystems() {
+ public function getSupportedRevisionControlSystems() {
return array('svn');
}
$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');
}
}
- protected function getSupportedRevisionControlSystems() {
+ public function getSupportedRevisionControlSystems() {
return array('git', 'hg');
}
);
}
- protected function getSupportedRevisionControlSystems() {
+ public function getSupportedRevisionControlSystems() {
return array('git', 'hg');
}
return array();
}
- protected function getSupportedRevisionControlSystems() {
+ public function getSupportedRevisionControlSystems() {
return array('git', 'hg', 'svn');
}