mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Display revision number in history
Test Plan: Displayed repository. Displayed repository history. Wondered that we actually have bunch of commits without a revision. Displayed blame. Didn't display merge commit. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D2840
This commit is contained in:
parent
969dcc5bae
commit
d7b8bc892b
7 changed files with 52 additions and 13 deletions
|
@ -69,6 +69,18 @@ final class DifferentialRevision extends DifferentialDAO {
|
|||
return $this;
|
||||
}
|
||||
|
||||
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() {
|
||||
if (!$this->getID()) {
|
||||
return ($this->commits = array());
|
||||
|
|
|
@ -388,20 +388,13 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
|||
$commits = mpull($commits, null, 'getCommitIdentifier');
|
||||
}
|
||||
|
||||
$revision_ids = array();
|
||||
$revision_ids = id(new DifferentialRevision())
|
||||
->loadIDsByCommitPHIDs(mpull($commits, 'getPHID'));
|
||||
$revisions = array();
|
||||
if ($commits) {
|
||||
$revision_ids = queryfx_all(
|
||||
id(new DifferentialRevision())->establishConnection('r'),
|
||||
'SELECT * FROM %T WHERE commitPHID IN (%Ls)',
|
||||
DifferentialRevision::TABLE_COMMIT,
|
||||
mpull($commits, 'getPHID'));
|
||||
if ($revision_ids) {
|
||||
$revision_ids = ipull($revision_ids, 'revisionID', 'commitPHID');
|
||||
$revisions = id(new DifferentialRevision())->loadAllWhere(
|
||||
'id IN (%Ld)',
|
||||
$revision_ids);
|
||||
}
|
||||
if ($revision_ids) {
|
||||
$revisions = id(new DifferentialRevision())->loadAllWhere(
|
||||
'id IN (%Ld)',
|
||||
$revision_ids);
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
|
|
@ -682,6 +682,7 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
$history_table = new DiffusionHistoryTableView();
|
||||
$history_table->setDiffusionRequest($drequest);
|
||||
$history_table->setHistory($merges);
|
||||
$history_table->loadRevisions();
|
||||
|
||||
$phids = $history_table->getRequiredHandlePHIDs();
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
|
|
|
@ -81,6 +81,7 @@ final class DiffusionHistoryController extends DiffusionController {
|
|||
$history_table = new DiffusionHistoryTableView();
|
||||
$history_table->setDiffusionRequest($drequest);
|
||||
$history_table->setHistory($history);
|
||||
$history_table->loadRevisions();
|
||||
|
||||
$phids = $history_table->getRequiredHandlePHIDs();
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
|
|
|
@ -70,6 +70,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
$history_table->setDiffusionRequest($drequest);
|
||||
$history_table->setHandles($handles);
|
||||
$history_table->setHistory($history);
|
||||
$history_table->loadRevisions();
|
||||
$history_table->setParents($history_query->getParents());
|
||||
$history_table->setIsHead(true);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
final class DiffusionHistoryTableView extends DiffusionView {
|
||||
|
||||
private $history;
|
||||
private $revisions = array();
|
||||
private $handles = array();
|
||||
private $isHead;
|
||||
private $parents;
|
||||
|
@ -29,6 +30,18 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function loadRevisions() {
|
||||
$commit_phids = array();
|
||||
foreach ($this->history as $item) {
|
||||
if ($item->getCommit()) {
|
||||
$commit_phids[] = $item->getCommit()->getPHID();
|
||||
}
|
||||
}
|
||||
$this->revisions = id(new DifferentialRevision())
|
||||
->loadIDsByCommitPHIDs($commit_phids);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
||||
$this->handles = $handles;
|
||||
|
@ -134,6 +147,9 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
|||
self::linkCommit(
|
||||
$drequest->getRepository(),
|
||||
$history->getCommitIdentifier()),
|
||||
($commit ?
|
||||
self::linkRevision(idx($this->revisions, $commit->getPHID())) :
|
||||
null),
|
||||
$change,
|
||||
$date,
|
||||
$time,
|
||||
|
@ -150,6 +166,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
|||
'Browse',
|
||||
'',
|
||||
'Commit',
|
||||
'Revision',
|
||||
'Change',
|
||||
'Date',
|
||||
'Time',
|
||||
|
@ -161,6 +178,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
|||
'',
|
||||
'threads',
|
||||
'n',
|
||||
'n',
|
||||
'',
|
||||
'',
|
||||
'right',
|
||||
|
|
|
@ -134,4 +134,17 @@ abstract class DiffusionView extends AphrontView {
|
|||
$commit_name);
|
||||
}
|
||||
|
||||
final public static function linkRevision($id) {
|
||||
if (!$id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => "/D{$id}",
|
||||
),
|
||||
"D{$id}");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue