Diffusion - clean up catching ConduitException

Summary: Ref T7123. Turns out that we might throw ConduitClientException now in proxied scenarios. For all but one callsite remove the try / catch bit and don't issue the call for SVN. For the remaining callsite, also don't issue the call for SVN but keep in the exception logic since its renders a pretty error message in the non-proxied case?

Test Plan: played around with diffusion and things looked okay.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7123

Differential Revision: https://secure.phabricator.com/D11789
This commit is contained in:
Bob Trahan
2015-02-17 14:01:17 -08:00
parent 3fcc3fdedf
commit 81d2f2686c
5 changed files with 83 additions and 85 deletions

View File

@@ -52,7 +52,11 @@ final class DiffusionBrowseSearchController extends DiffusionBrowseController {
$search_mode = null; $search_mode = null;
try { switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$results = array();
break;
default:
if (strlen($this->getRequest()->getStr('grep'))) { if (strlen($this->getRequest()->getStr('grep'))) {
$search_mode = 'grep'; $search_mode = 'grep';
$query_string = $this->getRequest()->getStr('grep'); $query_string = $this->getRequest()->getStr('grep');
@@ -78,13 +82,7 @@ final class DiffusionBrowseSearchController extends DiffusionBrowseController {
'offset' => $page, 'offset' => $page,
)); ));
} }
} catch (ConduitException $ex) { break;
$err = $ex->getErrorDescription();
if ($err != '') {
return id(new PHUIErrorView())
->setTitle(pht('Search Error'))
->appendChild($err);
}
} }
$results = $pager->sliceResults($results); $results = $pager->sliceResults($results);

View File

@@ -8,22 +8,22 @@ final class DiffusionCommitBranchesController extends DiffusionController {
protected function processDiffusionRequest(AphrontRequest $request) { protected function processDiffusionRequest(AphrontRequest $request) {
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$branches = array(); $branches = array();
try { break;
default:
$branches = $this->callConduitWithDiffusionRequest( $branches = $this->callConduitWithDiffusionRequest(
'diffusion.branchquery', 'diffusion.branchquery',
array( array(
'contains' => $drequest->getCommit(), 'contains' => $drequest->getCommit(),
)); ));
} catch (ConduitException $ex) { break;
if ($ex->getMessage() != 'ERR-UNSUPPORTED-VCS') {
throw $ex;
}
} }
$branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
$branch_links = array(); $branch_links = array();
foreach ($branches as $branch) { foreach ($branches as $branch) {
$branch_links[] = phutil_tag( $branch_links[] = phutil_tag(

View File

@@ -8,10 +8,14 @@ final class DiffusionCommitTagsController extends DiffusionController {
protected function processDiffusionRequest(AphrontRequest $request) { protected function processDiffusionRequest(AphrontRequest $request) {
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
$tag_limit = 10; $repository = $drequest->getRepository();
$tag_limit = 10;
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$tags = array(); $tags = array();
try { break;
default:
$tags = DiffusionRepositoryTag::newFromConduit( $tags = DiffusionRepositoryTag::newFromConduit(
$this->callConduitWithDiffusionRequest( $this->callConduitWithDiffusionRequest(
'diffusion.tagsquery', 'diffusion.tagsquery',
@@ -19,12 +23,8 @@ final class DiffusionCommitTagsController extends DiffusionController {
'commit' => $drequest->getCommit(), 'commit' => $drequest->getCommit(),
'limit' => $tag_limit + 1, 'limit' => $tag_limit + 1,
))); )));
} catch (ConduitException $ex) { break;
if ($ex->getMessage() != 'ERR-UNSUPPORTED-VCS') {
throw $ex;
} }
}
$has_more_tags = (count($tags) > $tag_limit); $has_more_tags = (count($tags) > $tag_limit);
$tags = array_slice($tags, 0, $tag_limit); $tags = array_slice($tags, 0, $tag_limit);

View File

@@ -374,10 +374,15 @@ final class DiffusionRepositoryController extends DiffusionController {
private function buildTagListTable(DiffusionRequest $drequest) { private function buildTagListTable(DiffusionRequest $drequest) {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();
$repository = $drequest->getRepository();
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// no tags in SVN
return null;
}
$tag_limit = 15; $tag_limit = 15;
$tags = array(); $tags = array();
try {
$tags = DiffusionRepositoryTag::newFromConduit( $tags = DiffusionRepositoryTag::newFromConduit(
$this->callConduitWithDiffusionRequest( $this->callConduitWithDiffusionRequest(
'diffusion.tagsquery', 'diffusion.tagsquery',
@@ -386,11 +391,6 @@ final class DiffusionRepositoryController extends DiffusionController {
'commit' => null, 'commit' => null,
'limit' => $tag_limit + 1, 'limit' => $tag_limit + 1,
))); )));
} catch (ConduitException $e) {
if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') {
throw $e;
}
}
if (!$tags) { if (!$tags) {
return null; return null;
@@ -402,7 +402,7 @@ final class DiffusionRepositoryController extends DiffusionController {
$commits = id(new DiffusionCommitQuery()) $commits = id(new DiffusionCommitQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIdentifiers(mpull($tags, 'getCommitIdentifier')) ->withIdentifiers(mpull($tags, 'getCommitIdentifier'))
->withRepository($drequest->getRepository()) ->withRepository($repository)
->needCommitData(true) ->needCommitData(true)
->execute(); ->execute();

View File

@@ -28,16 +28,16 @@ final class DiffusionTagListController extends DiffusionController {
$is_commit = false; $is_commit = false;
} }
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$tags = array(); $tags = array();
try { break;
default:
$conduit_result = $this->callConduitWithDiffusionRequest( $conduit_result = $this->callConduitWithDiffusionRequest(
'diffusion.tagsquery', 'diffusion.tagsquery',
$params); $params);
$tags = DiffusionRepositoryTag::newFromConduit($conduit_result); $tags = DiffusionRepositoryTag::newFromConduit($conduit_result);
} catch (ConduitException $ex) { break;
if ($ex->getMessage() != 'ERR-UNSUPPORTED-VCS') {
throw $ex;
}
} }
$tags = $pager->sliceResults($tags); $tags = $pager->sliceResults($tags);