@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.

Replace "DiffusionCommitListView" with "DiffusionCommitGraphView"

Summary:
Ref T13552. This older view mostly duplicates other code and has only two callsites:

- The "Commits" section of user profile pages.
- The "Ambiguous Hash" page when you visit a commit hash page which is an ambiguous prefix of two or more commit hashes.

Replace both with "DiffusionCommitGraphView".

Test Plan:
- Visited profile page, clicked "Commits".
- Visited an ambiguous hash page (`rPbd3c23`).

Maniphest Tasks: T13552

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

+39 -205
+2 -2
resources/celerity/map.php
··· 73 73 'rsrc/css/application/diffusion/diffusion-icons.css' => '23b31a1b', 74 74 'rsrc/css/application/diffusion/diffusion-readme.css' => 'b68a76e4', 75 75 'rsrc/css/application/diffusion/diffusion-repository.css' => 'b89e8c6c', 76 - 'rsrc/css/application/diffusion/diffusion.css' => 'a54bb336', 76 + 'rsrc/css/application/diffusion/diffusion.css' => 'db8bbf58', 77 77 'rsrc/css/application/feed/feed.css' => 'd8b6e3f8', 78 78 'rsrc/css/application/files/global-drag-and-drop.css' => '1d2713a4', 79 79 'rsrc/css/application/flag/flag.css' => '2b77be8d', ··· 567 567 'differential-revision-history-css' => '8aa3eac5', 568 568 'differential-revision-list-css' => '93d2df7d', 569 569 'differential-table-of-contents-css' => 'bba788b9', 570 - 'diffusion-css' => 'a54bb336', 570 + 'diffusion-css' => 'db8bbf58', 571 571 'diffusion-icons-css' => '23b31a1b', 572 572 'diffusion-readme-css' => 'b68a76e4', 573 573 'diffusion-repository-css' => 'b89e8c6c',
-2
src/__phutil_library_map__.php
··· 783 783 'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php', 784 784 'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php', 785 785 'DiffusionCommitListController' => 'applications/diffusion/controller/DiffusionCommitListController.php', 786 - 'DiffusionCommitListView' => 'applications/diffusion/view/DiffusionCommitListView.php', 787 786 'DiffusionCommitMergeHeraldField' => 'applications/diffusion/herald/DiffusionCommitMergeHeraldField.php', 788 787 'DiffusionCommitMessageHeraldField' => 'applications/diffusion/herald/DiffusionCommitMessageHeraldField.php', 789 788 'DiffusionCommitPackageAuditHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php', ··· 6873 6872 'DiffusionCommitHookEngine' => 'Phobject', 6874 6873 'DiffusionCommitHookRejectException' => 'Exception', 6875 6874 'DiffusionCommitListController' => 'DiffusionController', 6876 - 'DiffusionCommitListView' => 'AphrontView', 6877 6875 'DiffusionCommitMergeHeraldField' => 'DiffusionCommitHeraldField', 6878 6876 'DiffusionCommitMessageHeraldField' => 'DiffusionCommitHeraldField', 6879 6877 'DiffusionCommitPackageAuditHeraldField' => 'DiffusionCommitHeraldField',
+2 -3
src/applications/diffusion/controller/DiffusionCommitController.php
··· 90 90 ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 91 91 ->appendChild($warning_message); 92 92 93 - $list = id(new DiffusionCommitListView()) 93 + $list = id(new DiffusionCommitGraphView()) 94 94 ->setViewer($viewer) 95 - ->setCommits($commits) 96 - ->setNoDataString(pht('No recent commits.')); 95 + ->setCommits($commits); 97 96 98 97 $crumbs->addTextCrumb(pht('Ambiguous Commit')); 99 98
+18 -3
src/applications/diffusion/controller/DiffusionHistoryController.php
··· 54 54 55 55 $history_list = id(new DiffusionCommitGraphView()) 56 56 ->setViewer($viewer) 57 - ->setParents($history_results['parents']) 58 - ->setIsHead(!$pager->getOffset()) 59 - ->setIsTail(!$pager->getHasMorePages()) 60 57 ->setDiffusionRequest($drequest) 61 58 ->setHistory($history) 62 59 ->setCommits($commits); 60 + 61 + // NOTE: If we have a path (like "src/"), many nodes in the graph are 62 + // likely to be missing (since the path wasn't touched by those commits). 63 + 64 + // If we draw the graph, commits will often appear to be unrelated because 65 + // intermediate nodes are omitted. Just drop the graph. 66 + 67 + // The ideal behavior would be to load the entire graph and then connect 68 + // ancestors appropriately, but this would currrently be prohibitively 69 + // expensive in the general case. 70 + 71 + $show_graph = !strlen($drequest->getPath()); 72 + if ($show_graph) { 73 + $history_list 74 + ->setParents($history_results['parents']) 75 + ->setIsHead(!$pager->getOffset()) 76 + ->setIsTail(!$pager->getHasMorePages()); 77 + } 63 78 64 79 $header = $this->buildHeader($drequest); 65 80
+14 -7
src/applications/diffusion/view/DiffusionCommitGraphView.php
··· 332 332 } 333 333 334 334 private function newBrowseButton($hash) { 335 - $commit = $this->getCommit($hash); 335 + $repository = $this->getRepository(); 336 + 337 + if ($repository) { 338 + $drequest = $this->getDiffusionRequest(); 339 + 340 + return $this->linkBrowse( 341 + $drequest->getPath(), 342 + array( 343 + 'commit' => $hash, 344 + 'branch' => $drequest->getBranch(), 345 + ), 346 + $as_button = true); 347 + } 336 348 337 - return $this->linkBrowse( 338 - '/', 339 - array( 340 - 'commit' => $hash, 341 - ), 342 - $as_button = true); 349 + return null; 343 350 } 344 351 345 352 private function getCommit($hash) {
-177
src/applications/diffusion/view/DiffusionCommitListView.php
··· 1 - <?php 2 - 3 - final class DiffusionCommitListView extends AphrontView { 4 - 5 - private $commits = array(); 6 - private $noDataString; 7 - 8 - public function setNoDataString($no_data_string) { 9 - $this->noDataString = $no_data_string; 10 - return $this; 11 - } 12 - 13 - public function setHeader($header) { 14 - $this->header = $header; 15 - return $this; 16 - } 17 - 18 - public function setCommits(array $commits) { 19 - assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 20 - $this->commits = mpull($commits, null, 'getPHID'); 21 - return $this; 22 - } 23 - 24 - public function getCommits() { 25 - return $this->commits; 26 - } 27 - 28 - public function setHandles(array $handles) { 29 - assert_instances_of($handles, 'PhabricatorObjectHandle'); 30 - $this->handles = $handles; 31 - return $this; 32 - } 33 - 34 - private function getRequiredHandlePHIDs() { 35 - $phids = array(); 36 - foreach ($this->history as $item) { 37 - $data = $item->getCommitData(); 38 - if ($data) { 39 - if ($data->getCommitDetail('authorPHID')) { 40 - $phids[$data->getCommitDetail('authorPHID')] = true; 41 - } 42 - if ($data->getCommitDetail('committerPHID')) { 43 - $phids[$data->getCommitDetail('committerPHID')] = true; 44 - } 45 - } 46 - } 47 - return array_keys($phids); 48 - } 49 - 50 - private function getCommitDescription($phid) { 51 - if ($this->commits === null) { 52 - return pht('(Unknown Commit)'); 53 - } 54 - 55 - $commit = idx($this->commits, $phid); 56 - if (!$commit) { 57 - return pht('(Unknown Commit)'); 58 - } 59 - 60 - $summary = $commit->getCommitData()->getSummary(); 61 - if (strlen($summary)) { 62 - return $summary; 63 - } 64 - 65 - // No summary, so either this is still importing or just has an empty 66 - // commit message. 67 - 68 - if (!$commit->isImported()) { 69 - return pht('(Importing Commit...)'); 70 - } else { 71 - return pht('(Untitled Commit)'); 72 - } 73 - } 74 - 75 - public function render() { 76 - require_celerity_resource('diffusion-css'); 77 - return $this->buildList(); 78 - } 79 - 80 - public function buildList() { 81 - $viewer = $this->getViewer(); 82 - $rowc = array(); 83 - 84 - $phids = array(); 85 - foreach ($this->getCommits() as $commit) { 86 - $phids[] = $commit->getPHID(); 87 - 88 - $author_phid = $commit->getAuthorPHID(); 89 - if ($author_phid) { 90 - $phids[] = $author_phid; 91 - } 92 - } 93 - 94 - $handles = $viewer->loadHandles($phids); 95 - 96 - $cur_date = 0; 97 - $view = array(); 98 - foreach ($this->commits as $commit) { 99 - $new_date = phabricator_date($commit->getEpoch(), $viewer); 100 - if ($cur_date !== $new_date) { 101 - $date = ucfirst( 102 - phabricator_relative_date($commit->getEpoch(), $viewer)); 103 - $header = id(new PHUIHeaderView()) 104 - ->setHeader($date); 105 - $list = id(new PHUIObjectItemListView()) 106 - ->setFlush(true) 107 - ->addClass('diffusion-history-list'); 108 - 109 - $view[] = id(new PHUIObjectBoxView()) 110 - ->setHeader($header) 111 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 112 - ->setObjectList($list); 113 - } 114 - 115 - $commit_phid = $commit->getPHID(); 116 - $commit_handle = $handles[$commit_phid]; 117 - $committed = null; 118 - 119 - $commit_name = $commit_handle->getName(); 120 - $commit_link = $commit_handle->getURI(); 121 - $commit_desc = $this->getCommitDescription($commit_phid); 122 - $committed = phabricator_datetime($commit->getEpoch(), $viewer); 123 - 124 - $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); 125 - $engine->setConfig('viewer', $viewer); 126 - $commit_data = $commit->getCommitData(); 127 - $message = $commit_data->getCommitMessage(); 128 - $message = $engine->markupText($message); 129 - $message = phutil_tag_div( 130 - 'diffusion-history-message phabricator-remarkup', $message); 131 - 132 - $author_phid = $commit->getAuthorPHID(); 133 - if ($author_phid) { 134 - $author_name = $handles[$author_phid]->renderLink(); 135 - $author_image_uri = $handles[$author_phid]->getImageURI(); 136 - } else { 137 - $author_name = $commit->getCommitData()->getAuthorName(); 138 - $author_image_uri = 139 - celerity_get_resource_uri('/rsrc/image/people/user0.png'); 140 - } 141 - 142 - $commit_tag = id(new PHUITagView()) 143 - ->setName($commit_name) 144 - ->setType(PHUITagView::TYPE_SHADE) 145 - ->setColor(PHUITagView::COLOR_INDIGO) 146 - ->setBorder(PHUITagView::BORDER_NONE) 147 - ->setSlimShady(true); 148 - 149 - $item = id(new PHUIObjectItemView()) 150 - ->setHeader($commit_desc) 151 - ->setHref($commit_link) 152 - ->setDisabled($commit->isUnreachable()) 153 - ->setDescription($message) 154 - ->setImageURI($author_image_uri) 155 - ->addByline(pht('Author: %s', $author_name)) 156 - ->addIcon('none', $committed) 157 - ->addAttribute($commit_tag); 158 - 159 - $list->addItem($item); 160 - $cur_date = $new_date; 161 - } 162 - 163 - if (!$view) { 164 - $list = id(new PHUIObjectItemListView()) 165 - ->setFlush(true) 166 - ->setNoDataString($this->noDataString); 167 - 168 - $view = id(new PHUIObjectBoxView()) 169 - ->setHeaderText(pht('Recent Commits')) 170 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 171 - ->setObjectList($list); 172 - } 173 - 174 - return $view; 175 - } 176 - 177 - }
+3 -3
src/applications/people/controller/PhabricatorPeopleProfileCommitsController.php
··· 58 58 ->setViewer($viewer) 59 59 ->withAuthorPHIDs(array($user->getPHID())) 60 60 ->needCommitData(true) 61 + ->needIdentities(true) 61 62 ->setLimit(100) 62 63 ->execute(); 63 64 64 - $list = id(new DiffusionCommitListView()) 65 + $list = id(new DiffusionCommitGraphView()) 65 66 ->setViewer($viewer) 66 - ->setCommits($commits) 67 - ->setNoDataString(pht('No recent commits.')); 67 + ->setCommits($commits); 68 68 69 69 return $list; 70 70 }
-8
webroot/rsrc/css/application/diffusion/diffusion.css
··· 93 93 font-size: {$biggerfontsize}; 94 94 } 95 95 96 - .diffusion-history-message { 97 - background-color: {$bluebackground}; 98 - padding: 16px; 99 - margin: 4px 0; 100 - border-radius: 5px; 101 - color: {$darkbluetext}; 102 - } 103 - 104 96 .diffusion-history-list .phui-oi-attribute { 105 97 font-size: {$smallerfontsize}; 106 98 letter-spacing: 0.01em;