diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditHostingController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditHostingController.php index 7b39aa3602..055ad5a958 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditHostingController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditHostingController.php @@ -126,6 +126,9 @@ final class DiffusionRepositoryEditHostingController $request = $this->getRequest(); $user = $request->getUser(); + $type = $repository->getVersionControlSystem(); + $is_svn = ($type == PhabricatorRepositoryType::REPOSITORY_TYPE_SVN); + $v_http_mode = $repository->getDetail( 'serve-over-http', PhabricatorRepository::SERVE_OFF); @@ -146,9 +149,11 @@ final class DiffusionRepositoryEditHostingController $type_http = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_HTTP; $type_ssh = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_SSH; - $xactions[] = id(clone $template) - ->setTransactionType($type_http) - ->setNewValue($v_http_mode); + if (!$is_svn) { + $xactions[] = id(clone $template) + ->setTransactionType($type_http) + ->setNewValue($v_http_mode); + } $xactions[] = id(clone $template) ->setTransactionType($type_ssh) @@ -232,6 +237,18 @@ final class DiffusionRepositoryEditHostingController PhabricatorRepository::SERVE_READWRITE), $rw_message); + if ($is_svn) { + $http_control = id(new AphrontFormMarkupControl()) + ->setLabel(pht('HTTP')) + ->setValue( + phutil_tag( + 'em', + array(), + pht( + 'Phabricator does not currently support HTTP access to '. + 'Subversion repositories.'))); + } + $form = id(new AphrontFormView()) ->setUser($user) ->appendRemarkupInstructions( diff --git a/src/applications/diffusion/controller/DiffusionServeController.php b/src/applications/diffusion/controller/DiffusionServeController.php index 6e78b89abc..3a7312c39a 100644 --- a/src/applications/diffusion/controller/DiffusionServeController.php +++ b/src/applications/diffusion/controller/DiffusionServeController.php @@ -172,18 +172,53 @@ final class DiffusionServeController extends DiffusionController { pht('This repository is not available over HTTP.')); } - switch ($repository->getVersionControlSystem()) { - case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: - $result = $this->serveGitRequest($repository, $viewer); - break; - case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: - $result = $this->serveMercurialRequest($repository, $viewer); - break; - default: - $result = new PhabricatorVCSResponse( - 999, - pht('TODO: Implement meaningful responses.')); - break; + $vcs_type = $repository->getVersionControlSystem(); + $req_type = $this->isVCSRequest($request); + + if ($vcs_type != $req_type) { + switch ($req_type) { + case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: + $result = new PhabricatorVCSResponse( + 500, + pht('This is not a Git repository.')); + break; + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: + $result = new PhabricatorVCSResponse( + 500, + pht('This is not a Mercurial repository.')); + break; + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: + $result = new PhabricatorVCSResponse( + 500, + pht('This is not a Subversion repository.')); + break; + default: + $result = new PhabricatorVCSResponse( + 500, + pht('Unknown request type.')); + break; + } + } else { + switch ($vcs_type) { + case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: + $result = $this->serveGitRequest($repository, $viewer); + break; + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: + $result = $this->serveMercurialRequest($repository, $viewer); + break; + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: + $result = new PhabricatorVCSResponse( + 500, + pht( + 'Phabricator does not support HTTP access to Subversion '. + 'repositories.')); + break; + default: + $result = new PhabricatorVCSResponse( + 500, + pht('Unknown version control system.')); + break; + } } $code = $result->getHTTPResponseCode(); @@ -232,7 +267,7 @@ final class DiffusionServeController extends DiffusionController { return DiffusionMercurialWireProtocol::isReadOnlyBatchCommand($cmds); } return DiffusionMercurialWireProtocol::isReadOnlyCommand($cmd); - case PhabricatorRepositoryType::REPOSITORY_TYPE_SUBVERSION: + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: break; } diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index 2174bdbadf..a4d140bba0 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -757,6 +757,9 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO } public function getServeOverHTTP() { + if ($this->isSVN()) { + return self::SERVE_OFF; + } $serve = $this->getDetail('serve-over-http', self::SERVE_OFF); return $this->normalizeServeConfigSetting($serve); }