2012-12-07 16:19:57 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialChangesetTwoUpRenderer
|
Implement basic one-up and test renderers
Summary:
This is a half-step toward one-up and test renderers. This is mostly a structural change, and has no user-facing impact. It splits the rendering hierarchy like this:
- Renderer (more methods are abstract than before)
- HTML Renderer (most HTML stuff has moved down from the base to here)
- HTML 1-up (placeholder only -- not yet a functional implementation)
- HTML 2-up (minimal changes, uses mostly old code)
- Test Renderer (unit-testable renderer base, implements text versions of the HTML stuff)
- Test 1-up (selects 1-up mode for test rendering)
- Test 2-up (selects 2-up mode for test rendering)
Broadly, I'm trying to share as much code as possible by splitting rendering into more, smaller stages. Specifically, we do this:
- Combine the various sorts of inputs (changes, context, inlines, etc.) into a single, relatively homogenous list of "primitives". This happens in the base class.
- The primitive types are: old (diff left side), new (diff right side), context ("show more context"), no-context ("context not available") and inline (inline comment).
- Possibly, apply a filtering/reordering step to the primitives to get them ready for 1-up rendering. This mostly removes information, and does a small amount of reordering. This also happens in the base class.
- Pass the primitives to the actual renderer, to convert them into HTML, text, or whatever else. This happens in the leaf class.
The primitive implementation is not yet complete (it doesn't attach as much information to the primitives as it should -- stuff like coverage and copies), but covers the basics.
The existing HTMLTwoUp renderer does not use the primitive path; instead, it still goes down the old path.
Test Plan: Ran unit tests, looked at a bunch of diffs.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D4421
2013-01-14 14:20:06 -08:00
|
|
|
extends DifferentialChangesetHTMLRenderer {
|
2012-12-07 16:19:57 -08:00
|
|
|
|
2019-02-14 09:54:55 -08:00
|
|
|
private $newOffsetMap;
|
|
|
|
|
Implement basic one-up and test renderers
Summary:
This is a half-step toward one-up and test renderers. This is mostly a structural change, and has no user-facing impact. It splits the rendering hierarchy like this:
- Renderer (more methods are abstract than before)
- HTML Renderer (most HTML stuff has moved down from the base to here)
- HTML 1-up (placeholder only -- not yet a functional implementation)
- HTML 2-up (minimal changes, uses mostly old code)
- Test Renderer (unit-testable renderer base, implements text versions of the HTML stuff)
- Test 1-up (selects 1-up mode for test rendering)
- Test 2-up (selects 2-up mode for test rendering)
Broadly, I'm trying to share as much code as possible by splitting rendering into more, smaller stages. Specifically, we do this:
- Combine the various sorts of inputs (changes, context, inlines, etc.) into a single, relatively homogenous list of "primitives". This happens in the base class.
- The primitive types are: old (diff left side), new (diff right side), context ("show more context"), no-context ("context not available") and inline (inline comment).
- Possibly, apply a filtering/reordering step to the primitives to get them ready for 1-up rendering. This mostly removes information, and does a small amount of reordering. This also happens in the base class.
- Pass the primitives to the actual renderer, to convert them into HTML, text, or whatever else. This happens in the leaf class.
The primitive implementation is not yet complete (it doesn't attach as much information to the primitives as it should -- stuff like coverage and copies), but covers the basics.
The existing HTMLTwoUp renderer does not use the primitive path; instead, it still goes down the old path.
Test Plan: Ran unit tests, looked at a bunch of diffs.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D4421
2013-01-14 14:20:06 -08:00
|
|
|
public function isOneUpRenderer() {
|
|
|
|
return false;
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
2015-03-05 14:01:52 -08:00
|
|
|
protected function getRendererTableClass() {
|
|
|
|
return 'diff-2up';
|
|
|
|
}
|
|
|
|
|
Make "Show Context" persist rendering, whitespace, encoding, etc
Summary:
Ref T2009. Currently, we do not persist view parameters when making context rendering requests.
The big one is the renderer (1up vs 2up). This makes context on unified diffs come in with too many columns.
However, it impacts other parameters too. For example, at HEAD, if you change highlighting to "rainbow" and then load more context, the context uses the original highlighter instead of the rainbow highlighter.
This moves context loads into ChangesetViewManager, which maintains view parameters and can provide them correctly.
- This removes "ref"; it is no longer required, as the ChangesetViewManager tracks it.
- This removes URI management from `behavior-show-more`; it is no longer required, since the ChangesetViewManager knows how to render.
- This removes "whitespace" since this is handled properly by the view manager.
Test Plan:
- Used "Show Top" / "Show All" / "Show Bottom" in 1-up and 2-up views.
- Changed file highlighting to rainbow, loaded stuff, saw rainbow stick.
- Used "Show Entire File" in 1-up and 2-up views.
- Saw loading chrome.
- No loading chrome normally.
- Made inlines, verified `copyRows()` code runs.
- Poked around Diffusion -- it is missing some parameter handling, but works OK.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D11977
2015-03-05 14:03:00 -08:00
|
|
|
public function getRendererKey() {
|
|
|
|
return '2up';
|
|
|
|
}
|
|
|
|
|
2014-11-14 16:58:24 -08:00
|
|
|
protected function renderColgroup() {
|
|
|
|
return phutil_tag('colgroup', array(), array(
|
|
|
|
phutil_tag('col', array('class' => 'num')),
|
|
|
|
phutil_tag('col', array('class' => 'left')),
|
|
|
|
phutil_tag('col', array('class' => 'num')),
|
|
|
|
phutil_tag('col', array('class' => 'copy')),
|
|
|
|
phutil_tag('col', array('class' => 'right')),
|
|
|
|
phutil_tag('col', array('class' => 'cov')),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
public function renderTextChange(
|
|
|
|
$range_start,
|
|
|
|
$range_len,
|
2012-12-11 17:16:11 -08:00
|
|
|
$rows) {
|
2012-12-07 16:19:57 -08:00
|
|
|
|
2013-01-10 16:06:39 -08:00
|
|
|
$hunk_starts = $this->getHunkStartLines();
|
2012-12-07 16:19:57 -08:00
|
|
|
|
|
|
|
$context_not_available = null;
|
2013-01-10 16:06:39 -08:00
|
|
|
if ($hunk_starts) {
|
2013-01-25 12:57:17 -08:00
|
|
|
$context_not_available = javelin_tag(
|
2012-12-07 16:19:57 -08:00
|
|
|
'tr',
|
|
|
|
array(
|
|
|
|
'sigil' => 'context-target',
|
|
|
|
),
|
2013-01-17 19:15:06 -08:00
|
|
|
phutil_tag(
|
2012-12-07 16:19:57 -08:00
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'colspan' => 6,
|
2014-10-08 00:01:04 +11:00
|
|
|
'class' => 'show-more',
|
2012-12-07 16:19:57 -08:00
|
|
|
),
|
2013-02-19 13:33:10 -08:00
|
|
|
pht('Context not available.')));
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
$html = array();
|
Break long words in differential two-up view
Summary: This should prevent long lines from making the code width different between files, which can be annoying. (And of course, it stops long lines from making a giant scrollbar too.)
Test Plan:
Loaded this diff in Chrome, Firefox, IE9, and IE8:
{F137505}
(That's a screenshot from Chrome, but it looks about the same in the other browsers.)
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin, chad
Maniphest Tasks: T2004
Differential Revision: https://secure.phabricator.com/D8686
2014-04-03 09:37:49 -07:00
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
$old_lines = $this->getOldLines();
|
|
|
|
$new_lines = $this->getNewLines();
|
2012-12-11 17:16:11 -08:00
|
|
|
$gaps = $this->getGaps();
|
2012-12-07 16:19:57 -08:00
|
|
|
$reference = $this->getRenderingReference();
|
|
|
|
|
2015-03-05 14:03:57 -08:00
|
|
|
list($left_prefix, $right_prefix) = $this->getLineIDPrefixes();
|
2012-12-07 16:19:57 -08:00
|
|
|
|
|
|
|
$changeset = $this->getChangeset();
|
|
|
|
$copy_lines = idx($changeset->getMetadata(), 'copy:lines', array());
|
|
|
|
$highlight_old = $this->getHighlightOld();
|
|
|
|
$highlight_new = $this->getHighlightNew();
|
|
|
|
$old_render = $this->getOldRender();
|
|
|
|
$new_render = $this->getNewRender();
|
|
|
|
$original_left = $this->getOriginalOld();
|
|
|
|
$original_right = $this->getOriginalNew();
|
2012-12-11 17:16:11 -08:00
|
|
|
$mask = $this->getMask();
|
2012-12-07 16:19:57 -08:00
|
|
|
|
2019-02-14 09:54:55 -08:00
|
|
|
$scope_engine = $this->getScopeEngine();
|
|
|
|
$offset_map = null;
|
Render indent depth changes more clearly
Summary:
Ref T13161. See PHI723. Our whitespace handling is based on whitespace flags like `diff -bw`, mostly just for historical reasons: long ago, the easiest way to minimize the visual impact of indentation changes was to literally use `diff -bw`.
However, this approach is very coarse and has a lot of problems, like detecting `"ab" -> "a b"` as "only a whitespace change" even though this is always semantic. It also causes problems in YAML, Python, etc. Over time, we've added a lot of stuff to mitigate the downsides to this approach.
We also no longer get any benefits from this approach being simple: we need faithful diffs as the authoritative source, and have to completely rebuild the diff to `diff -bw` it. In the UI, we have a "whitespace mode" flag. We have the "whitespace matters" configuration.
I think ReviewBoard generally has a better approach to indent depth changes than we do (see T13161) where it detects them and renders them in a minimal way with low visual impact. This is ultimately what we want: reduce visual clutter for depth-only changes, but preserve whitespace changes in strings, etc.
Move toward detecting and rendering indent depth changes. Followup work:
- These should get colorblind colors and the design can probably use a little more tweaking.
- The OneUp mode is okay, but could be improved.
- Whitespace mode can now be removed completely.
- I'm trying to handle tabs correctly, but since we currently mangle them into spaces today, it's hard to be sure I actually got it right.
Test Plan: {F6214084}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161
Differential Revision: https://secure.phabricator.com/D20181
2019-02-15 08:10:56 -08:00
|
|
|
$depth_only = $this->getDepthOnlyLines();
|
2019-02-14 09:54:55 -08:00
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) {
|
|
|
|
if (empty($mask[$ii])) {
|
|
|
|
// If we aren't going to show this line, we've just entered a gap.
|
|
|
|
// Pop information about the next gap off the $gaps stack and render
|
|
|
|
// an appropriate "Show more context" element. This branch eventually
|
|
|
|
// increments $ii by the entire size of the gap and then continues
|
|
|
|
// the loop.
|
|
|
|
$gap = array_pop($gaps);
|
|
|
|
$top = $gap[0];
|
|
|
|
$len = $gap[1];
|
|
|
|
|
2015-03-05 14:03:26 -08:00
|
|
|
$contents = $this->renderShowContextLinks($top, $len, $rows);
|
2012-12-07 16:19:57 -08:00
|
|
|
|
|
|
|
$is_last_block = false;
|
|
|
|
if ($ii + $len >= $rows) {
|
|
|
|
$is_last_block = true;
|
|
|
|
}
|
|
|
|
|
2019-02-14 09:54:55 -08:00
|
|
|
$context_text = null;
|
2012-12-07 16:19:57 -08:00
|
|
|
$context_line = null;
|
2019-02-20 05:06:42 -08:00
|
|
|
if (!$is_last_block && $scope_engine) {
|
2019-02-14 09:54:55 -08:00
|
|
|
$target_line = $new_lines[$ii + $len]['line'];
|
|
|
|
$context_line = $scope_engine->getScopeStart($target_line);
|
|
|
|
if ($context_line !== null) {
|
|
|
|
// The scope engine returns a line number in the file. We need
|
|
|
|
// to map that back to a display offset in the diff.
|
|
|
|
if (!$offset_map) {
|
|
|
|
$offset_map = $this->getNewLineToOffsetMap();
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
2019-02-14 09:54:55 -08:00
|
|
|
$offset = $offset_map[$context_line];
|
|
|
|
$context_text = $new_render[$offset];
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-30 10:58:21 -08:00
|
|
|
$container = javelin_tag(
|
2012-12-07 16:19:57 -08:00
|
|
|
'tr',
|
|
|
|
array(
|
|
|
|
'sigil' => 'context-target',
|
|
|
|
),
|
2013-01-30 10:58:21 -08:00
|
|
|
array(
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
2019-02-17 07:58:26 -08:00
|
|
|
'class' => 'show-context-line n left-context',
|
|
|
|
)),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
2013-01-30 10:58:21 -08:00
|
|
|
'class' => 'show-more',
|
|
|
|
),
|
2015-03-05 14:03:26 -08:00
|
|
|
$contents),
|
2013-01-30 10:58:21 -08:00
|
|
|
phutil_tag(
|
2019-02-17 07:58:26 -08:00
|
|
|
'td',
|
2013-01-30 10:58:21 -08:00
|
|
|
array(
|
2019-02-17 07:58:26 -08:00
|
|
|
'class' => 'show-context-line n',
|
|
|
|
'data-n' => $context_line,
|
|
|
|
)),
|
2013-01-30 10:58:21 -08:00
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'colspan' => 3,
|
|
|
|
'class' => 'show-context',
|
|
|
|
),
|
|
|
|
// TODO: [HTML] Escaping model here isn't ideal.
|
2019-02-14 09:54:55 -08:00
|
|
|
phutil_safe_html($context_text)),
|
2013-01-30 10:58:21 -08:00
|
|
|
));
|
2012-12-07 16:19:57 -08:00
|
|
|
|
|
|
|
$html[] = $container;
|
|
|
|
|
|
|
|
$ii += ($len - 1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$o_num = null;
|
Break long words in differential two-up view
Summary: This should prevent long lines from making the code width different between files, which can be annoying. (And of course, it stops long lines from making a giant scrollbar too.)
Test Plan:
Loaded this diff in Chrome, Firefox, IE9, and IE8:
{F137505}
(That's a screenshot from Chrome, but it looks about the same in the other browsers.)
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin, chad
Maniphest Tasks: T2004
Differential Revision: https://secure.phabricator.com/D8686
2014-04-03 09:37:49 -07:00
|
|
|
$o_classes = '';
|
2012-12-07 16:19:57 -08:00
|
|
|
$o_text = null;
|
|
|
|
if (isset($old_lines[$ii])) {
|
|
|
|
$o_num = $old_lines[$ii]['line'];
|
|
|
|
$o_text = isset($old_render[$ii]) ? $old_render[$ii] : null;
|
|
|
|
if ($old_lines[$ii]['type']) {
|
|
|
|
if ($old_lines[$ii]['type'] == '\\') {
|
|
|
|
$o_text = $old_lines[$ii]['text'];
|
Break long words in differential two-up view
Summary: This should prevent long lines from making the code width different between files, which can be annoying. (And of course, it stops long lines from making a giant scrollbar too.)
Test Plan:
Loaded this diff in Chrome, Firefox, IE9, and IE8:
{F137505}
(That's a screenshot from Chrome, but it looks about the same in the other browsers.)
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin, chad
Maniphest Tasks: T2004
Differential Revision: https://secure.phabricator.com/D8686
2014-04-03 09:37:49 -07:00
|
|
|
$o_class = 'comment';
|
2012-12-07 16:19:57 -08:00
|
|
|
} else if ($original_left && !isset($highlight_old[$o_num])) {
|
Break long words in differential two-up view
Summary: This should prevent long lines from making the code width different between files, which can be annoying. (And of course, it stops long lines from making a giant scrollbar too.)
Test Plan:
Loaded this diff in Chrome, Firefox, IE9, and IE8:
{F137505}
(That's a screenshot from Chrome, but it looks about the same in the other browsers.)
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin, chad
Maniphest Tasks: T2004
Differential Revision: https://secure.phabricator.com/D8686
2014-04-03 09:37:49 -07:00
|
|
|
$o_class = 'old-rebase';
|
2012-12-07 16:19:57 -08:00
|
|
|
} else if (empty($new_lines[$ii])) {
|
Break long words in differential two-up view
Summary: This should prevent long lines from making the code width different between files, which can be annoying. (And of course, it stops long lines from making a giant scrollbar too.)
Test Plan:
Loaded this diff in Chrome, Firefox, IE9, and IE8:
{F137505}
(That's a screenshot from Chrome, but it looks about the same in the other browsers.)
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin, chad
Maniphest Tasks: T2004
Differential Revision: https://secure.phabricator.com/D8686
2014-04-03 09:37:49 -07:00
|
|
|
$o_class = 'old old-full';
|
2012-12-07 16:19:57 -08:00
|
|
|
} else {
|
2019-03-06 08:30:18 -08:00
|
|
|
if (isset($depth_only[$ii])) {
|
|
|
|
if ($depth_only[$ii] == '>') {
|
|
|
|
// When a line has depth-only change, we only highlight the
|
|
|
|
// left side of the diff if the depth is decreasing. When the
|
|
|
|
// depth is increasing, the ">>" marker on the right hand side
|
|
|
|
// of the diff generally provides enough visibility on its own.
|
|
|
|
|
|
|
|
$o_class = '';
|
|
|
|
} else {
|
|
|
|
$o_class = 'old';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$o_class = 'old';
|
|
|
|
}
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
Break long words in differential two-up view
Summary: This should prevent long lines from making the code width different between files, which can be annoying. (And of course, it stops long lines from making a giant scrollbar too.)
Test Plan:
Loaded this diff in Chrome, Firefox, IE9, and IE8:
{F137505}
(That's a screenshot from Chrome, but it looks about the same in the other browsers.)
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin, chad
Maniphest Tasks: T2004
Differential Revision: https://secure.phabricator.com/D8686
2014-04-03 09:37:49 -07:00
|
|
|
$o_classes = $o_class;
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
$n_copy = hsprintf('<td class="copy" />');
|
2012-12-07 16:19:57 -08:00
|
|
|
$n_cov = null;
|
|
|
|
$n_colspan = 2;
|
|
|
|
$n_classes = '';
|
|
|
|
$n_num = null;
|
|
|
|
$n_text = null;
|
|
|
|
|
|
|
|
if (isset($new_lines[$ii])) {
|
|
|
|
$n_num = $new_lines[$ii]['line'];
|
|
|
|
$n_text = isset($new_render[$ii]) ? $new_render[$ii] : null;
|
|
|
|
$coverage = $this->getCodeCoverage();
|
|
|
|
|
|
|
|
if ($coverage !== null) {
|
|
|
|
if (empty($coverage[$n_num - 1])) {
|
|
|
|
$cov_class = 'N';
|
|
|
|
} else {
|
|
|
|
$cov_class = $coverage[$n_num - 1];
|
|
|
|
}
|
|
|
|
$cov_class = 'cov-'.$cov_class;
|
2013-11-11 09:23:23 -08:00
|
|
|
$n_cov = phutil_tag('td', array('class' => "cov {$cov_class}"));
|
2012-12-07 16:19:57 -08:00
|
|
|
$n_colspan--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($new_lines[$ii]['type']) {
|
|
|
|
if ($new_lines[$ii]['type'] == '\\') {
|
|
|
|
$n_text = $new_lines[$ii]['text'];
|
|
|
|
$n_class = 'comment';
|
|
|
|
} else if ($original_right && !isset($highlight_new[$n_num])) {
|
|
|
|
$n_class = 'new-rebase';
|
|
|
|
} else if (empty($old_lines[$ii])) {
|
|
|
|
$n_class = 'new new-full';
|
|
|
|
} else {
|
2019-03-06 08:30:18 -08:00
|
|
|
// When a line has a depth-only change, never highlight it on
|
|
|
|
// the right side. The ">>" marker generally provides enough
|
|
|
|
// visibility on its own for indent depth increases, and the left
|
|
|
|
// side is still highlighted for indent depth decreases.
|
Render indent depth changes more clearly
Summary:
Ref T13161. See PHI723. Our whitespace handling is based on whitespace flags like `diff -bw`, mostly just for historical reasons: long ago, the easiest way to minimize the visual impact of indentation changes was to literally use `diff -bw`.
However, this approach is very coarse and has a lot of problems, like detecting `"ab" -> "a b"` as "only a whitespace change" even though this is always semantic. It also causes problems in YAML, Python, etc. Over time, we've added a lot of stuff to mitigate the downsides to this approach.
We also no longer get any benefits from this approach being simple: we need faithful diffs as the authoritative source, and have to completely rebuild the diff to `diff -bw` it. In the UI, we have a "whitespace mode" flag. We have the "whitespace matters" configuration.
I think ReviewBoard generally has a better approach to indent depth changes than we do (see T13161) where it detects them and renders them in a minimal way with low visual impact. This is ultimately what we want: reduce visual clutter for depth-only changes, but preserve whitespace changes in strings, etc.
Move toward detecting and rendering indent depth changes. Followup work:
- These should get colorblind colors and the design can probably use a little more tweaking.
- The OneUp mode is okay, but could be improved.
- Whitespace mode can now be removed completely.
- I'm trying to handle tabs correctly, but since we currently mangle them into spaces today, it's hard to be sure I actually got it right.
Test Plan: {F6214084}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161
Differential Revision: https://secure.phabricator.com/D20181
2019-02-15 08:10:56 -08:00
|
|
|
|
|
|
|
if (isset($depth_only[$ii])) {
|
|
|
|
$n_class = '';
|
|
|
|
} else {
|
|
|
|
$n_class = 'new';
|
|
|
|
}
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
$n_classes = $n_class;
|
|
|
|
|
Render indent depth changes more clearly
Summary:
Ref T13161. See PHI723. Our whitespace handling is based on whitespace flags like `diff -bw`, mostly just for historical reasons: long ago, the easiest way to minimize the visual impact of indentation changes was to literally use `diff -bw`.
However, this approach is very coarse and has a lot of problems, like detecting `"ab" -> "a b"` as "only a whitespace change" even though this is always semantic. It also causes problems in YAML, Python, etc. Over time, we've added a lot of stuff to mitigate the downsides to this approach.
We also no longer get any benefits from this approach being simple: we need faithful diffs as the authoritative source, and have to completely rebuild the diff to `diff -bw` it. In the UI, we have a "whitespace mode" flag. We have the "whitespace matters" configuration.
I think ReviewBoard generally has a better approach to indent depth changes than we do (see T13161) where it detects them and renders them in a minimal way with low visual impact. This is ultimately what we want: reduce visual clutter for depth-only changes, but preserve whitespace changes in strings, etc.
Move toward detecting and rendering indent depth changes. Followup work:
- These should get colorblind colors and the design can probably use a little more tweaking.
- The OneUp mode is okay, but could be improved.
- Whitespace mode can now be removed completely.
- I'm trying to handle tabs correctly, but since we currently mangle them into spaces today, it's hard to be sure I actually got it right.
Test Plan: {F6214084}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161
Differential Revision: https://secure.phabricator.com/D20181
2019-02-15 08:10:56 -08:00
|
|
|
$not_copied =
|
|
|
|
// If this line only changed depth, copy markers are pointless.
|
|
|
|
(!isset($copy_lines[$n_num])) ||
|
|
|
|
(isset($depth_only[$ii])) ||
|
|
|
|
($new_lines[$ii]['type'] == '\\');
|
|
|
|
|
|
|
|
if ($not_copied) {
|
In Differential, give the "moved/copied from" gutter a more clear visual look
Summary:
Depends on D20196. See PHI985. When empty, the "moved/copied" gutter currently renders with the same background color as the rest of the line. This can be misleading because it makes code look more indented than it is, especially if you're unfamiliar with the tool:
{F6225179}
If we remove this misleading coloration, we get a white gap. This is more clear, but looks a little odd:
{F6225181}
Instead, give this gutter a subtle background fill in all casses, to make it more clear that it's a separate gutter region, not a part of the text diff:
{F6225183}
Test Plan: See screenshots. Copied text from a diff, added/removed inlines, etc.
Reviewers: amckinley
Reviewed By: amckinley
Differential Revision: https://secure.phabricator.com/D20197
2019-02-20 04:40:06 -08:00
|
|
|
$n_copy = phutil_tag('td', array('class' => 'copy'));
|
2012-12-07 16:19:57 -08:00
|
|
|
} else {
|
|
|
|
list($orig_file, $orig_line, $orig_type) = $copy_lines[$n_num];
|
|
|
|
$title = ($orig_type == '-' ? 'Moved' : 'Copied').' from ';
|
|
|
|
if ($orig_file == '') {
|
|
|
|
$title .= "line {$orig_line}";
|
|
|
|
} else {
|
|
|
|
$title .=
|
|
|
|
basename($orig_file).
|
|
|
|
":{$orig_line} in dir ".
|
|
|
|
dirname('/'.$orig_file);
|
|
|
|
}
|
|
|
|
$class = ($orig_type == '-' ? 'new-move' : 'new-copy');
|
2013-01-25 12:57:17 -08:00
|
|
|
$n_copy = javelin_tag(
|
2012-12-07 16:19:57 -08:00
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'meta' => array(
|
|
|
|
'msg' => $title,
|
|
|
|
),
|
|
|
|
'class' => 'copy '.$class,
|
In Differential, give the "moved/copied from" gutter a more clear visual look
Summary:
Depends on D20196. See PHI985. When empty, the "moved/copied" gutter currently renders with the same background color as the rest of the line. This can be misleading because it makes code look more indented than it is, especially if you're unfamiliar with the tool:
{F6225179}
If we remove this misleading coloration, we get a white gap. This is more clear, but looks a little odd:
{F6225181}
Instead, give this gutter a subtle background fill in all casses, to make it more clear that it's a separate gutter region, not a part of the text diff:
{F6225183}
Test Plan: See screenshots. Copied text from a diff, added/removed inlines, etc.
Reviewers: amckinley
Reviewed By: amckinley
Differential Revision: https://secure.phabricator.com/D20197
2019-02-20 04:40:06 -08:00
|
|
|
));
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-10 16:06:39 -08:00
|
|
|
if (isset($hunk_starts[$o_num])) {
|
2012-12-07 16:19:57 -08:00
|
|
|
$html[] = $context_not_available;
|
|
|
|
}
|
|
|
|
|
2015-03-05 14:03:57 -08:00
|
|
|
if ($o_num && $left_prefix) {
|
|
|
|
$o_id = $left_prefix.$o_num;
|
2012-12-07 16:19:57 -08:00
|
|
|
} else {
|
|
|
|
$o_id = null;
|
|
|
|
}
|
|
|
|
|
2015-03-05 14:03:57 -08:00
|
|
|
if ($n_num && $right_prefix) {
|
|
|
|
$n_id = $right_prefix.$n_num;
|
2012-12-07 16:19:57 -08:00
|
|
|
} else {
|
|
|
|
$n_id = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$old_comments = $this->getOldComments();
|
|
|
|
$new_comments = $this->getNewComments();
|
Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
2015-05-27 10:28:38 -07:00
|
|
|
$scaffolds = array();
|
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
if ($o_num && isset($old_comments[$o_num])) {
|
|
|
|
foreach ($old_comments[$o_num] as $comment) {
|
2015-03-06 05:57:24 -08:00
|
|
|
$inline = $this->buildInlineComment(
|
|
|
|
$comment,
|
|
|
|
$on_right = false);
|
|
|
|
$scaffold = $this->getRowScaffoldForInline($inline);
|
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
if ($n_num && isset($new_comments[$n_num])) {
|
|
|
|
foreach ($new_comments[$n_num] as $key => $new_comment) {
|
|
|
|
if ($comment->isCompatible($new_comment)) {
|
2015-03-06 05:57:24 -08:00
|
|
|
$companion = $this->buildInlineComment(
|
|
|
|
$new_comment,
|
|
|
|
$on_right = true);
|
|
|
|
|
|
|
|
$scaffold->addInlineView($companion);
|
2012-12-07 16:19:57 -08:00
|
|
|
unset($new_comments[$n_num][$key]);
|
2015-05-07 14:09:41 -07:00
|
|
|
break;
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-06 05:57:24 -08:00
|
|
|
|
Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
2015-05-27 10:28:38 -07:00
|
|
|
|
|
|
|
$scaffolds[] = $scaffold;
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
}
|
Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
2015-05-27 10:28:38 -07:00
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
if ($n_num && isset($new_comments[$n_num])) {
|
|
|
|
foreach ($new_comments[$n_num] as $comment) {
|
2015-03-06 05:57:24 -08:00
|
|
|
$inline = $this->buildInlineComment(
|
|
|
|
$comment,
|
|
|
|
$on_right = true);
|
Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
2015-05-27 10:28:38 -07:00
|
|
|
|
|
|
|
$scaffolds[] = $this->getRowScaffoldForInline($inline);
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
}
|
Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
2015-05-27 10:28:38 -07:00
|
|
|
|
Use `<td class="n" data-n="3">` instead of `<th>3</th>` for line numbers
Summary:
Ref T13161. Ref T12822. See PHI870. Long ago, the web was simple. You could leave your doors unlocked, you knew all your neighbors, crime hadn't been invented yet, and `<th>3</th>` was a perfectly fine way to render a line number cell containing the number "3".
But times have changed!
- In PHI870, this isn't good for screenreaders. We can't do much about this, so switch to `<td>`.
- In D19349 / T13105 and elsewhere, this `::after { content: attr(data-n); }` approach seems like the least bad general-purpose approach for preventing line numbers from being copied. Although Differential needs even more magic beyond this in the two-up view, this is likely good enough for the one-up view, and is consistent with other views (paste, harbormaster logs, general source display) where this technique is sufficient on its own.
The chance this breaks //something// is pretty much 100%, but we've got a week to figure out what it breaks. I couldn't find any issues immediately.
Test Plan:
- Created, edited, deleted inlines in 1-up and 2-up views.
- Replied, keyboard-navigated, keyboard-replied, drag-selected, poked and prodded everything.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161, T12822
Differential Revision: https://secure.phabricator.com/D20188
2019-02-16 09:50:20 -08:00
|
|
|
$old_number = phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'id' => $o_id,
|
|
|
|
'class' => $o_classes.' n',
|
|
|
|
'data-n' => $o_num,
|
|
|
|
));
|
|
|
|
|
|
|
|
$new_number = phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'id' => $n_id,
|
|
|
|
'class' => $n_classes.' n',
|
|
|
|
'data-n' => $n_num,
|
|
|
|
));
|
|
|
|
|
Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
2015-05-27 10:28:38 -07:00
|
|
|
$html[] = phutil_tag('tr', array(), array(
|
Use `<td class="n" data-n="3">` instead of `<th>3</th>` for line numbers
Summary:
Ref T13161. Ref T12822. See PHI870. Long ago, the web was simple. You could leave your doors unlocked, you knew all your neighbors, crime hadn't been invented yet, and `<th>3</th>` was a perfectly fine way to render a line number cell containing the number "3".
But times have changed!
- In PHI870, this isn't good for screenreaders. We can't do much about this, so switch to `<td>`.
- In D19349 / T13105 and elsewhere, this `::after { content: attr(data-n); }` approach seems like the least bad general-purpose approach for preventing line numbers from being copied. Although Differential needs even more magic beyond this in the two-up view, this is likely good enough for the one-up view, and is consistent with other views (paste, harbormaster logs, general source display) where this technique is sufficient on its own.
The chance this breaks //something// is pretty much 100%, but we've got a week to figure out what it breaks. I couldn't find any issues immediately.
Test Plan:
- Created, edited, deleted inlines in 1-up and 2-up views.
- Replied, keyboard-navigated, keyboard-replied, drag-selected, poked and prodded everything.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161, T12822
Differential Revision: https://secure.phabricator.com/D20188
2019-02-16 09:50:20 -08:00
|
|
|
$old_number,
|
Behold! Copy text from either side of a diff!
Summary:
Ref T12822. Ref T13161. By default, when users select text from a diff and copy it to the clipboard, they get both sides of the diff and all the line numbers. This is usually not what they intended to copy.
As of D20188, we use `content: attr(...)` to render line numbers. No browser copies this text, so that fixes line numbers.
We can use "user-select" CSS to visually prevent selection of line numbers and other stuff we don't want to copy. In Firefox and Chrome, "user-select" also applies to copied text, so getting "user-select" on the right nodes is largely good enough to do what we want.
In Safari, "user-select" is only visual, so we always need to crawl the DOM to figure out what text to pull out of it anyway.
In all browsers, we likely want to crawl the DOM anyway because this will let us show one piece of text and copy a different piece of text. We probably want to do this in the future to preserve "\t" tabs, and possibly to let us render certain character codes in one way but copy their original values. For example, we could render "\x07" as "␇".
Finally, we have to figure out which side of the diff we're copying from. The rule here is:
- If you start the selection by clicking somewhere on the left or right side of the diff, that's what you're copying.
- Otherwise, use normal document copy rules.
So the overall flow here is:
- Listen for clicks.
- When the user clicks the left or right side of the diff, store what they clicked.
- When a selection starts, and something is actually selected, check if it was initiated by clicking a diff. If it was, apply a visual effect to get "user-select" where it needs to go and show the user what we think they're doing and what we're going to copy.
- (Then, try to handle a bunch of degenerate cases where you start a selection and then click inside that selection.)
- When a user clicks elsewhere or ends the selection with nothing selected, clear the selection mode.
- When a user copies text, if we have an active selection mode, pull all the selected nodes out of the DOM and filter out the ones we don't want to copy, then stitch the text back together. Although I believe this didn't work well in ~2010, it appears to work well today.
Test Plan: This mostly seems to work in Safari, Chrome, and Firefox. T12822 has some errata. I haven't tested touch events but am satisfied if the touch event story is anything better than "permanently destroys data".
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161, T12822
Differential Revision: https://secure.phabricator.com/D20191
2019-02-16 09:32:13 -08:00
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'class' => $o_classes,
|
|
|
|
'data-copy-mode' => 'copy-l',
|
|
|
|
),
|
|
|
|
$o_text),
|
Use `<td class="n" data-n="3">` instead of `<th>3</th>` for line numbers
Summary:
Ref T13161. Ref T12822. See PHI870. Long ago, the web was simple. You could leave your doors unlocked, you knew all your neighbors, crime hadn't been invented yet, and `<th>3</th>` was a perfectly fine way to render a line number cell containing the number "3".
But times have changed!
- In PHI870, this isn't good for screenreaders. We can't do much about this, so switch to `<td>`.
- In D19349 / T13105 and elsewhere, this `::after { content: attr(data-n); }` approach seems like the least bad general-purpose approach for preventing line numbers from being copied. Although Differential needs even more magic beyond this in the two-up view, this is likely good enough for the one-up view, and is consistent with other views (paste, harbormaster logs, general source display) where this technique is sufficient on its own.
The chance this breaks //something// is pretty much 100%, but we've got a week to figure out what it breaks. I couldn't find any issues immediately.
Test Plan:
- Created, edited, deleted inlines in 1-up and 2-up views.
- Replied, keyboard-navigated, keyboard-replied, drag-selected, poked and prodded everything.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161, T12822
Differential Revision: https://secure.phabricator.com/D20188
2019-02-16 09:50:20 -08:00
|
|
|
$new_number,
|
Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
2015-05-27 10:28:38 -07:00
|
|
|
$n_copy,
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
Behold! Copy text from either side of a diff!
Summary:
Ref T12822. Ref T13161. By default, when users select text from a diff and copy it to the clipboard, they get both sides of the diff and all the line numbers. This is usually not what they intended to copy.
As of D20188, we use `content: attr(...)` to render line numbers. No browser copies this text, so that fixes line numbers.
We can use "user-select" CSS to visually prevent selection of line numbers and other stuff we don't want to copy. In Firefox and Chrome, "user-select" also applies to copied text, so getting "user-select" on the right nodes is largely good enough to do what we want.
In Safari, "user-select" is only visual, so we always need to crawl the DOM to figure out what text to pull out of it anyway.
In all browsers, we likely want to crawl the DOM anyway because this will let us show one piece of text and copy a different piece of text. We probably want to do this in the future to preserve "\t" tabs, and possibly to let us render certain character codes in one way but copy their original values. For example, we could render "\x07" as "␇".
Finally, we have to figure out which side of the diff we're copying from. The rule here is:
- If you start the selection by clicking somewhere on the left or right side of the diff, that's what you're copying.
- Otherwise, use normal document copy rules.
So the overall flow here is:
- Listen for clicks.
- When the user clicks the left or right side of the diff, store what they clicked.
- When a selection starts, and something is actually selected, check if it was initiated by clicking a diff. If it was, apply a visual effect to get "user-select" where it needs to go and show the user what we think they're doing and what we're going to copy.
- (Then, try to handle a bunch of degenerate cases where you start a selection and then click inside that selection.)
- When a user clicks elsewhere or ends the selection with nothing selected, clear the selection mode.
- When a user copies text, if we have an active selection mode, pull all the selected nodes out of the DOM and filter out the ones we don't want to copy, then stitch the text back together. Although I believe this didn't work well in ~2010, it appears to work well today.
Test Plan: This mostly seems to work in Safari, Chrome, and Firefox. T12822 has some errata. I haven't tested touch events but am satisfied if the touch event story is anything better than "permanently destroys data".
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161, T12822
Differential Revision: https://secure.phabricator.com/D20191
2019-02-16 09:32:13 -08:00
|
|
|
array(
|
|
|
|
'class' => $n_classes,
|
|
|
|
'colspan' => $n_colspan,
|
|
|
|
'data-copy-mode' => 'copy-r',
|
|
|
|
),
|
2019-02-17 04:06:27 -08:00
|
|
|
$n_text),
|
Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
2015-05-27 10:28:38 -07:00
|
|
|
$n_cov,
|
|
|
|
));
|
|
|
|
|
|
|
|
if ($context_not_available && ($ii == $rows - 1)) {
|
|
|
|
$html[] = $context_not_available;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($scaffolds as $scaffold) {
|
|
|
|
$html[] = $scaffold;
|
|
|
|
}
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
return $this->wrapChangeInTable(phutil_implode_html('', $html));
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
2015-05-22 17:27:56 +10:00
|
|
|
public function renderFileChange(
|
|
|
|
$old_file = null,
|
|
|
|
$new_file = null,
|
|
|
|
$id = 0,
|
|
|
|
$vs = 0) {
|
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
$old = null;
|
|
|
|
if ($old_file) {
|
2015-03-06 09:38:21 -08:00
|
|
|
$old = $this->renderImageStage($old_file);
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
$new = null;
|
|
|
|
if ($new_file) {
|
2015-03-06 09:38:21 -08:00
|
|
|
$new = $this->renderImageStage($new_file);
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
2017-05-17 05:52:45 -07:00
|
|
|
// If we don't have an explicit "vs" changeset, it's the left side of the
|
|
|
|
// "id" changeset.
|
|
|
|
if (!$vs) {
|
|
|
|
$vs = $id;
|
|
|
|
}
|
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
$html_old = array();
|
|
|
|
$html_new = array();
|
2012-12-21 14:16:00 -08:00
|
|
|
foreach ($this->getOldComments() as $on_line => $comment_group) {
|
|
|
|
foreach ($comment_group as $comment) {
|
2015-03-06 05:57:24 -08:00
|
|
|
$inline = $this->buildInlineComment(
|
|
|
|
$comment,
|
|
|
|
$on_right = false);
|
|
|
|
$html_old[] = $this->getRowScaffoldForInline($inline);
|
2012-12-21 14:16:00 -08:00
|
|
|
}
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
2012-12-21 14:16:00 -08:00
|
|
|
foreach ($this->getNewComments() as $lin_line => $comment_group) {
|
|
|
|
foreach ($comment_group as $comment) {
|
2015-03-06 05:57:24 -08:00
|
|
|
$inline = $this->buildInlineComment(
|
|
|
|
$comment,
|
|
|
|
$on_right = true);
|
|
|
|
$html_new[] = $this->getRowScaffoldForInline($inline);
|
2012-12-21 14:16:00 -08:00
|
|
|
}
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$old) {
|
2013-11-11 09:23:23 -08:00
|
|
|
$th_old = phutil_tag('th', array());
|
2012-12-07 16:19:57 -08:00
|
|
|
} else {
|
2013-11-11 09:23:23 -08:00
|
|
|
$th_old = phutil_tag('th', array('id' => "C{$vs}OL1"), 1);
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$new) {
|
2013-11-11 09:23:23 -08:00
|
|
|
$th_new = phutil_tag('th', array());
|
2012-12-07 16:19:57 -08:00
|
|
|
} else {
|
2016-04-01 12:52:31 -07:00
|
|
|
$th_new = phutil_tag('th', array('id' => "C{$id}NL1"), 1);
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
2014-04-03 15:11:06 -07:00
|
|
|
$output = hsprintf(
|
2012-12-07 16:19:57 -08:00
|
|
|
'<tr class="differential-image-diff">'.
|
2013-02-13 14:50:15 -08:00
|
|
|
'%s'.
|
Break long words in differential two-up view
Summary: This should prevent long lines from making the code width different between files, which can be annoying. (And of course, it stops long lines from making a giant scrollbar too.)
Test Plan:
Loaded this diff in Chrome, Firefox, IE9, and IE8:
{F137505}
(That's a screenshot from Chrome, but it looks about the same in the other browsers.)
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin, chad
Maniphest Tasks: T2004
Differential Revision: https://secure.phabricator.com/D8686
2014-04-03 09:37:49 -07:00
|
|
|
'<td class="differential-old-image">%s</td>'.
|
2013-02-13 14:50:15 -08:00
|
|
|
'%s'.
|
Break long words in differential two-up view
Summary: This should prevent long lines from making the code width different between files, which can be annoying. (And of course, it stops long lines from making a giant scrollbar too.)
Test Plan:
Loaded this diff in Chrome, Firefox, IE9, and IE8:
{F137505}
(That's a screenshot from Chrome, but it looks about the same in the other browsers.)
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin, chad
Maniphest Tasks: T2004
Differential Revision: https://secure.phabricator.com/D8686
2014-04-03 09:37:49 -07:00
|
|
|
'<td class="differential-new-image" colspan="3">%s</td>'.
|
2012-12-07 16:19:57 -08:00
|
|
|
'</tr>'.
|
2013-02-13 14:50:15 -08:00
|
|
|
'%s'.
|
|
|
|
'%s',
|
|
|
|
$th_old,
|
|
|
|
$old,
|
|
|
|
$th_new,
|
|
|
|
$new,
|
|
|
|
phutil_implode_html('', $html_old),
|
|
|
|
phutil_implode_html('', $html_new));
|
2012-12-07 16:19:57 -08:00
|
|
|
|
2013-01-15 08:07:40 -08:00
|
|
|
$output = $this->wrapChangeInTable($output);
|
|
|
|
|
|
|
|
return $this->renderChangesetTable($output);
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|
|
|
|
|
2015-03-06 05:44:36 -08:00
|
|
|
public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) {
|
|
|
|
return id(new PHUIDiffTwoUpInlineCommentRowScaffold())
|
|
|
|
->addInlineView($view);
|
|
|
|
}
|
|
|
|
|
2019-02-14 09:54:55 -08:00
|
|
|
private function getNewLineToOffsetMap() {
|
|
|
|
if ($this->newOffsetMap === null) {
|
|
|
|
$new = $this->getNewLines();
|
|
|
|
|
|
|
|
$map = array();
|
|
|
|
foreach ($new as $offset => $new_line) {
|
|
|
|
if ($new_line['line'] === null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$map[$new_line['line']] = $offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->newOffsetMap = $map;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->newOffsetMap;
|
|
|
|
}
|
|
|
|
|
2019-02-17 07:58:26 -08:00
|
|
|
protected function getTableSigils() {
|
|
|
|
return array(
|
|
|
|
'intercept-copy',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-12-07 16:19:57 -08:00
|
|
|
}
|