1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Link revision from blame

Summary: I need this much more than commit but it can be useful too.

Test Plan: Displayed blame, clicked on the link.

Reviewers: epriestley

Reviewed By: epriestley

CC: john, aran, Korvin, phunt

Differential Revision: https://secure.phabricator.com/D2820
This commit is contained in:
vrana 2012-06-21 12:48:45 -07:00
parent d6ec905fe3
commit a7a978d1f3

View file

@ -388,6 +388,22 @@ final class DiffusionBrowseFileController extends DiffusionController {
$commits = mpull($commits, null, 'getCommitIdentifier');
}
$revision_ids = 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) {
$revision_ids = ipull($revision_ids, 'revisionID', 'commitPHID');
$revisions = id(new DifferentialRevision())->loadAllWhere(
'id IN (%Ld)',
$revision_ids);
}
}
$request = $this->getRequest();
$user = $request->getUser();
@ -411,6 +427,7 @@ final class DiffusionBrowseFileController extends DiffusionController {
$before_link = null;
$commit_link = null;
$revision_link = null;
if (idx($line, 'commit')) {
$commit = $line['commit'];
@ -443,6 +460,31 @@ final class DiffusionBrowseFileController extends DiffusionController {
),
phutil_escape_html(phutil_utf8_shorten($line['commit'], 9, '')));
$revision_id = idx($revision_ids, $commits[$commit]->getPHID());
if ($revision_id) {
$revision = idx($revisions, $revision_id);
if (!$revision) {
$tooltip = '(Invalid revision)';
} else {
$tooltip =
phabricator_date($revision->getDateModified(), $user).
" \xC2\xB7 ".
$revision->getTitle();
}
$revision_link = javelin_render_tag(
'a',
array(
'href' => '/D'.$revision_id,
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $tooltip,
'align' => 'E',
'size' => 600,
),
),
'D'.$revision_id);
}
$before_link = javelin_render_tag(
'a',
array(
@ -473,6 +515,14 @@ final class DiffusionBrowseFileController extends DiffusionController {
),
$commit_link);
$blame[] = phutil_render_tag(
'th',
array(
'class' => 'diffusion-rev-link',
'style' => 'background: '.$color,
),
$revision_link);
$blame[] = phutil_render_tag(
'th',
array(