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

Remove all callers to "DifferentialRevision->loadIDsByCommitPHIDs()"

Summary: Depends on D20457. Ref T13276. Kill all remaining callers to this method and delete it.

Test Plan:
- Grepped for `loadIDsByCommitPHIDs`.
- Viewed blame again to make sure I didn't break it.
- Viewed "History" view for commits with revisions.
- Viewed "Graph" view for commits with revisions.
- Viewed "Merged Commits" table for commits with revisions.
- Viewed "Compare" table for commits with revisions.
- Viewed "Repository" main page history table for commits with revisions.
- Grepped for `linkRevision`.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13276

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

+106 -113
+2
src/__phutil_library_map__.php
··· 765 765 'DiffusionCommitRevisionAcceptedHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php', 766 766 'DiffusionCommitRevisionAcceptingReviewersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionAcceptingReviewersHeraldField.php', 767 767 'DiffusionCommitRevisionHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionHeraldField.php', 768 + 'DiffusionCommitRevisionQuery' => 'applications/diffusion/query/DiffusionCommitRevisionQuery.php', 768 769 'DiffusionCommitRevisionReviewersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php', 769 770 'DiffusionCommitRevisionSubscribersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php', 770 771 'DiffusionCommitSearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitSearchConduitAPIMethod.php', ··· 6427 6428 'DiffusionCommitRevisionAcceptedHeraldField' => 'DiffusionCommitHeraldField', 6428 6429 'DiffusionCommitRevisionAcceptingReviewersHeraldField' => 'DiffusionCommitHeraldField', 6429 6430 'DiffusionCommitRevisionHeraldField' => 'DiffusionCommitHeraldField', 6431 + 'DiffusionCommitRevisionQuery' => 'Phobject', 6430 6432 'DiffusionCommitRevisionReviewersHeraldField' => 'DiffusionCommitHeraldField', 6431 6433 'DiffusionCommitRevisionSubscribersHeraldField' => 'DiffusionCommitHeraldField', 6432 6434 'DiffusionCommitSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
-12
src/applications/differential/storage/DifferentialRevision.php
··· 158 158 return '/'.$this->getMonogram(); 159 159 } 160 160 161 - public function loadIDsByCommitPHIDs($phids) { 162 - if (!$phids) { 163 - return array(); 164 - } 165 - $revision_ids = queryfx_all( 166 - $this->establishConnection('r'), 167 - 'SELECT * FROM %T WHERE commitPHID IN (%Ls)', 168 - self::TABLE_COMMIT, 169 - $phids); 170 - return ipull($revision_ids, 'revisionID', 'commitPHID'); 171 - } 172 - 173 161 public function loadCommitPHIDs() { 174 162 if (!$this->getID()) { 175 163 return ($this->commits = array());
+3 -42
src/applications/diffusion/controller/DiffusionBlameController.php
··· 36 36 37 37 $commit_map = mpull($commits, 'getCommitIdentifier', 'getPHID'); 38 38 39 - $revision_map = $this->loadRevisionsForCommits($commits); 39 + $revision_map = DiffusionCommitRevisionQuery::loadRevisionMapForCommits( 40 + $viewer, 41 + $commits); 40 42 41 43 $base_href = (string)$drequest->generateURI( 42 44 array( ··· 265 267 } else { 266 268 return "{$summary}\n{$date}"; 267 269 } 268 - } 269 - 270 - private function loadRevisionsForCommits(array $commits) { 271 - if (!$commits) { 272 - return array(); 273 - } 274 - 275 - $commit_phids = mpull($commits, 'getPHID'); 276 - 277 - $edge_query = id(new PhabricatorEdgeQuery()) 278 - ->withSourcePHIDs($commit_phids) 279 - ->withEdgeTypes( 280 - array( 281 - DiffusionCommitHasRevisionEdgeType::EDGECONST, 282 - )); 283 - $edge_query->execute(); 284 - 285 - $revision_phids = $edge_query->getDestinationPHIDs(); 286 - if (!$revision_phids) { 287 - return array(); 288 - } 289 - 290 - $viewer = $this->getViewer(); 291 - 292 - $revisions = id(new DifferentialRevisionQuery()) 293 - ->setViewer($viewer) 294 - ->withPHIDs($revision_phids) 295 - ->execute(); 296 - $revisions = mpull($revisions, null, 'getPHID'); 297 - 298 - $map = array(); 299 - foreach ($commit_phids as $commit_phid) { 300 - $revision_phids = $edge_query->getDestinationPHIDs( 301 - array( 302 - $commit_phid, 303 - )); 304 - 305 - $map[$commit_phid] = array_select_keys($revisions, $revision_phids); 306 - } 307 - 308 - return $map; 309 270 } 310 271 311 272 }
+1 -5
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 1106 1106 $history_table = id(new DiffusionHistoryTableView()) 1107 1107 ->setViewer($viewer) 1108 1108 ->setDiffusionRequest($drequest) 1109 - ->setHistory($history); 1110 - 1111 - $history_table->loadRevisions(); 1112 - 1113 - $history_table 1109 + ->setHistory($history) 1114 1110 ->setParents($results['parents']) 1115 1111 ->setFilterParents(true) 1116 1112 ->setIsHead(true)
-2
src/applications/diffusion/controller/DiffusionCommitController.php
··· 807 807 ->setDiffusionRequest($drequest) 808 808 ->setHistory($merges); 809 809 810 - $history_table->loadRevisions(); 811 - 812 810 $panel = id(new PHUIObjectBoxView()) 813 811 ->setHeaderText(pht('Merged Changes')) 814 812 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
+1 -5
src/applications/diffusion/controller/DiffusionCompareController.php
··· 299 299 $history_table = id(new DiffusionHistoryTableView()) 300 300 ->setUser($viewer) 301 301 ->setDiffusionRequest($drequest) 302 - ->setHistory($history); 303 - 304 - $history_table->loadRevisions(); 305 - 306 - $history_table 302 + ->setHistory($history) 307 303 ->setParents($results['parents']) 308 304 ->setFilterParents(true) 309 305 ->setIsHead(!$pager->getOffset())
-1
src/applications/diffusion/controller/DiffusionGraphController.php
··· 40 40 ->setDiffusionRequest($drequest) 41 41 ->setHistory($history); 42 42 43 - $graph->loadRevisions(); 44 43 $show_graph = !strlen($drequest->getPath()); 45 44 if ($show_graph) { 46 45 $graph->setParents($history_results['parents']);
-1
src/applications/diffusion/controller/DiffusionHistoryController.php
··· 40 40 ->setDiffusionRequest($drequest) 41 41 ->setHistory($history); 42 42 43 - $history_list->loadRevisions(); 44 43 $header = $this->buildHeader($drequest); 45 44 46 45 $crumbs = $this->buildCrumbs(
+2 -6
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 440 440 $history_table = id(new DiffusionHistoryTableView()) 441 441 ->setUser($viewer) 442 442 ->setDiffusionRequest($drequest) 443 - ->setHistory($history); 444 - 445 - // TODO: Super sketchy. 446 - $history_table->loadRevisions(); 443 + ->setHistory($history) 444 + ->setIsHead(true); 447 445 448 446 if ($history_results) { 449 447 $history_table->setParents($history_results['parents']); 450 448 } 451 - 452 - $history_table->setIsHead(true); 453 449 454 450 $panel = id(new PHUIObjectBoxView()) 455 451 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
+49
src/applications/diffusion/query/DiffusionCommitRevisionQuery.php
··· 1 + <?php 2 + 3 + final class DiffusionCommitRevisionQuery 4 + extends Phobject { 5 + 6 + public static function loadRevisionMapForCommits( 7 + PhabricatorUser $viewer, 8 + array $commits) { 9 + assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 10 + 11 + if (!$commits) { 12 + return array(); 13 + } 14 + 15 + $commit_phids = mpull($commits, 'getPHID'); 16 + 17 + $edge_query = id(new PhabricatorEdgeQuery()) 18 + ->withSourcePHIDs($commit_phids) 19 + ->withEdgeTypes( 20 + array( 21 + DiffusionCommitHasRevisionEdgeType::EDGECONST, 22 + )); 23 + $edge_query->execute(); 24 + 25 + $revision_phids = $edge_query->getDestinationPHIDs(); 26 + if (!$revision_phids) { 27 + return array(); 28 + } 29 + 30 + $revisions = id(new DifferentialRevisionQuery()) 31 + ->setViewer($viewer) 32 + ->withPHIDs($revision_phids) 33 + ->execute(); 34 + $revisions = mpull($revisions, null, 'getPHID'); 35 + 36 + $map = array(); 37 + foreach ($commit_phids as $commit_phid) { 38 + $revision_phids = $edge_query->getDestinationPHIDs( 39 + array( 40 + $commit_phid, 41 + )); 42 + 43 + $map[$commit_phid] = array_select_keys($revisions, $revision_phids); 44 + } 45 + 46 + return $map; 47 + } 48 + 49 + }
+6 -5
src/applications/diffusion/view/DiffusionHistoryListView.php
··· 104 104 105 105 $diff_tag = null; 106 106 if ($show_revisions && $commit) { 107 - $d_id = idx($this->getRevisions(), $commit->getPHID()); 108 - if ($d_id) { 107 + $revisions = $this->getRevisionsForCommit($commit); 108 + if ($revisions) { 109 + $revision = head($revisions); 109 110 $diff_tag = id(new PHUITagView()) 110 - ->setName('D'.$d_id) 111 + ->setName($revision->getMonogram()) 111 112 ->setType(PHUITagView::TYPE_SHADE) 112 113 ->setColor(PHUITagView::COLOR_BLUE) 113 - ->setHref('/D'.$d_id) 114 + ->setHref($revision->getURI()) 114 115 ->setBorder(PHUITagView::BORDER_NONE) 115 116 ->setSlimShady(true); 116 - } 117 + } 117 118 } 118 119 119 120 $build_view = null;
+15 -3
src/applications/diffusion/view/DiffusionHistoryTableView.php
··· 127 127 'tip' => $name, 128 128 )); 129 129 130 + $revision_link = null; 131 + if ($commit) { 132 + $revisions = $this->getRevisionsForCommit($commit); 133 + if ($revisions) { 134 + $revision = head($revisions); 135 + $revision_link = phutil_tag( 136 + 'a', 137 + array( 138 + 'href' => $revision->getURI(), 139 + ), 140 + $revision->getMonogram()); 141 + } 142 + } 143 + 130 144 $rows[] = array( 131 145 $graph ? $graph[$ii++] : null, 132 146 $browse, ··· 135 149 $history->getCommitIdentifier()), 136 150 $build, 137 151 $audit_view, 138 - ($commit ? 139 - self::linkRevision(idx($this->getRevisions(), $commit->getPHID())) : 140 - null), 152 + $revision_link, 141 153 $author, 142 154 $summary, 143 155 $committed,
+27 -18
src/applications/diffusion/view/DiffusionHistoryView.php
··· 9 9 private $isTail; 10 10 private $parents; 11 11 private $filterParents; 12 + private $revisionMap; 12 13 13 14 public function setHistory(array $history) { 14 15 assert_instances_of($history, 'DiffusionPathChange'); ··· 18 19 19 20 public function getHistory() { 20 21 return $this->history; 21 - } 22 - 23 - public function loadRevisions() { 24 - $commit_phids = array(); 25 - foreach ($this->history as $item) { 26 - if ($item->getCommit()) { 27 - $commit_phids[] = $item->getCommit()->getPHID(); 28 - } 29 - } 30 - 31 - // TODO: Get rid of this. 32 - $this->revisions = id(new DifferentialRevision()) 33 - ->loadIDsByCommitPHIDs($commit_phids); 34 - return $this; 35 - } 36 - 37 - public function getRevisions() { 38 - return $this->revisions; 39 22 } 40 23 41 24 public function setHandles(array $handles) { ··· 97 80 } 98 81 99 82 public function render() {} 83 + 84 + final protected function getRevisionsForCommit( 85 + PhabricatorRepositoryCommit $commit) { 86 + 87 + if ($this->revisionMap === null) { 88 + $this->revisionMap = $this->newRevisionMap(); 89 + } 90 + 91 + return idx($this->revisionMap, $commit->getPHID(), array()); 92 + } 93 + 94 + private function newRevisionMap() { 95 + $history = $this->history; 96 + 97 + $commits = array(); 98 + foreach ($history as $item) { 99 + $commit = $item->getCommit(); 100 + if ($commit) { 101 + $commits[] = $commit; 102 + } 103 + } 104 + 105 + return DiffusionCommitRevisionQuery::loadRevisionMapForCommits( 106 + $this->getViewer(), 107 + $commits); 108 + } 100 109 101 110 }
-13
src/applications/diffusion/view/DiffusionView.php
··· 169 169 $detail); 170 170 } 171 171 172 - final public static function linkRevision($id) { 173 - if (!$id) { 174 - return null; 175 - } 176 - 177 - return phutil_tag( 178 - 'a', 179 - array( 180 - 'href' => "/D{$id}", 181 - ), 182 - "D{$id}"); 183 - } 184 - 185 172 final public static function renderName($name) { 186 173 $email = new PhutilEmailAddress($name); 187 174 if ($email->getDisplayName() && $email->getDomainName()) {