From 66a30ef97bbe6bb1210941c96a2b688d41a42bc8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 13 Jul 2014 06:55:04 -0700 Subject: [PATCH] Fix issue in Mercurial repos with duplicate branch heads Summary: Fixes T5613. A branch may have multiple heads in Mercurial, but `executeOne()` expects exactly one result. Load them all instead. Equivalently, we could `limit(1)`, but it's likely that we'll use the cursors in the future to reduce the number of VCS operations we do, so this is probably a little more along the lines where we're headed. Test Plan: Poked around some repos. Reviewers: chad, richardvanvelzen Reviewed By: richardvanvelzen Subscribers: epriestley Maniphest Tasks: T5613 Differential Revision: https://secure.phabricator.com/D9918 --- .../diffusion/controller/DiffusionRepositoryController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php index 8bc0e98872..151c5f8a2c 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php @@ -29,13 +29,14 @@ final class DiffusionRepositoryController extends DiffusionController { // If this VCS supports branches, check that the selected branch actually // exists. if ($drequest->supportsBranches()) { - $ref_cursor = id(new PhabricatorRepositoryRefCursorQuery()) + // NOTE: Mercurial may have multiple branch heads with the same name. + $ref_cursors = id(new PhabricatorRepositoryRefCursorQuery()) ->setViewer($viewer) ->withRepositoryPHIDs(array($repository->getPHID())) ->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH)) ->withRefNames(array($drequest->getBranch())) - ->executeOne(); - if ($ref_cursor) { + ->execute(); + if ($ref_cursors) { // This is a valid branch, so we necessarily have some content. $page_has_content = true; } else {