mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
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
This commit is contained in:
parent
fc92cf4382
commit
7e8dc0742b
14 changed files with 106 additions and 113 deletions
|
@ -765,6 +765,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitRevisionAcceptedHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php',
|
'DiffusionCommitRevisionAcceptedHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php',
|
||||||
'DiffusionCommitRevisionAcceptingReviewersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionAcceptingReviewersHeraldField.php',
|
'DiffusionCommitRevisionAcceptingReviewersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionAcceptingReviewersHeraldField.php',
|
||||||
'DiffusionCommitRevisionHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionHeraldField.php',
|
'DiffusionCommitRevisionHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionHeraldField.php',
|
||||||
|
'DiffusionCommitRevisionQuery' => 'applications/diffusion/query/DiffusionCommitRevisionQuery.php',
|
||||||
'DiffusionCommitRevisionReviewersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php',
|
'DiffusionCommitRevisionReviewersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php',
|
||||||
'DiffusionCommitRevisionSubscribersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php',
|
'DiffusionCommitRevisionSubscribersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php',
|
||||||
'DiffusionCommitSearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitSearchConduitAPIMethod.php',
|
'DiffusionCommitSearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitSearchConduitAPIMethod.php',
|
||||||
|
@ -6427,6 +6428,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitRevisionAcceptedHeraldField' => 'DiffusionCommitHeraldField',
|
'DiffusionCommitRevisionAcceptedHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
'DiffusionCommitRevisionAcceptingReviewersHeraldField' => 'DiffusionCommitHeraldField',
|
'DiffusionCommitRevisionAcceptingReviewersHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
'DiffusionCommitRevisionHeraldField' => 'DiffusionCommitHeraldField',
|
'DiffusionCommitRevisionHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
|
'DiffusionCommitRevisionQuery' => 'Phobject',
|
||||||
'DiffusionCommitRevisionReviewersHeraldField' => 'DiffusionCommitHeraldField',
|
'DiffusionCommitRevisionReviewersHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
'DiffusionCommitRevisionSubscribersHeraldField' => 'DiffusionCommitHeraldField',
|
'DiffusionCommitRevisionSubscribersHeraldField' => 'DiffusionCommitHeraldField',
|
||||||
'DiffusionCommitSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
'DiffusionCommitSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||||
|
|
|
@ -158,18 +158,6 @@ final class DifferentialRevision extends DifferentialDAO
|
||||||
return '/'.$this->getMonogram();
|
return '/'.$this->getMonogram();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadIDsByCommitPHIDs($phids) {
|
|
||||||
if (!$phids) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
$revision_ids = queryfx_all(
|
|
||||||
$this->establishConnection('r'),
|
|
||||||
'SELECT * FROM %T WHERE commitPHID IN (%Ls)',
|
|
||||||
self::TABLE_COMMIT,
|
|
||||||
$phids);
|
|
||||||
return ipull($revision_ids, 'revisionID', 'commitPHID');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function loadCommitPHIDs() {
|
public function loadCommitPHIDs() {
|
||||||
if (!$this->getID()) {
|
if (!$this->getID()) {
|
||||||
return ($this->commits = array());
|
return ($this->commits = array());
|
||||||
|
|
|
@ -36,7 +36,9 @@ final class DiffusionBlameController extends DiffusionController {
|
||||||
|
|
||||||
$commit_map = mpull($commits, 'getCommitIdentifier', 'getPHID');
|
$commit_map = mpull($commits, 'getCommitIdentifier', 'getPHID');
|
||||||
|
|
||||||
$revision_map = $this->loadRevisionsForCommits($commits);
|
$revision_map = DiffusionCommitRevisionQuery::loadRevisionMapForCommits(
|
||||||
|
$viewer,
|
||||||
|
$commits);
|
||||||
|
|
||||||
$base_href = (string)$drequest->generateURI(
|
$base_href = (string)$drequest->generateURI(
|
||||||
array(
|
array(
|
||||||
|
@ -267,45 +269,4 @@ final class DiffusionBlameController extends DiffusionController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadRevisionsForCommits(array $commits) {
|
|
||||||
if (!$commits) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$commit_phids = mpull($commits, 'getPHID');
|
|
||||||
|
|
||||||
$edge_query = id(new PhabricatorEdgeQuery())
|
|
||||||
->withSourcePHIDs($commit_phids)
|
|
||||||
->withEdgeTypes(
|
|
||||||
array(
|
|
||||||
DiffusionCommitHasRevisionEdgeType::EDGECONST,
|
|
||||||
));
|
|
||||||
$edge_query->execute();
|
|
||||||
|
|
||||||
$revision_phids = $edge_query->getDestinationPHIDs();
|
|
||||||
if (!$revision_phids) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$viewer = $this->getViewer();
|
|
||||||
|
|
||||||
$revisions = id(new DifferentialRevisionQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withPHIDs($revision_phids)
|
|
||||||
->execute();
|
|
||||||
$revisions = mpull($revisions, null, 'getPHID');
|
|
||||||
|
|
||||||
$map = array();
|
|
||||||
foreach ($commit_phids as $commit_phid) {
|
|
||||||
$revision_phids = $edge_query->getDestinationPHIDs(
|
|
||||||
array(
|
|
||||||
$commit_phid,
|
|
||||||
));
|
|
||||||
|
|
||||||
$map[$commit_phid] = array_select_keys($revisions, $revision_phids);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $map;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1106,11 +1106,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
$history_table = id(new DiffusionHistoryTableView())
|
$history_table = id(new DiffusionHistoryTableView())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->setDiffusionRequest($drequest)
|
->setDiffusionRequest($drequest)
|
||||||
->setHistory($history);
|
->setHistory($history)
|
||||||
|
|
||||||
$history_table->loadRevisions();
|
|
||||||
|
|
||||||
$history_table
|
|
||||||
->setParents($results['parents'])
|
->setParents($results['parents'])
|
||||||
->setFilterParents(true)
|
->setFilterParents(true)
|
||||||
->setIsHead(true)
|
->setIsHead(true)
|
||||||
|
|
|
@ -807,8 +807,6 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
->setDiffusionRequest($drequest)
|
->setDiffusionRequest($drequest)
|
||||||
->setHistory($merges);
|
->setHistory($merges);
|
||||||
|
|
||||||
$history_table->loadRevisions();
|
|
||||||
|
|
||||||
$panel = id(new PHUIObjectBoxView())
|
$panel = id(new PHUIObjectBoxView())
|
||||||
->setHeaderText(pht('Merged Changes'))
|
->setHeaderText(pht('Merged Changes'))
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
|
|
|
@ -299,11 +299,7 @@ final class DiffusionCompareController extends DiffusionController {
|
||||||
$history_table = id(new DiffusionHistoryTableView())
|
$history_table = id(new DiffusionHistoryTableView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setDiffusionRequest($drequest)
|
->setDiffusionRequest($drequest)
|
||||||
->setHistory($history);
|
->setHistory($history)
|
||||||
|
|
||||||
$history_table->loadRevisions();
|
|
||||||
|
|
||||||
$history_table
|
|
||||||
->setParents($results['parents'])
|
->setParents($results['parents'])
|
||||||
->setFilterParents(true)
|
->setFilterParents(true)
|
||||||
->setIsHead(!$pager->getOffset())
|
->setIsHead(!$pager->getOffset())
|
||||||
|
|
|
@ -40,7 +40,6 @@ final class DiffusionGraphController extends DiffusionController {
|
||||||
->setDiffusionRequest($drequest)
|
->setDiffusionRequest($drequest)
|
||||||
->setHistory($history);
|
->setHistory($history);
|
||||||
|
|
||||||
$graph->loadRevisions();
|
|
||||||
$show_graph = !strlen($drequest->getPath());
|
$show_graph = !strlen($drequest->getPath());
|
||||||
if ($show_graph) {
|
if ($show_graph) {
|
||||||
$graph->setParents($history_results['parents']);
|
$graph->setParents($history_results['parents']);
|
||||||
|
|
|
@ -40,7 +40,6 @@ final class DiffusionHistoryController extends DiffusionController {
|
||||||
->setDiffusionRequest($drequest)
|
->setDiffusionRequest($drequest)
|
||||||
->setHistory($history);
|
->setHistory($history);
|
||||||
|
|
||||||
$history_list->loadRevisions();
|
|
||||||
$header = $this->buildHeader($drequest);
|
$header = $this->buildHeader($drequest);
|
||||||
|
|
||||||
$crumbs = $this->buildCrumbs(
|
$crumbs = $this->buildCrumbs(
|
||||||
|
|
|
@ -440,17 +440,13 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
$history_table = id(new DiffusionHistoryTableView())
|
$history_table = id(new DiffusionHistoryTableView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setDiffusionRequest($drequest)
|
->setDiffusionRequest($drequest)
|
||||||
->setHistory($history);
|
->setHistory($history)
|
||||||
|
->setIsHead(true);
|
||||||
// TODO: Super sketchy.
|
|
||||||
$history_table->loadRevisions();
|
|
||||||
|
|
||||||
if ($history_results) {
|
if ($history_results) {
|
||||||
$history_table->setParents($history_results['parents']);
|
$history_table->setParents($history_results['parents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$history_table->setIsHead(true);
|
|
||||||
|
|
||||||
$panel = id(new PHUIObjectBoxView())
|
$panel = id(new PHUIObjectBoxView())
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
->addClass('diffusion-mobile-view');
|
->addClass('diffusion-mobile-view');
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionCommitRevisionQuery
|
||||||
|
extends Phobject {
|
||||||
|
|
||||||
|
public static function loadRevisionMapForCommits(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
array $commits) {
|
||||||
|
assert_instances_of($commits, 'PhabricatorRepositoryCommit');
|
||||||
|
|
||||||
|
if (!$commits) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$commit_phids = mpull($commits, 'getPHID');
|
||||||
|
|
||||||
|
$edge_query = id(new PhabricatorEdgeQuery())
|
||||||
|
->withSourcePHIDs($commit_phids)
|
||||||
|
->withEdgeTypes(
|
||||||
|
array(
|
||||||
|
DiffusionCommitHasRevisionEdgeType::EDGECONST,
|
||||||
|
));
|
||||||
|
$edge_query->execute();
|
||||||
|
|
||||||
|
$revision_phids = $edge_query->getDestinationPHIDs();
|
||||||
|
if (!$revision_phids) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$revisions = id(new DifferentialRevisionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withPHIDs($revision_phids)
|
||||||
|
->execute();
|
||||||
|
$revisions = mpull($revisions, null, 'getPHID');
|
||||||
|
|
||||||
|
$map = array();
|
||||||
|
foreach ($commit_phids as $commit_phid) {
|
||||||
|
$revision_phids = $edge_query->getDestinationPHIDs(
|
||||||
|
array(
|
||||||
|
$commit_phid,
|
||||||
|
));
|
||||||
|
|
||||||
|
$map[$commit_phid] = array_select_keys($revisions, $revision_phids);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $map;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -104,16 +104,17 @@ final class DiffusionHistoryListView extends DiffusionHistoryView {
|
||||||
|
|
||||||
$diff_tag = null;
|
$diff_tag = null;
|
||||||
if ($show_revisions && $commit) {
|
if ($show_revisions && $commit) {
|
||||||
$d_id = idx($this->getRevisions(), $commit->getPHID());
|
$revisions = $this->getRevisionsForCommit($commit);
|
||||||
if ($d_id) {
|
if ($revisions) {
|
||||||
|
$revision = head($revisions);
|
||||||
$diff_tag = id(new PHUITagView())
|
$diff_tag = id(new PHUITagView())
|
||||||
->setName('D'.$d_id)
|
->setName($revision->getMonogram())
|
||||||
->setType(PHUITagView::TYPE_SHADE)
|
->setType(PHUITagView::TYPE_SHADE)
|
||||||
->setColor(PHUITagView::COLOR_BLUE)
|
->setColor(PHUITagView::COLOR_BLUE)
|
||||||
->setHref('/D'.$d_id)
|
->setHref($revision->getURI())
|
||||||
->setBorder(PHUITagView::BORDER_NONE)
|
->setBorder(PHUITagView::BORDER_NONE)
|
||||||
->setSlimShady(true);
|
->setSlimShady(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$build_view = null;
|
$build_view = null;
|
||||||
|
|
|
@ -127,6 +127,20 @@ final class DiffusionHistoryTableView extends DiffusionHistoryView {
|
||||||
'tip' => $name,
|
'tip' => $name,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$revision_link = null;
|
||||||
|
if ($commit) {
|
||||||
|
$revisions = $this->getRevisionsForCommit($commit);
|
||||||
|
if ($revisions) {
|
||||||
|
$revision = head($revisions);
|
||||||
|
$revision_link = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $revision->getURI(),
|
||||||
|
),
|
||||||
|
$revision->getMonogram());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
$graph ? $graph[$ii++] : null,
|
$graph ? $graph[$ii++] : null,
|
||||||
$browse,
|
$browse,
|
||||||
|
@ -135,9 +149,7 @@ final class DiffusionHistoryTableView extends DiffusionHistoryView {
|
||||||
$history->getCommitIdentifier()),
|
$history->getCommitIdentifier()),
|
||||||
$build,
|
$build,
|
||||||
$audit_view,
|
$audit_view,
|
||||||
($commit ?
|
$revision_link,
|
||||||
self::linkRevision(idx($this->getRevisions(), $commit->getPHID())) :
|
|
||||||
null),
|
|
||||||
$author,
|
$author,
|
||||||
$summary,
|
$summary,
|
||||||
$committed,
|
$committed,
|
||||||
|
|
|
@ -9,6 +9,7 @@ abstract class DiffusionHistoryView extends DiffusionView {
|
||||||
private $isTail;
|
private $isTail;
|
||||||
private $parents;
|
private $parents;
|
||||||
private $filterParents;
|
private $filterParents;
|
||||||
|
private $revisionMap;
|
||||||
|
|
||||||
public function setHistory(array $history) {
|
public function setHistory(array $history) {
|
||||||
assert_instances_of($history, 'DiffusionPathChange');
|
assert_instances_of($history, 'DiffusionPathChange');
|
||||||
|
@ -20,24 +21,6 @@ abstract class DiffusionHistoryView extends DiffusionView {
|
||||||
return $this->history;
|
return $this->history;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadRevisions() {
|
|
||||||
$commit_phids = array();
|
|
||||||
foreach ($this->history as $item) {
|
|
||||||
if ($item->getCommit()) {
|
|
||||||
$commit_phids[] = $item->getCommit()->getPHID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Get rid of this.
|
|
||||||
$this->revisions = id(new DifferentialRevision())
|
|
||||||
->loadIDsByCommitPHIDs($commit_phids);
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRevisions() {
|
|
||||||
return $this->revisions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setHandles(array $handles) {
|
public function setHandles(array $handles) {
|
||||||
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
||||||
$this->handles = $handles;
|
$this->handles = $handles;
|
||||||
|
@ -98,4 +81,30 @@ abstract class DiffusionHistoryView extends DiffusionView {
|
||||||
|
|
||||||
public function render() {}
|
public function render() {}
|
||||||
|
|
||||||
|
final protected function getRevisionsForCommit(
|
||||||
|
PhabricatorRepositoryCommit $commit) {
|
||||||
|
|
||||||
|
if ($this->revisionMap === null) {
|
||||||
|
$this->revisionMap = $this->newRevisionMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
return idx($this->revisionMap, $commit->getPHID(), array());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function newRevisionMap() {
|
||||||
|
$history = $this->history;
|
||||||
|
|
||||||
|
$commits = array();
|
||||||
|
foreach ($history as $item) {
|
||||||
|
$commit = $item->getCommit();
|
||||||
|
if ($commit) {
|
||||||
|
$commits[] = $commit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DiffusionCommitRevisionQuery::loadRevisionMapForCommits(
|
||||||
|
$this->getViewer(),
|
||||||
|
$commits);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,19 +169,6 @@ abstract class DiffusionView extends AphrontView {
|
||||||
$detail);
|
$detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public static function linkRevision($id) {
|
|
||||||
if (!$id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return phutil_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => "/D{$id}",
|
|
||||||
),
|
|
||||||
"D{$id}");
|
|
||||||
}
|
|
||||||
|
|
||||||
final public static function renderName($name) {
|
final public static function renderName($name) {
|
||||||
$email = new PhutilEmailAddress($name);
|
$email = new PhutilEmailAddress($name);
|
||||||
if ($email->getDisplayName() && $email->getDomainName()) {
|
if ($email->getDisplayName() && $email->getDomainName()) {
|
||||||
|
|
Loading…
Reference in a new issue