From 25656b311a93f0ac5e02f1e21086233416aa9ca0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 30 Oct 2013 13:06:43 -0700 Subject: [PATCH] Clean up Diffusion tag list query a bit Summary: - Use DiffusionCommitQuery. - Use denormalized summary. - Use stronger "Importing" test. Test Plan: Viewed `/diffusion/X/` for repos with tags. Saw tags; saw importing commits marked as "Importing" instead of "Unknown". Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7452 --- .../DiffusionRepositoryController.php | 42 ++++++++++--------- .../view/DiffusionHistoryTableView.php | 2 +- .../diffusion/view/DiffusionTagListView.php | 4 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php index c3d27ac196..2034e55743 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php @@ -225,15 +225,15 @@ final class DiffusionRepositoryController extends DiffusionController { ->withRepositoryIDs(array($drequest->getRepository()->getID())) ->execute(); - $table = new DiffusionBranchTableView(); - $table->setDiffusionRequest($drequest); - $table->setBranches($branches); - $table->setCommits($commits); - $table->setUser($this->getRequest()->getUser()); + $table = id(new DiffusionBranchTableView()) + ->setUser($viewer) + ->setDiffusionRequest($drequest) + ->setBranches($branches) + ->setCommits($commits); - $panel = new AphrontPanelView(); - $panel->setHeader(pht('Branches')); - $panel->setNoBackground(); + $panel = id(new AphrontPanelView()) + ->setHeader(pht('Branches')) + ->setNoBackground(); if ($more_branches) { $panel->setCaption(pht('Showing %d branches.', $limit)); @@ -257,6 +257,8 @@ final class DiffusionRepositoryController extends DiffusionController { } private function buildTagListTable(DiffusionRequest $drequest) { + $viewer = $this->getRequest()->getUser(); + $tag_limit = 15; $tags = array(); try { @@ -281,26 +283,26 @@ final class DiffusionRepositoryController extends DiffusionController { $more_tags = (count($tags) > $tag_limit); $tags = array_slice($tags, 0, $tag_limit); - $commits = id(new PhabricatorAuditCommitQuery()) - ->withIdentifiers( - $drequest->getRepository()->getID(), - mpull($tags, 'getCommitIdentifier')) + $commits = id(new DiffusionCommitQuery()) + ->setViewer($viewer) + ->withIdentifiers(mpull($tags, 'getCommitIdentifier')) + ->withRepositoryIDs(array($drequest->getRepository()->getID())) ->needCommitData(true) ->execute(); - $view = new DiffusionTagListView(); - $view->setDiffusionRequest($drequest); - $view->setTags($tags); - $view->setUser($this->getRequest()->getUser()); - $view->setCommits($commits); + $view = id(new DiffusionTagListView()) + ->setUser($viewer) + ->setDiffusionRequest($drequest) + ->setTags($tags) + ->setCommits($commits); $phids = $view->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $view->setHandles($handles); - $panel = new AphrontPanelView(); - $panel->setHeader(pht('Tags')); - $panel->setNoBackground(true); + $panel = id(new AphrontPanelView()) + ->setHeader(pht('Tags')) + ->setNoBackground(true); if ($more_tags) { $panel->setCaption(pht('Showing the %d most recent tags.', $tag_limit)); diff --git a/src/applications/diffusion/view/DiffusionHistoryTableView.php b/src/applications/diffusion/view/DiffusionHistoryTableView.php index 6cf855da43..cc35e160a6 100644 --- a/src/applications/diffusion/view/DiffusionHistoryTableView.php +++ b/src/applications/diffusion/view/DiffusionHistoryTableView.php @@ -113,7 +113,7 @@ final class DiffusionHistoryTableView extends DiffusionView { } $commit = $history->getCommit(); - if ($commit && !$commit->getIsUnparsed() && $data) { + if ($commit && $commit->isImported() && $data) { $change = $this->linkChange( $history->getChangeType(), $history->getFileType(), diff --git a/src/applications/diffusion/view/DiffusionTagListView.php b/src/applications/diffusion/view/DiffusionTagListView.php index 25e8dd41fb..668453f88e 100644 --- a/src/applications/diffusion/view/DiffusionTagListView.php +++ b/src/applications/diffusion/view/DiffusionTagListView.php @@ -73,8 +73,8 @@ final class DiffusionTagListView extends DiffusionView { // unique data which isn't otherwise available. $description = $tag->getDescription(); } else { - if ($commit && $commit->getCommitData()) { - $description = $commit->getCommitData()->getSummary(); + if ($commit) { + $description = $commit->getSummary(); } else { $description = $tag->getDescription(); }