@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

Show first 10 branches, then "More Branches" for commits on huge numbers of branches

Summary: Fixes T9562. We already do this for tags, but didn't have similar logic for branches. Implement that logic.

Test Plan:
- Set limit to 1, saw "More branches", clicked it, got the correct results.
- Verified that branch table with no specified commit still works properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9562

Differential Revision: https://secure.phabricator.com/D15284

+42 -32
+11 -5
src/applications/diffusion/controller/DiffusionBranchTableController.php
··· 19 19 $pager = id(new PHUIPagerView()) 20 20 ->readFromRequest($request); 21 21 22 - // TODO: Add support for branches that contain commit 22 + $params = array( 23 + 'offset' => $pager->getOffset(), 24 + 'limit' => $pager->getPageSize() + 1, 25 + ); 26 + 27 + $contains = $drequest->getSymbolicCommit(); 28 + if (strlen($contains)) { 29 + $params['contains'] = $contains; 30 + } 31 + 23 32 $branches = $this->callConduitWithDiffusionRequest( 24 33 'diffusion.branchquery', 25 - array( 26 - 'offset' => $pager->getOffset(), 27 - 'limit' => $pager->getPageSize() + 1, 28 - )); 34 + $params); 29 35 $branches = $pager->sliceResults($branches); 30 36 31 37 $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
+23 -13
src/applications/diffusion/controller/DiffusionCommitBranchesController.php
··· 15 15 $drequest = $this->getDiffusionRequest(); 16 16 $repository = $drequest->getRepository(); 17 17 18 - switch ($repository->getVersionControlSystem()) { 19 - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 20 - $branches = array(); 21 - break; 22 - default: 23 - $branches = $this->callConduitWithDiffusionRequest( 24 - 'diffusion.branchquery', 25 - array( 26 - 'contains' => $drequest->getCommit(), 27 - )); 28 - break; 29 - } 18 + $branch_limit = 10; 19 + $branches = DiffusionRepositoryRef::loadAllFromDictionaries( 20 + $this->callConduitWithDiffusionRequest( 21 + 'diffusion.branchquery', 22 + array( 23 + 'contains' => $drequest->getCommit(), 24 + 'limit' => $branch_limit + 1, 25 + ))); 30 26 31 - $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); 27 + $has_more_branches = (count($branches) > $branch_limit); 28 + $branches = array_slice($branches, 0, $branch_limit); 29 + 32 30 $branch_links = array(); 33 31 foreach ($branches as $branch) { 34 32 $branch_links[] = phutil_tag( ··· 41 39 )), 42 40 ), 43 41 $branch->getShortName()); 42 + } 43 + 44 + if ($has_more_branches) { 45 + $branch_links[] = phutil_tag( 46 + 'a', 47 + array( 48 + 'href' => $drequest->generateURI( 49 + array( 50 + 'action' => 'branches', 51 + )), 52 + ), 53 + pht("More Branches\xE2\x80\xA6")); 44 54 } 45 55 46 56 return id(new AphrontAjaxResponse())
+8 -14
src/applications/diffusion/controller/DiffusionCommitTagsController.php
··· 16 16 $repository = $drequest->getRepository(); 17 17 18 18 $tag_limit = 10; 19 - switch ($repository->getVersionControlSystem()) { 20 - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 21 - $tags = array(); 22 - break; 23 - default: 24 - $tags = DiffusionRepositoryTag::newFromConduit( 25 - $this->callConduitWithDiffusionRequest( 26 - 'diffusion.tagsquery', 27 - array( 28 - 'commit' => $drequest->getCommit(), 29 - 'limit' => $tag_limit + 1, 30 - ))); 31 - break; 32 - } 19 + $tags = DiffusionRepositoryTag::newFromConduit( 20 + $this->callConduitWithDiffusionRequest( 21 + 'diffusion.tagsquery', 22 + array( 23 + 'commit' => $drequest->getCommit(), 24 + 'limit' => $tag_limit + 1, 25 + ))); 26 + 33 27 $has_more_tags = (count($tags) > $tag_limit); 34 28 $tags = array_slice($tags, 0, $tag_limit); 35 29