2012-12-08 01:19:57 +01: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 23:20:06 +01:00
|
|
|
extends DifferentialChangesetHTMLRenderer {
|
2012-12-08 01:19:57 +01:00
|
|
|
|
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 23:20:06 +01:00
|
|
|
public function isOneUpRenderer() {
|
|
|
|
return false;
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function renderTextChange(
|
|
|
|
$range_start,
|
|
|
|
$range_len,
|
2012-12-12 02:16:11 +01:00
|
|
|
$rows) {
|
2012-12-08 01:19:57 +01:00
|
|
|
|
2013-01-11 01:06:39 +01:00
|
|
|
$hunk_starts = $this->getHunkStartLines();
|
2012-12-08 01:19:57 +01:00
|
|
|
|
|
|
|
$context_not_available = null;
|
2013-01-11 01:06:39 +01:00
|
|
|
if ($hunk_starts) {
|
2013-01-25 21:57:17 +01:00
|
|
|
$context_not_available = javelin_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'tr',
|
|
|
|
array(
|
|
|
|
'sigil' => 'context-target',
|
|
|
|
),
|
2013-01-18 04:15:06 +01:00
|
|
|
phutil_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'colspan' => 6,
|
|
|
|
'class' => 'show-more'
|
|
|
|
),
|
2013-02-19 22:33:10 +01:00
|
|
|
pht('Context not available.')));
|
2012-12-08 01:19:57 +01: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 18:37:49 +02:00
|
|
|
|
2012-12-08 01:19:57 +01:00
|
|
|
$old_lines = $this->getOldLines();
|
|
|
|
$new_lines = $this->getNewLines();
|
2012-12-12 02:16:11 +01:00
|
|
|
$gaps = $this->getGaps();
|
2012-12-08 01:19:57 +01:00
|
|
|
$reference = $this->getRenderingReference();
|
|
|
|
$left_id = $this->getOldChangesetID();
|
|
|
|
$right_id = $this->getNewChangesetID();
|
|
|
|
|
|
|
|
// "N" stands for 'new' and means the comment should attach to the new file
|
|
|
|
// when stored, i.e. DifferentialInlineComment->setIsNewFile().
|
|
|
|
// "O" stands for 'old' and means the comment should attach to the old file.
|
|
|
|
|
|
|
|
$left_char = $this->getOldAttachesToNewFile()
|
|
|
|
? 'N'
|
|
|
|
: 'O';
|
|
|
|
$right_char = $this->getNewAttachesToNewFile()
|
|
|
|
? 'N'
|
|
|
|
: 'O';
|
|
|
|
|
|
|
|
$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-12 02:16:11 +01:00
|
|
|
$depths = $this->getDepths();
|
|
|
|
$mask = $this->getMask();
|
2012-12-08 01:19:57 +01: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];
|
|
|
|
|
|
|
|
$end = $top + $len - 20;
|
|
|
|
|
|
|
|
$contents = array();
|
|
|
|
|
|
|
|
if ($len > 40) {
|
|
|
|
$is_first_block = false;
|
|
|
|
if ($ii == 0) {
|
|
|
|
$is_first_block = true;
|
|
|
|
}
|
|
|
|
|
2013-01-25 21:57:17 +01:00
|
|
|
$contents[] = javelin_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'sigil' => 'show-more',
|
|
|
|
'meta' => array(
|
|
|
|
'ref' => $reference,
|
|
|
|
'range' => "{$top}-{$len}/{$top}-20",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
$is_first_block
|
2013-01-24 22:18:44 +01:00
|
|
|
? pht("Show First 20 Lines")
|
|
|
|
: pht("\xE2\x96\xB2 Show 20 Lines"));
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
2013-01-25 21:57:17 +01:00
|
|
|
$contents[] = javelin_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'sigil' => 'show-more',
|
|
|
|
'meta' => array(
|
|
|
|
'type' => 'all',
|
|
|
|
'ref' => $reference,
|
|
|
|
'range' => "{$top}-{$len}/{$top}-{$len}",
|
|
|
|
),
|
|
|
|
),
|
2013-01-24 22:18:44 +01:00
|
|
|
pht('Show All %d Lines', $len));
|
2012-12-08 01:19:57 +01:00
|
|
|
|
|
|
|
$is_last_block = false;
|
|
|
|
if ($ii + $len >= $rows) {
|
|
|
|
$is_last_block = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($len > 40) {
|
2013-01-25 21:57:17 +01:00
|
|
|
$contents[] = javelin_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'sigil' => 'show-more',
|
|
|
|
'meta' => array(
|
|
|
|
'ref' => $reference,
|
|
|
|
'range' => "{$top}-{$len}/{$end}-20",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
$is_last_block
|
2013-01-24 22:18:44 +01:00
|
|
|
? pht("Show Last 20 Lines")
|
|
|
|
: pht("\xE2\x96\xBC Show 20 Lines"));
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$context = null;
|
|
|
|
$context_line = null;
|
|
|
|
if (!$is_last_block && $depths[$ii + $len]) {
|
|
|
|
for ($l = $ii + $len - 1; $l >= $ii; $l--) {
|
|
|
|
$line = $new_lines[$l]['text'];
|
|
|
|
if ($depths[$l] < $depths[$ii + $len] && trim($line) != '') {
|
|
|
|
$context = $new_render[$l];
|
|
|
|
$context_line = $new_lines[$l]['line'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-30 19:58:21 +01:00
|
|
|
$container = javelin_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'tr',
|
|
|
|
array(
|
|
|
|
'sigil' => 'context-target',
|
|
|
|
),
|
2013-01-30 19:58:21 +01:00
|
|
|
array(
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'colspan' => 2,
|
|
|
|
'class' => 'show-more',
|
|
|
|
),
|
2013-02-13 23:50:15 +01:00
|
|
|
phutil_implode_html(
|
2013-01-30 19:58:21 +01:00
|
|
|
" \xE2\x80\xA2 ", // Bullet
|
|
|
|
$contents)),
|
|
|
|
phutil_tag(
|
|
|
|
'th',
|
|
|
|
array(
|
|
|
|
'class' => 'show-context-line',
|
|
|
|
),
|
|
|
|
$context_line ? (int)$context_line : null),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'colspan' => 3,
|
|
|
|
'class' => 'show-context',
|
|
|
|
),
|
|
|
|
// TODO: [HTML] Escaping model here isn't ideal.
|
|
|
|
phutil_safe_html($context)),
|
|
|
|
));
|
2012-12-08 01:19:57 +01: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 18:37:49 +02:00
|
|
|
$o_classes = '';
|
2012-12-08 01:19:57 +01: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 18:37:49 +02:00
|
|
|
$o_class = 'comment';
|
2012-12-08 01:19:57 +01: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 18:37:49 +02:00
|
|
|
$o_class = 'old-rebase';
|
2012-12-08 01:19:57 +01: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 18:37:49 +02:00
|
|
|
$o_class = 'old old-full';
|
2012-12-08 01:19:57 +01:00
|
|
|
} else {
|
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 18:37:49 +02:00
|
|
|
$o_class = 'old';
|
2012-12-08 01:19:57 +01: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 18:37:49 +02:00
|
|
|
$o_classes = $o_class;
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
$n_copy = hsprintf('<td class="copy" />');
|
2012-12-08 01:19:57 +01: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 18:23:23 +01:00
|
|
|
$n_cov = phutil_tag('td', array('class' => "cov {$cov_class}"));
|
2012-12-08 01:19:57 +01: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 {
|
|
|
|
$n_class = 'new';
|
|
|
|
}
|
|
|
|
$n_classes = $n_class;
|
|
|
|
|
|
|
|
if ($new_lines[$ii]['type'] == '\\' || !isset($copy_lines[$n_num])) {
|
2013-11-11 18:23:23 +01:00
|
|
|
$n_copy = phutil_tag('td', array('class' => "copy {$n_class}"));
|
2012-12-08 01:19:57 +01: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 21:57:17 +01:00
|
|
|
$n_copy = javelin_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'meta' => array(
|
|
|
|
'msg' => $title,
|
|
|
|
),
|
|
|
|
'class' => 'copy '.$class,
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-11 01:06:39 +01:00
|
|
|
if (isset($hunk_starts[$o_num])) {
|
2012-12-08 01:19:57 +01:00
|
|
|
$html[] = $context_not_available;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($o_num && $left_id) {
|
2013-02-13 23:50:15 +01:00
|
|
|
$o_id = 'C'.$left_id.$left_char.'L'.$o_num;
|
2012-12-08 01:19:57 +01:00
|
|
|
} else {
|
|
|
|
$o_id = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($n_num && $right_id) {
|
2013-02-13 23:50:15 +01:00
|
|
|
$n_id = 'C'.$right_id.$right_char.'L'.$n_num;
|
2012-12-08 01:19:57 +01:00
|
|
|
} else {
|
|
|
|
$n_id = null;
|
|
|
|
}
|
|
|
|
|
2014-04-09 02:55:48 +02:00
|
|
|
// NOTE: This is a unicode zero-width space, which we use as a hint when
|
|
|
|
// intercepting 'copy' events to make sure sensible text ends up on the
|
|
|
|
// clipboard. See the 'phabricator-oncopy' behavior.
|
|
|
|
$zero_space = "\xE2\x80\x8B";
|
2013-11-11 18:23:23 +01:00
|
|
|
|
2012-12-08 01:19:57 +01:00
|
|
|
// NOTE: The Javascript is sensitive to whitespace changes in this
|
|
|
|
// block!
|
|
|
|
|
2013-11-11 18:23:23 +01:00
|
|
|
$html[] = phutil_tag('tr', array(), array(
|
2013-02-13 23:50:15 +01:00
|
|
|
phutil_tag('th', array('id' => $o_id), $o_num),
|
2013-11-11 18:23:23 +01:00
|
|
|
phutil_tag('td', array('class' => $o_classes), $o_text),
|
2013-02-13 23:50:15 +01:00
|
|
|
phutil_tag('th', array('id' => $n_id), $n_num),
|
|
|
|
$n_copy,
|
2013-11-11 18:23:23 +01:00
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array('class' => $n_classes, 'colspan' => $n_colspan),
|
2014-04-09 02:55:48 +02:00
|
|
|
array(
|
|
|
|
phutil_tag('span', array('class' => 'zwsp'), $zero_space),
|
|
|
|
$n_text
|
|
|
|
)),
|
2013-11-11 18:23:23 +01:00
|
|
|
$n_cov,
|
|
|
|
));
|
2012-12-08 01:19:57 +01:00
|
|
|
|
|
|
|
if ($context_not_available && ($ii == $rows - 1)) {
|
|
|
|
$html[] = $context_not_available;
|
|
|
|
}
|
|
|
|
|
|
|
|
$old_comments = $this->getOldComments();
|
|
|
|
$new_comments = $this->getNewComments();
|
|
|
|
|
|
|
|
if ($o_num && isset($old_comments[$o_num])) {
|
|
|
|
foreach ($old_comments[$o_num] as $comment) {
|
2012-12-12 02:16:11 +01:00
|
|
|
$comment_html = $this->renderInlineComment($comment,
|
|
|
|
$on_right = false);
|
2012-12-08 01:19:57 +01:00
|
|
|
$new = '';
|
|
|
|
if ($n_num && isset($new_comments[$n_num])) {
|
|
|
|
foreach ($new_comments[$n_num] as $key => $new_comment) {
|
|
|
|
if ($comment->isCompatible($new_comment)) {
|
|
|
|
$new = $this->renderInlineComment($new_comment,
|
|
|
|
$on_right = true);
|
|
|
|
unset($new_comments[$n_num][$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-11 18:23:23 +01:00
|
|
|
$html[] = phutil_tag('tr', array('class' => 'inline'), array(
|
|
|
|
phutil_tag('th', 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 18:37:49 +02:00
|
|
|
phutil_tag('td', array(), $comment_html),
|
2013-11-11 18:23:23 +01:00
|
|
|
phutil_tag('th', 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 18:37:49 +02:00
|
|
|
phutil_tag('td', array('colspan' => 3), $new),
|
2013-11-11 18:23:23 +01:00
|
|
|
));
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($n_num && isset($new_comments[$n_num])) {
|
|
|
|
foreach ($new_comments[$n_num] as $comment) {
|
2012-12-12 02:16:11 +01:00
|
|
|
$comment_html = $this->renderInlineComment($comment,
|
|
|
|
$on_right = true);
|
2013-11-11 18:23:23 +01:00
|
|
|
$html[] = phutil_tag('tr', array('class' => 'inline'), array(
|
|
|
|
phutil_tag('th', 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 18:37:49 +02:00
|
|
|
phutil_tag('td', array()),
|
2013-11-11 18:23:23 +01:00
|
|
|
phutil_tag('th', array()),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
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 18:37:49 +02:00
|
|
|
array('colspan' => 3),
|
2013-11-11 18:23:23 +01:00
|
|
|
$comment_html),
|
|
|
|
));
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
return $this->wrapChangeInTable(phutil_implode_html('', $html));
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function renderFileChange($old_file = null,
|
|
|
|
$new_file = null,
|
|
|
|
$id = 0,
|
|
|
|
$vs = 0) {
|
|
|
|
$old = null;
|
|
|
|
if ($old_file) {
|
2013-01-18 03:47:13 +01:00
|
|
|
$old = phutil_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-image-stage'
|
|
|
|
),
|
2013-01-18 03:39:02 +01:00
|
|
|
phutil_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'img',
|
|
|
|
array(
|
|
|
|
'src' => $old_file->getBestURI(),
|
2013-02-19 22:33:10 +01:00
|
|
|
)));
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$new = null;
|
|
|
|
if ($new_file) {
|
2013-01-18 03:47:13 +01:00
|
|
|
$new = phutil_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-image-stage'
|
|
|
|
),
|
2013-01-18 03:39:02 +01:00
|
|
|
phutil_tag(
|
2012-12-08 01:19:57 +01:00
|
|
|
'img',
|
|
|
|
array(
|
|
|
|
'src' => $new_file->getBestURI(),
|
2013-02-19 22:33:10 +01:00
|
|
|
)));
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$html_old = array();
|
|
|
|
$html_new = array();
|
2012-12-21 23:16:00 +01:00
|
|
|
foreach ($this->getOldComments() as $on_line => $comment_group) {
|
|
|
|
foreach ($comment_group as $comment) {
|
|
|
|
$comment_html = $this->renderInlineComment($comment, $on_right = false);
|
2013-11-11 18:23:23 +01:00
|
|
|
$html_old[] = phutil_tag('tr', array('class' => 'inline'), array(
|
|
|
|
phutil_tag('th', 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 18:37:49 +02:00
|
|
|
phutil_tag('td', array(), $comment_html),
|
2013-11-11 18:23:23 +01:00
|
|
|
phutil_tag('th', 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 18:37:49 +02:00
|
|
|
phutil_tag('td', array('colspan' => 3)),
|
2013-11-11 18:23:23 +01:00
|
|
|
));
|
2012-12-21 23:16:00 +01:00
|
|
|
}
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
2012-12-21 23:16:00 +01:00
|
|
|
foreach ($this->getNewComments() as $lin_line => $comment_group) {
|
|
|
|
foreach ($comment_group as $comment) {
|
|
|
|
$comment_html = $this->renderInlineComment($comment, $on_right = true);
|
2013-11-11 18:23:23 +01:00
|
|
|
$html_new[] = phutil_tag('tr', array('class' => 'inline'), array(
|
|
|
|
phutil_tag('th', 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 18:37:49 +02:00
|
|
|
phutil_tag('td', array()),
|
2013-11-11 18:23:23 +01:00
|
|
|
phutil_tag('th', array()),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
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 18:37:49 +02:00
|
|
|
array('colspan' => 3),
|
2013-11-11 18:23:23 +01:00
|
|
|
$comment_html),
|
|
|
|
));
|
2012-12-21 23:16:00 +01:00
|
|
|
}
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$old) {
|
2013-11-11 18:23:23 +01:00
|
|
|
$th_old = phutil_tag('th', array());
|
2012-12-08 01:19:57 +01:00
|
|
|
} else {
|
2013-11-11 18:23:23 +01:00
|
|
|
$th_old = phutil_tag('th', array('id' => "C{$vs}OL1"), 1);
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$new) {
|
2013-11-11 18:23:23 +01:00
|
|
|
$th_new = phutil_tag('th', array());
|
2012-12-08 01:19:57 +01:00
|
|
|
} else {
|
2013-11-11 18:23:23 +01:00
|
|
|
$th_new = phutil_tag('th', array('id' => "C{$id}OL1"), 1);
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
2014-04-04 00:11:06 +02:00
|
|
|
$output = hsprintf(
|
2012-12-08 01:19:57 +01:00
|
|
|
'<tr class="differential-image-diff">'.
|
2013-02-13 23:50:15 +01: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 18:37:49 +02:00
|
|
|
'<td class="differential-old-image">%s</td>'.
|
2013-02-13 23:50:15 +01: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 18:37:49 +02:00
|
|
|
'<td class="differential-new-image" colspan="3">%s</td>'.
|
2012-12-08 01:19:57 +01:00
|
|
|
'</tr>'.
|
2013-02-13 23:50:15 +01:00
|
|
|
'%s'.
|
|
|
|
'%s',
|
|
|
|
$th_old,
|
|
|
|
$old,
|
|
|
|
$th_new,
|
|
|
|
$new,
|
|
|
|
phutil_implode_html('', $html_old),
|
|
|
|
phutil_implode_html('', $html_new));
|
2012-12-08 01:19:57 +01:00
|
|
|
|
2013-01-15 17:07:40 +01:00
|
|
|
$output = $this->wrapChangeInTable($output);
|
|
|
|
|
|
|
|
return $this->renderChangesetTable($output);
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|