mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-03 19:31:02 +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;
|
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() {
|
public function loadCommitPHIDs() {
|
||||||
if (!$this->getID()) {
|
if (!$this->getID()) {
|
||||||
return ($this->commits = array());
|
return ($this->commits = array());
|
||||||
|
|
|
@ -388,21 +388,14 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
||||||
$commits = mpull($commits, null, 'getCommitIdentifier');
|
$commits = mpull($commits, null, 'getCommitIdentifier');
|
||||||
}
|
}
|
||||||
|
|
||||||
$revision_ids = array();
|
$revision_ids = id(new DifferentialRevision())
|
||||||
|
->loadIDsByCommitPHIDs(mpull($commits, 'getPHID'));
|
||||||
$revisions = array();
|
$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) {
|
if ($revision_ids) {
|
||||||
$revision_ids = ipull($revision_ids, 'revisionID', 'commitPHID');
|
|
||||||
$revisions = id(new DifferentialRevision())->loadAllWhere(
|
$revisions = id(new DifferentialRevision())->loadAllWhere(
|
||||||
'id IN (%Ld)',
|
'id IN (%Ld)',
|
||||||
$revision_ids);
|
$revision_ids);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
|
@ -682,6 +682,7 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
$history_table = new DiffusionHistoryTableView();
|
$history_table = new DiffusionHistoryTableView();
|
||||||
$history_table->setDiffusionRequest($drequest);
|
$history_table->setDiffusionRequest($drequest);
|
||||||
$history_table->setHistory($merges);
|
$history_table->setHistory($merges);
|
||||||
|
$history_table->loadRevisions();
|
||||||
|
|
||||||
$phids = $history_table->getRequiredHandlePHIDs();
|
$phids = $history_table->getRequiredHandlePHIDs();
|
||||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||||
|
|
|
@ -81,6 +81,7 @@ final class DiffusionHistoryController extends DiffusionController {
|
||||||
$history_table = new DiffusionHistoryTableView();
|
$history_table = new DiffusionHistoryTableView();
|
||||||
$history_table->setDiffusionRequest($drequest);
|
$history_table->setDiffusionRequest($drequest);
|
||||||
$history_table->setHistory($history);
|
$history_table->setHistory($history);
|
||||||
|
$history_table->loadRevisions();
|
||||||
|
|
||||||
$phids = $history_table->getRequiredHandlePHIDs();
|
$phids = $history_table->getRequiredHandlePHIDs();
|
||||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||||
|
|
|
@ -70,6 +70,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
$history_table->setDiffusionRequest($drequest);
|
$history_table->setDiffusionRequest($drequest);
|
||||||
$history_table->setHandles($handles);
|
$history_table->setHandles($handles);
|
||||||
$history_table->setHistory($history);
|
$history_table->setHistory($history);
|
||||||
|
$history_table->loadRevisions();
|
||||||
$history_table->setParents($history_query->getParents());
|
$history_table->setParents($history_query->getParents());
|
||||||
$history_table->setIsHead(true);
|
$history_table->setIsHead(true);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
final class DiffusionHistoryTableView extends DiffusionView {
|
final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
|
|
||||||
private $history;
|
private $history;
|
||||||
|
private $revisions = array();
|
||||||
private $handles = array();
|
private $handles = array();
|
||||||
private $isHead;
|
private $isHead;
|
||||||
private $parents;
|
private $parents;
|
||||||
|
@ -29,6 +30,18 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
return $this;
|
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) {
|
public function setHandles(array $handles) {
|
||||||
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
||||||
$this->handles = $handles;
|
$this->handles = $handles;
|
||||||
|
@ -134,6 +147,9 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
self::linkCommit(
|
self::linkCommit(
|
||||||
$drequest->getRepository(),
|
$drequest->getRepository(),
|
||||||
$history->getCommitIdentifier()),
|
$history->getCommitIdentifier()),
|
||||||
|
($commit ?
|
||||||
|
self::linkRevision(idx($this->revisions, $commit->getPHID())) :
|
||||||
|
null),
|
||||||
$change,
|
$change,
|
||||||
$date,
|
$date,
|
||||||
$time,
|
$time,
|
||||||
|
@ -150,6 +166,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
'Browse',
|
'Browse',
|
||||||
'',
|
'',
|
||||||
'Commit',
|
'Commit',
|
||||||
|
'Revision',
|
||||||
'Change',
|
'Change',
|
||||||
'Date',
|
'Date',
|
||||||
'Time',
|
'Time',
|
||||||
|
@ -161,6 +178,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
'',
|
'',
|
||||||
'threads',
|
'threads',
|
||||||
'n',
|
'n',
|
||||||
|
'n',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'right',
|
'right',
|
||||||
|
|
|
@ -134,4 +134,17 @@ abstract class DiffusionView extends AphrontView {
|
||||||
$commit_name);
|
$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