@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Ignore closed branch heads by default in Mercurial

Summary:
Fixes T6160. Ref T7100.

- When resolving ambiguous branch references, ignore closed heads unless there are no other options.
- Hide closed heads by default on the main page.
- Show branch open/closed state in Mercurial.

Test Plan: Browsed a previously-ambiguous Mercurial repository because of multiple branch heads, no longer ambiguous.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6160, T7100

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

+55 -3
+11
src/applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php
··· 17 17 18 18 protected function defineCustomParamTypes() { 19 19 return array( 20 + 'closed' => 'optional bool', 20 21 'limit' => 'optional int', 21 22 'offset' => 'optional int', 22 23 'contains' => 'optional string', ··· 94 95 foreach ($refs as $key => $ref) { 95 96 if (!$repository->shouldTrackBranch($ref->getShortName())) { 96 97 unset($refs[$key]); 98 + } 99 + } 100 + 101 + $with_closed = $request->getValue('closed'); 102 + if ($with_closed !== null) { 103 + foreach ($refs as $key => $ref) { 104 + $fields = $ref->getRawFields(); 105 + if (idx($fields, 'closed') != $with_closed) { 106 + unset($refs[$key]); 107 + } 97 108 } 98 109 } 99 110
+1
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 351 351 $branches = $this->callConduitWithDiffusionRequest( 352 352 'diffusion.branchquery', 353 353 array( 354 + 'closed' => false, 354 355 'limit' => $limit + 1, 355 356 )); 356 357 if (!$branches) {
+23 -3
src/applications/diffusion/request/DiffusionRequest.php
··· 756 756 } 757 757 758 758 private function chooseBestRefMatch($ref, array $results) { 759 - // TODO: Do a better job of selecting the best match. 760 - $match = head($results); 759 + // First, filter out less-desirable matches. 760 + $candidates = array(); 761 + foreach ($results as $result) { 762 + // Exclude closed heads. 763 + if ($result['type'] == 'branch') { 764 + if (idx($result, 'closed')) { 765 + continue; 766 + } 767 + } 768 + 769 + $candidates[] = $result; 770 + } 771 + 772 + // If we filtered everything, undo the filtering. 773 + if (!$candidates) { 774 + $candidates = $results; 775 + } 776 + 777 + // TODO: Do a better job of selecting the best match? 778 + $match = head($candidates); 761 779 762 780 // After choosing the best alternative, save all the alternatives so the 763 781 // UI can show them to the user. 764 - $this->refAlternatives = $results; 782 + if (count($candidates) > 1) { 783 + $this->refAlternatives = $candidates; 784 + } 765 785 766 786 return $match; 767 787 }
+20
src/applications/diffusion/view/DiffusionBranchTableView.php
··· 22 22 $current_branch = $drequest->getBranch(); 23 23 $repository = $drequest->getRepository(); 24 24 25 + $can_close_branches = ($repository->isHg()); 26 + 25 27 Javelin::initBehavior('phabricator-tooltips'); 26 28 27 29 $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose'); ··· 74 76 'tip' => $tip, 75 77 'size' => 200, 76 78 )); 79 + 80 + $fields = $branch->getRawFields(); 81 + $closed = idx($fields, 'closed'); 82 + if ($closed) { 83 + $status = pht('Closed'); 84 + } else { 85 + $status = pht('Open'); 86 + } 77 87 78 88 $rows[] = array( 79 89 phutil_tag( ··· 99 109 self::linkCommit( 100 110 $drequest->getRepository(), 101 111 $branch->getCommitIdentifier()), 112 + $status, 102 113 $status_icon, 103 114 $datetime, 104 115 AphrontTableView::renderSingleDisplayLine($details), ··· 116 127 pht('History'), 117 128 pht('Branch'), 118 129 pht('Head'), 130 + pht('State'), 119 131 pht(''), 120 132 pht('Modified'), 121 133 pht('Details'), ··· 127 139 '', 128 140 '', 129 141 '', 142 + '', 130 143 'wide', 144 + )); 145 + $view->setColumnVisibility( 146 + array( 147 + true, 148 + true, 149 + true, 150 + $can_close_branches, 131 151 )); 132 152 $view->setRowClasses($rowc); 133 153 return $view->render();