@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+4 -3
+4 -3
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 29 29 // If this VCS supports branches, check that the selected branch actually 30 30 // exists. 31 31 if ($drequest->supportsBranches()) { 32 - $ref_cursor = id(new PhabricatorRepositoryRefCursorQuery()) 32 + // NOTE: Mercurial may have multiple branch heads with the same name. 33 + $ref_cursors = id(new PhabricatorRepositoryRefCursorQuery()) 33 34 ->setViewer($viewer) 34 35 ->withRepositoryPHIDs(array($repository->getPHID())) 35 36 ->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH)) 36 37 ->withRefNames(array($drequest->getBranch())) 37 - ->executeOne(); 38 - if ($ref_cursor) { 38 + ->execute(); 39 + if ($ref_cursors) { 39 40 // This is a valid branch, so we necessarily have some content. 40 41 $page_has_content = true; 41 42 } else {