Page MenuHomePhabricator

D7451.id16781.diff

D7451.id16781.diff

diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php
@@ -197,61 +197,62 @@
}
private function buildBranchListTable(DiffusionRequest $drequest) {
- if ($drequest->getBranch() !== null) {
- $limit = 15;
+ $viewer = $this->getRequest()->getUser();
- $branches = DiffusionBranchInformation::newFromConduit(
- $this->callConduitWithDiffusionRequest(
- 'diffusion.branchquery',
- array(
- 'limit' => $limit
- )));
- if (!$branches) {
- return null;
- }
+ if ($drequest->getBranch() === null) {
+ return null;
+ }
- $more_branches = (count($branches) > $limit);
- $branches = array_slice($branches, 0, $limit);
+ $limit = 15;
- $commits = id(new PhabricatorAuditCommitQuery())
- ->withIdentifiers(
- $drequest->getRepository()->getID(),
- mpull($branches, 'getHeadCommitIdentifier'))
- ->needCommitData(true)
- ->execute();
+ $branches = DiffusionBranchInformation::newFromConduit(
+ $this->callConduitWithDiffusionRequest(
+ 'diffusion.branchquery',
+ array(
+ 'limit' => $limit + 1,
+ )));
+ if (!$branches) {
+ return null;
+ }
- $table = new DiffusionBranchTableView();
- $table->setDiffusionRequest($drequest);
- $table->setBranches($branches);
- $table->setCommits($commits);
- $table->setUser($this->getRequest()->getUser());
+ $more_branches = (count($branches) > $limit);
+ $branches = array_slice($branches, 0, $limit);
- $panel = new AphrontPanelView();
- $panel->setHeader(pht('Branches'));
- $panel->setNoBackground();
+ $commits = id(new DiffusionCommitQuery())
+ ->setViewer($viewer)
+ ->withIdentifiers(mpull($branches, 'getHeadCommitIdentifier'))
+ ->withRepositoryIDs(array($drequest->getRepository()->getID()))
+ ->execute();
- if ($more_branches) {
- $panel->setCaption(pht('Showing %d branches.', $limit));
- }
+ $table = new DiffusionBranchTableView();
+ $table->setDiffusionRequest($drequest);
+ $table->setBranches($branches);
+ $table->setCommits($commits);
+ $table->setUser($this->getRequest()->getUser());
- $panel->addButton(
- phutil_tag(
- 'a',
- array(
- 'href' => $drequest->generateURI(
- array(
- 'action' => 'branches',
- )),
- 'class' => 'grey button',
- ),
- pht("Show All Branches \xC2\xBB")));
-
- $panel->appendChild($table);
+ $panel = new AphrontPanelView();
+ $panel->setHeader(pht('Branches'));
+ $panel->setNoBackground();
- return $panel;
+ if ($more_branches) {
+ $panel->setCaption(pht('Showing %d branches.', $limit));
}
- return null;
+ $panel->addButton(
+ phutil_tag(
+ 'a',
+ array(
+ 'href' => $drequest->generateURI(
+ array(
+ 'action' => 'branches',
+ )),
+ 'class' => 'grey button',
+ ),
+ pht("Show All Branches \xC2\xBB")));
+
+ $panel->appendChild($table);
+
+ return $panel;
}
private function buildTagListTable(DiffusionRequest $drequest) {
diff --git a/src/applications/diffusion/query/DiffusionCommitQuery.php b/src/applications/diffusion/query/DiffusionCommitQuery.php
--- a/src/applications/diffusion/query/DiffusionCommitQuery.php
+++ b/src/applications/diffusion/query/DiffusionCommitQuery.php
@@ -9,6 +9,8 @@
private $defaultRepository;
private $identifierMap;
+ private $needCommitData;
+
/**
* Load commits by partial or full identifiers, e.g. "rXab82393", "rX1234",
* or "a9caf12". When an identifier matches multiple commits, they will all
@@ -34,6 +36,11 @@
return $this;
}
+ public function withRepositoryIDs(array $repository_ids) {
+ $this->repositoryIDs = $repository_ids;
+ return $this;
+ }
+
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
@@ -44,6 +51,11 @@
return $this;
}
+ public function needCommitData($need) {
+ $this->needCommitData = $need;
+ return $this;
+ }
+
public function getIdentifierMap() {
if ($this->identifierMap === null) {
throw new Exception(
@@ -71,7 +83,7 @@
return $table->loadAllFromArray($data);
}
- public function willFilterPage(array $commits) {
+ protected function willFilterPage(array $commits) {
$repository_ids = mpull($commits, 'getRepositoryID', 'getRepositoryID');
$repos = id(new PhabricatorRepositoryQuery())
->setViewer($this->getViewer())
@@ -131,6 +143,22 @@
return $commits;
}
+ protected function didFilterPage(array $commits) {
+
+ if ($this->needCommitData) {
+ $data = id(new PhabricatorRepositoryCommitData())->loadAllWhere(
+ 'commitID in (%Ld)',
+ mpull($commits, 'getID'));
+ $data = mpull($data, null, 'getCommitID');
+ foreach ($commits as $commit) {
+ $commit_data = idx($data, $commit->getID());
+ $commit->attachCommitData($commit_data);
+ }
+ }
+
+ return $commits;
+ }
+
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
@@ -237,6 +265,13 @@
$this->phids);
}
+ if ($this->repositoryIDs) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'repositoryID IN (%Ld)',
+ $this->repositoryIDs);
+ }
+
return $this->formatWhereClause($where);
}
diff --git a/src/applications/diffusion/view/DiffusionBranchTableView.php b/src/applications/diffusion/view/DiffusionBranchTableView.php
--- a/src/applications/diffusion/view/DiffusionBranchTableView.php
+++ b/src/applications/diffusion/view/DiffusionBranchTableView.php
@@ -25,10 +25,7 @@
foreach ($this->branches as $branch) {
$commit = idx($this->commits, $branch->getHeadCommitIdentifier());
if ($commit) {
- $details = $commit->getCommitData()->getCommitMessage();
- $details = idx(explode("\n", $details), 0);
- $details = substr($details, 0, 80);
-
+ $details = $commit->getSummary();
$datetime = phabricator_datetime($commit->getEpoch(), $this->user);
} else {
$datetime = null;
@@ -61,7 +58,6 @@
$branch->getHeadCommitIdentifier()),
$datetime,
AphrontTableView::renderSingleDisplayLine($details),
- // TODO: etc etc
);
if ($branch->getName() == $current_branch) {
$rowc[] = 'highlighted';
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
@@ -81,7 +81,8 @@
$this->getID());
}
- public function attachCommitData(PhabricatorRepositoryCommitData $data) {
+ public function attachCommitData(
+ PhabricatorRepositoryCommitData $data = null) {
$this->commitData = $data;
return $this;
}

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/6a/hz/yacisp2ghtsxgltt
Default Alt Text
D7451.id16781.diff (7 KB)

Event Timeline