From ced20d48eac2d474dc856039b710b3bf54607093 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 28 Apr 2015 08:56:16 -0700 Subject: [PATCH] Improve handling of bad branches in Diffusion Summary: Fixes T7972. - Trap the RefNotFound error which may occur in `getAlternatives()`. - Improve error handling in Mercurial. Test Plan: {F387611} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7972 Differential Revision: https://secure.phabricator.com/D12590 --- .../query/lowlevel/DiffusionLowLevelResolveRefsQuery.php | 4 ++++ src/applications/diffusion/request/DiffusionRequest.php | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php index 556ddf0904..2fc03fb739 100644 --- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php +++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php @@ -204,6 +204,10 @@ final class DiffusionLowLevelResolveRefsQuery // unclear how to best do that. For now, treat it as a miss instead. continue; } + if (preg_match('/unknown revision/', $ex->getStdErr())) { + // No matches for this ref. + continue; + } throw $ex; } diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php index 2af40ac930..f0f6d49c23 100644 --- a/src/applications/diffusion/request/DiffusionRequest.php +++ b/src/applications/diffusion/request/DiffusionRequest.php @@ -755,7 +755,12 @@ abstract class DiffusionRequest { public function getRefAlternatives() { // Make sure we've resolved the reference into a stable commit first. - $this->getStableCommit(); + try { + $this->getStableCommit(); + } catch (DiffusionRefNotFoundException $ex) { + // If we have a bad reference, just return the empty set of + // alternatives. + } return $this->refAlternatives; }