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

Move the view of merged changes to "DiffusionCommitGraphView"

Summary: Ref T13552. When viewing a merge commit, merged changes are currently shown inline. Update this view to use the new "GraphView" rendering pipeline.

Test Plan:
- Viewed a merge commit, saw merges.
- Viewed history, profile page, etc.

Maniphest Tasks: T13552

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

+133 -65
+3 -3
src/applications/diffusion/controller/DiffusionCommitController.php
··· 811 811 new PhutilNumber($limit))); 812 812 } 813 813 814 - $history_table = id(new DiffusionHistoryTableView()) 815 - ->setUser($viewer) 814 + $commit_list = id(new DiffusionCommitGraphView()) 815 + ->setViewer($viewer) 816 816 ->setDiffusionRequest($drequest) 817 817 ->setHistory($merges); 818 818 819 819 $panel = id(new PHUIObjectBoxView()) 820 820 ->setHeaderText(pht('Merged Changes')) 821 821 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 822 - ->setTable($history_table); 822 + ->setObjectList($commit_list->newObjectItemListView()); 823 823 if ($caption) { 824 824 $panel->setInfoView($caption); 825 825 }
+1 -19
src/applications/diffusion/controller/DiffusionHistoryController.php
··· 35 35 36 36 $history = $pager->sliceResults($history); 37 37 38 - $identifiers = array(); 39 - foreach ($history as $item) { 40 - $identifiers[] = $item->getCommitIdentifier(); 41 - } 42 - 43 - if ($identifiers) { 44 - $commits = id(new DiffusionCommitQuery()) 45 - ->setViewer($viewer) 46 - ->withRepositoryPHIDs(array($repository->getPHID())) 47 - ->withIdentifiers($identifiers) 48 - ->needCommitData(true) 49 - ->needIdentities(true) 50 - ->execute(); 51 - } else { 52 - $commits = array(); 53 - } 54 - 55 38 $history_list = id(new DiffusionCommitGraphView()) 56 39 ->setViewer($viewer) 57 40 ->setDiffusionRequest($drequest) 58 - ->setHistory($history) 59 - ->setCommits($commits); 41 + ->setHistory($history); 60 42 61 43 // NOTE: If we have a path (like "src/"), many nodes in the graph are 62 44 // likely to be missing (since the path wasn't touched by those commits).
+129 -43
src/applications/diffusion/view/DiffusionCommitGraphView.php
··· 4 4 extends DiffusionView { 5 5 6 6 private $history; 7 - private $commits = array(); 7 + private $commits; 8 8 private $isHead; 9 9 private $isTail; 10 10 private $parents; 11 11 private $filterParents; 12 12 13 - private $commitMap = array(); 13 + private $commitMap; 14 14 private $buildableMap; 15 15 private $revisionMap; 16 16 ··· 27 27 public function setCommits(array $commits) { 28 28 assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 29 29 $this->commits = $commits; 30 - $this->commitMap = mpull($commits, null, 'getCommitIdentifier'); 31 30 return $this; 32 31 } 33 32 ··· 81 80 return $drequest->getRepository(); 82 81 } 83 82 84 - public function render() { 85 - $viewer = $this->getViewer(); 83 + public function newObjectItemListView() { 84 + $list_view = id(new PHUIObjectItemListView()); 85 + 86 + $item_views = $this->newObjectItemViews(); 87 + foreach ($item_views as $item_view) { 88 + $list_view->addItem($item_view); 89 + } 90 + 91 + return $list_view; 92 + } 86 93 94 + private function newObjectItemViews() { 87 95 require_celerity_resource('diffusion-css'); 88 96 89 97 $show_builds = $this->shouldShowBuilds(); 90 98 $show_revisions = $this->shouldShowRevisions(); 91 99 92 - $items = $this->newHistoryItems(); 100 + $views = array(); 93 101 94 - $rows = array(); 95 - $last_date = null; 96 - foreach ($items as $item) { 102 + $items = $this->newHistoryItems(); 103 + foreach ($items as $hash => $item) { 97 104 $content = array(); 98 105 99 - $item_epoch = $item['epoch']; 100 - $item_hash = $item['hash']; 101 106 $commit = $item['commit']; 102 107 103 - $item_date = phabricator_date($item_epoch, $viewer); 104 - if ($item_date !== $last_date) { 105 - $last_date = $item_date; 106 - $content[] = phutil_tag( 107 - 'div', 108 - array( 109 - 'class' => 'diffusion-commit-graph-date-header', 110 - ), 111 - $item_date); 112 - } 113 - 114 108 $commit_description = $this->getCommitDescription($commit); 115 - $commit_link = $this->getCommitURI($item_hash); 109 + $commit_link = $this->getCommitURI($hash); 116 110 117 - $short_hash = $this->getCommitObjectName($item_hash); 111 + $short_hash = $this->getCommitObjectName($hash); 118 112 $is_disabled = $this->getCommitIsDisabled($commit); 119 113 120 114 $author_view = $this->getCommitAuthorView($commit); ··· 129 123 $item_view->addAttribute($author_view); 130 124 } 131 125 132 - $browse_button = $this->newBrowseButton($item_hash); 126 + $browse_button = $this->newBrowseButton($hash); 133 127 134 128 $build_view = null; 135 129 if ($show_builds) { 136 - $build_view = $this->newBuildView($item_hash); 130 + $build_view = $this->newBuildView($hash); 137 131 } 138 132 139 133 $item_view->setSideColumn( ··· 144 138 145 139 $revision_view = null; 146 140 if ($show_revisions) { 147 - $revision_view = $this->newRevisionView($item_hash); 141 + $revision_view = $this->newRevisionView($hash); 148 142 } 149 143 150 144 if ($revision_view !== null) { 151 145 $item_view->addAttribute($revision_view); 152 146 } 153 147 154 - $view = id(new PHUIObjectItemListView()) 155 - ->setFlush(true) 156 - ->addItem($item_view); 148 + $views[$hash] = $item_view; 149 + } 157 150 158 - $content[] = $view; 151 + return $views; 152 + } 153 + 154 + private function newObjectItemRows() { 155 + $viewer = $this->getViewer(); 156 + 157 + $items = $this->newHistoryItems(); 158 + $views = $this->newObjectItemViews(); 159 + 160 + $last_date = null; 161 + $rows = array(); 162 + foreach ($items as $hash => $item) { 163 + $item_epoch = $item['epoch']; 164 + $item_date = phabricator_date($item_epoch, $viewer); 165 + if ($item_date !== $last_date) { 166 + $last_date = $item_date; 167 + $date_view = phutil_tag( 168 + 'div', 169 + array( 170 + 'class' => 'diffusion-commit-graph-date-header', 171 + ), 172 + $item_date); 173 + } else { 174 + $date_view = null; 175 + } 159 176 160 - $rows[] = $content; 177 + $item_view = idx($views, $hash); 178 + if ($item_view) { 179 + $list_view = id(new PHUIObjectItemListView()) 180 + ->setFlush(true) 181 + ->addItem($item_view); 182 + } else { 183 + $list_view = null; 184 + } 185 + 186 + $rows[] = array( 187 + $date_view, 188 + $list_view, 189 + ); 161 190 } 191 + 192 + return $rows; 193 + } 194 + 195 + public function render() { 196 + $rows = $this->newObjectItemRows(); 162 197 163 198 $graph = $this->newGraphView(); 164 199 foreach ($rows as $idx => $row) { ··· 243 278 private function newHistoryItems() { 244 279 $items = array(); 245 280 246 - $commits = $this->getCommits(); 247 - $commit_map = mpull($commits, null, 'getCommitIdentifier'); 248 - 249 281 $history = $this->getHistory(); 250 282 if ($history !== null) { 251 283 foreach ($history as $history_item) { 252 284 $commit_hash = $history_item->getCommitIdentifier(); 253 285 254 - $items[] = array( 286 + $items[$commit_hash] = array( 255 287 'epoch' => $history_item->getEpoch(), 256 288 'hash' => $commit_hash, 257 - 'commit' => idx($commit_map, $commit_hash), 289 + 'commit' => $this->getCommit($commit_hash), 258 290 ); 259 291 } 260 292 } else { 293 + $commits = $this->getCommitMap(); 261 294 foreach ($commits as $commit) { 262 - $items[] = array( 295 + $commit_hash = $commit->getCommitIdentifier(); 296 + 297 + $items[$commit_hash] = array( 263 298 'epoch' => $commit->getEpoch(), 264 - 'hash' => $commit->getCommitIdentifier(), 299 + 'hash' => $commit_hash, 265 300 'commit' => $commit, 266 301 ); 267 302 } ··· 293 328 } 294 329 295 330 $commit = $this->getCommit($hash); 296 - return $commit->getURI(); 331 + if ($commit) { 332 + return $commit->getURI(); 333 + } 334 + 335 + return null; 297 336 } 298 337 299 338 private function getCommitObjectName($hash) { ··· 306 345 } 307 346 308 347 $commit = $this->getCommit($hash); 309 - return $commit->getDisplayName(); 348 + if ($commit) { 349 + return $commit->getDisplayName(); 350 + } 351 + 352 + return null; 310 353 } 311 354 312 355 private function getCommitIsDisabled($commit) { ··· 355 398 } 356 399 357 400 private function getCommitMap() { 401 + if ($this->commitMap === null) { 402 + $commit_list = $this->newCommitList(); 403 + $this->commitMap = mpull($commit_list, null, 'getCommitIdentifier'); 404 + } 405 + 358 406 return $this->commitMap; 359 407 } 360 408 ··· 379 427 380 428 private function getBuildableMap() { 381 429 if ($this->buildableMap === null) { 382 - $commits = $this->getCommits(); 430 + $commits = $this->getCommitMap(); 383 431 $buildables = $this->loadBuildables($commits); 384 432 $this->buildableMap = $buildables; 385 433 } ··· 424 472 425 473 private function newRevisionMap() { 426 474 $viewer = $this->getViewer(); 427 - $commits = $this->getCommits(); 475 + $commits = $this->getCommitMap(); 428 476 429 477 return DiffusionCommitRevisionQuery::loadRevisionMapForCommits( 430 478 $viewer, 431 479 $commits); 480 + } 481 + 482 + private function newCommitList() { 483 + $commits = $this->getCommits(); 484 + if ($commits !== null) { 485 + return $commits; 486 + } 487 + 488 + $repository = $this->getRepository(); 489 + if (!$repository) { 490 + return array(); 491 + } 492 + 493 + $history = $this->getHistory(); 494 + if ($history === null) { 495 + return array(); 496 + } 497 + 498 + $identifiers = array(); 499 + foreach ($history as $item) { 500 + $identifiers[] = $item->getCommitIdentifier(); 501 + } 502 + 503 + if (!$identifiers) { 504 + return array(); 505 + } 506 + 507 + $viewer = $this->getViewer(); 508 + 509 + $commits = id(new DiffusionCommitQuery()) 510 + ->setViewer($viewer) 511 + ->withRepositoryPHIDs(array($repository->getPHID())) 512 + ->withIdentifiers($identifiers) 513 + ->needCommitData(true) 514 + ->needIdentities(true) 515 + ->execute(); 516 + 517 + return $commits; 432 518 } 433 519 434 520 }