1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

When lines 12, 13, 14, etc all blame to the same change, only show it once

Summary:
Depends on D19312. Ref T13105. For readability, render only one link for each contiguous block of changes.

Also make the actual rendering logic a little more defensible.

Test Plan: Viewed some files with blame, saw one render per chunk instead of one per line.

Maniphest Tasks: T13105

Differential Revision: https://secure.phabricator.com/D19313
This commit is contained in:
epriestley 2018-04-09 05:38:06 -07:00
parent eb80f0a2d9
commit cf75d63b49
3 changed files with 61 additions and 44 deletions

View file

@ -390,7 +390,7 @@ return array(
'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'f01586dc', 'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'f01586dc',
'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '1db13e70', 'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '1db13e70',
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef', 'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef',
'rsrc/js/application/files/behavior-document-engine.js' => 'ed539253', 'rsrc/js/application/files/behavior-document-engine.js' => '6760beb4',
'rsrc/js/application/files/behavior-icon-composer.js' => '8499b6ab', 'rsrc/js/application/files/behavior-icon-composer.js' => '8499b6ab',
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888', 'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
'rsrc/js/application/harbormaster/behavior-harbormaster-log.js' => '191b4909', 'rsrc/js/application/harbormaster/behavior-harbormaster-log.js' => '191b4909',
@ -604,7 +604,7 @@ return array(
'javelin-behavior-diffusion-jump-to' => '73d09eef', 'javelin-behavior-diffusion-jump-to' => '73d09eef',
'javelin-behavior-diffusion-locate-file' => '6d3e1947', 'javelin-behavior-diffusion-locate-file' => '6d3e1947',
'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc', 'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc',
'javelin-behavior-document-engine' => 'ed539253', 'javelin-behavior-document-engine' => '6760beb4',
'javelin-behavior-doorkeeper-tag' => '1db13e70', 'javelin-behavior-doorkeeper-tag' => '1db13e70',
'javelin-behavior-drydock-live-operation-status' => '901935ef', 'javelin-behavior-drydock-live-operation-status' => '901935ef',
'javelin-behavior-durable-column' => '2ae077e1', 'javelin-behavior-durable-column' => '2ae077e1',
@ -1398,6 +1398,11 @@ return array(
'javelin-json', 'javelin-json',
'phuix-form-control-view', 'phuix-form-control-view',
), ),
'6760beb4' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
),
'680ea2c8' => array( '680ea2c8' => array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
@ -2116,11 +2121,6 @@ return array(
'javelin-stratcom', 'javelin-stratcom',
'javelin-vector', 'javelin-vector',
), ),
'ed539253' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
),
'edf8a145' => array( 'edf8a145' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-uri', 'javelin-uri',

View file

@ -130,8 +130,8 @@ final class PhabricatorSourceCodeView extends AphrontView {
$lines = idx($blame_map, $line_number); $lines = idx($blame_map, $line_number);
if ($lines) { if ($lines) {
$skip_blame = 'skip;'.$lines; $skip_blame = 'skip';
$info_blame = 'info;'.$lines; $info_blame = 'info';
} else { } else {
$skip_blame = null; $skip_blame = null;
$info_blame = null; $info_blame = null;
@ -149,6 +149,7 @@ final class PhabricatorSourceCodeView extends AphrontView {
array( array(
'class' => 'phabricator-source-blame-info', 'class' => 'phabricator-source-blame-info',
'data-blame' => $info_blame, 'data-blame' => $info_blame,
'data-blame-lines' => $lines,
)), )),
); );
} else { } else {

View file

@ -239,31 +239,48 @@ JX.behavior('document-engine', function(config, statics) {
// We're ready to render. // We're ready to render.
var viewport = JX.$(data.viewportID); var viewport = JX.$(data.viewportID);
var cells = JX.DOM.scry(viewport, 'th'); var row_nodes = JX.DOM.scry(viewport, 'tr');
var row_list = [];
var ii;
for (var ii = 0; ii < cells.length; ii++) { for (ii = 0; ii < row_nodes.length; ii++) {
var cell = cells[ii]; var row = {};
var keep = false;
var node = row_nodes[ii];
var spec = cell.getAttribute('data-blame'); for (var jj = 0; jj < node.childNodes.length; jj++) {
if (!spec) { var child = node.childNodes[jj];
if (!JX.DOM.isType(child, 'th')) {
continue; continue;
} }
spec = spec.split(';'); var spec = child.getAttribute('data-blame');
var type = spec[0]; if (spec) {
var lines = spec[1]; row[spec] = child;
keep = true;
var content = null;
switch (type) {
case 'skip':
content = renderSkip(data.blame.value, lines);
break;
case 'info':
content = renderInfo(data.blame.value, lines);
break;
} }
JX.DOM.setContent(cell, content); if (spec === 'info') {
row.lines = child.getAttribute('data-blame-lines');
}
}
if (keep) {
row_list.push(row);
}
}
var last = null;
for (ii = 0; ii < row_list.length; ii++) {
var commit = data.blame.value.blame[row_list[ii].lines - 1];
row_list[ii].commit = commit;
row_list[ii].last = last;
last = commit;
}
for (ii = 0; ii < row_list.length; ii++) {
renderBlame(row_list[ii], data.blame.value);
} }
} }
@ -273,26 +290,25 @@ JX.behavior('document-engine', function(config, statics) {
blame(data); blame(data);
} }
function renderSkip(blame, lines) { function renderBlame(row, blame) {
var commit = blame.blame[lines - 1]; var spec = blame.map[row.commit];
if (!commit) {
return null;
var info = null;
var skip = null;
if (spec && (row.commit != row.last)) {
skip = JX.$H(spec.skip);
info = JX.$H(spec.info);
} }
var spec = blame.map[commit]; if (row.skip) {
JX.DOM.setContent(row.skip, skip);
return JX.$H(spec.skip);
} }
function renderInfo(blame, lines) { if (row.info) {
var commit = blame.blame[lines - 1]; JX.DOM.setContent(row.info, info);
if (!commit) {
return null;
} }
var spec = blame.map[commit];
return JX.$H(spec.info);
} }
if (!statics.initialized) { if (!statics.initialized) {