2012-12-08 01:19:57 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class DifferentialChangesetRenderer {
|
|
|
|
|
|
|
|
private $user;
|
|
|
|
private $changeset;
|
|
|
|
private $renderingReference;
|
|
|
|
private $renderPropertyChangeHeader;
|
2013-09-13 01:00:00 +02:00
|
|
|
private $isTopLevel;
|
2013-01-11 01:06:39 +01:00
|
|
|
private $hunkStartLines;
|
2012-12-08 01:19:57 +01:00
|
|
|
private $oldLines;
|
|
|
|
private $newLines;
|
|
|
|
private $oldComments;
|
|
|
|
private $newComments;
|
|
|
|
private $oldChangesetID;
|
|
|
|
private $newChangesetID;
|
|
|
|
private $oldAttachesToNewFile;
|
|
|
|
private $newAttachesToNewFile;
|
|
|
|
private $highlightOld = array();
|
|
|
|
private $highlightNew = array();
|
|
|
|
private $codeCoverage;
|
|
|
|
private $handles;
|
|
|
|
private $markupEngine;
|
|
|
|
private $oldRender;
|
|
|
|
private $newRender;
|
|
|
|
private $originalOld;
|
|
|
|
private $originalNew;
|
2012-12-12 02:16:11 +01:00
|
|
|
private $gaps;
|
|
|
|
private $mask;
|
|
|
|
private $depths;
|
2014-06-20 20:49:41 +02:00
|
|
|
private $originalCharacterEncoding;
|
|
|
|
|
|
|
|
public function setOriginalCharacterEncoding($original_character_encoding) {
|
|
|
|
$this->originalCharacterEncoding = $original_character_encoding;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOriginalCharacterEncoding() {
|
|
|
|
return $this->originalCharacterEncoding;
|
|
|
|
}
|
2012-12-12 02:16:11 +01:00
|
|
|
|
|
|
|
public function setDepths($depths) {
|
|
|
|
$this->depths = $depths;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getDepths() {
|
|
|
|
return $this->depths;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMask($mask) {
|
|
|
|
$this->mask = $mask;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getMask() {
|
|
|
|
return $this->mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setGaps($gaps) {
|
|
|
|
$this->gaps = $gaps;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getGaps() {
|
|
|
|
return $this->gaps;
|
|
|
|
}
|
2012-12-08 01:19:57 +01:00
|
|
|
|
|
|
|
public function setOriginalNew($original_new) {
|
|
|
|
$this->originalNew = $original_new;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getOriginalNew() {
|
|
|
|
return $this->originalNew;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOriginalOld($original_old) {
|
|
|
|
$this->originalOld = $original_old;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getOriginalOld() {
|
|
|
|
return $this->originalOld;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNewRender($new_render) {
|
|
|
|
$this->newRender = $new_render;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getNewRender() {
|
|
|
|
return $this->newRender;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOldRender($old_render) {
|
|
|
|
$this->oldRender = $old_render;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getOldRender() {
|
|
|
|
return $this->oldRender;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) {
|
|
|
|
$this->markupEngine = $markup_engine;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getMarkupEngine() {
|
|
|
|
return $this->markupEngine;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHandles(array $handles) {
|
|
|
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
|
|
|
$this->handles = $handles;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getHandles() {
|
|
|
|
return $this->handles;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCodeCoverage($code_coverage) {
|
|
|
|
$this->codeCoverage = $code_coverage;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getCodeCoverage() {
|
|
|
|
return $this->codeCoverage;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHighlightNew($highlight_new) {
|
|
|
|
$this->highlightNew = $highlight_new;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getHighlightNew() {
|
|
|
|
return $this->highlightNew;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHighlightOld($highlight_old) {
|
|
|
|
$this->highlightOld = $highlight_old;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getHighlightOld() {
|
|
|
|
return $this->highlightOld;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNewAttachesToNewFile($attaches) {
|
|
|
|
$this->newAttachesToNewFile = $attaches;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getNewAttachesToNewFile() {
|
|
|
|
return $this->newAttachesToNewFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOldAttachesToNewFile($attaches) {
|
|
|
|
$this->oldAttachesToNewFile = $attaches;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getOldAttachesToNewFile() {
|
|
|
|
return $this->oldAttachesToNewFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNewChangesetID($new_changeset_id) {
|
|
|
|
$this->newChangesetID = $new_changeset_id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getNewChangesetID() {
|
|
|
|
return $this->newChangesetID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOldChangesetID($old_changeset_id) {
|
|
|
|
$this->oldChangesetID = $old_changeset_id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getOldChangesetID() {
|
|
|
|
return $this->oldChangesetID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNewComments(array $new_comments) {
|
|
|
|
foreach ($new_comments as $line_number => $comments) {
|
|
|
|
assert_instances_of($comments, 'PhabricatorInlineCommentInterface');
|
|
|
|
}
|
|
|
|
$this->newComments = $new_comments;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getNewComments() {
|
|
|
|
return $this->newComments;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOldComments(array $old_comments) {
|
|
|
|
foreach ($old_comments as $line_number => $comments) {
|
|
|
|
assert_instances_of($comments, 'PhabricatorInlineCommentInterface');
|
|
|
|
}
|
|
|
|
$this->oldComments = $old_comments;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getOldComments() {
|
|
|
|
return $this->oldComments;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNewLines(array $new_lines) {
|
|
|
|
$this->newLines = $new_lines;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getNewLines() {
|
|
|
|
return $this->newLines;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOldLines(array $old_lines) {
|
|
|
|
$this->oldLines = $old_lines;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getOldLines() {
|
|
|
|
return $this->oldLines;
|
|
|
|
}
|
|
|
|
|
2013-01-11 01:06:39 +01:00
|
|
|
public function setHunkStartLines(array $hunk_start_lines) {
|
|
|
|
$this->hunkStartLines = $hunk_start_lines;
|
2012-12-08 01:19:57 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-01-11 01:06:39 +01:00
|
|
|
protected function getHunkStartLines() {
|
|
|
|
return $this->hunkStartLines;
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setUser(PhabricatorUser $user) {
|
|
|
|
$this->user = $user;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getUser() {
|
|
|
|
return $this->user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setChangeset(DifferentialChangeset $changeset) {
|
|
|
|
$this->changeset = $changeset;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getChangeset() {
|
|
|
|
return $this->changeset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRenderingReference($rendering_reference) {
|
|
|
|
$this->renderingReference = $rendering_reference;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
protected function getRenderingReference() {
|
|
|
|
return $this->renderingReference;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRenderPropertyChangeHeader($should_render) {
|
|
|
|
$this->renderPropertyChangeHeader = $should_render;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
private function shouldRenderPropertyChangeHeader() {
|
|
|
|
return $this->renderPropertyChangeHeader;
|
|
|
|
}
|
|
|
|
|
2013-09-13 01:00:00 +02:00
|
|
|
public function setIsTopLevel($is) {
|
|
|
|
$this->isTopLevel = $is;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
private function getIsTopLevel() {
|
|
|
|
return $this->isTopLevel;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
final public function renderChangesetTable($content) {
|
|
|
|
$props = null;
|
|
|
|
if ($this->shouldRenderPropertyChangeHeader()) {
|
|
|
|
$props = $this->renderPropertyChangeHeader();
|
|
|
|
}
|
|
|
|
|
2013-09-13 01:00:00 +02:00
|
|
|
$notice = null;
|
|
|
|
if ($this->getIsTopLevel()) {
|
|
|
|
$force = (!$content && !$props);
|
|
|
|
$notice = $this->renderChangeTypeHeader($force);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
$result = $notice.$props.$content;
|
|
|
|
|
|
|
|
// TODO: Let the user customize their tab width / display style.
|
|
|
|
// TODO: We should possibly post-process "\r" as well.
|
|
|
|
// TODO: Both these steps should happen earlier.
|
|
|
|
$result = str_replace("\t", ' ', $result);
|
|
|
|
|
2013-02-17 15:37:02 +01:00
|
|
|
return phutil_safe_html($result);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
abstract public function isOneUpRenderer();
|
2012-12-08 01:19:57 +01:00
|
|
|
abstract public function renderTextChange(
|
|
|
|
$range_start,
|
|
|
|
$range_len,
|
2013-02-19 22:47:03 +01:00
|
|
|
$rows);
|
2012-12-08 01:19:57 +01:00
|
|
|
abstract public function renderFileChange(
|
2013-01-11 01:06:39 +01:00
|
|
|
$old = null,
|
|
|
|
$new = null,
|
|
|
|
$id = 0,
|
2013-02-19 22:47:03 +01:00
|
|
|
$vs = 0);
|
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
|
|
|
abstract protected function renderChangeTypeHeader($force);
|
|
|
|
|
|
|
|
protected function didRenderChangesetTableContents($contents) {
|
|
|
|
return $contents;
|
|
|
|
}
|
|
|
|
|
Fix whitespace and unchanged file shields
Summary:
Fixes T181. I actually have no idea what the original issue in T181 was, but this fixes several problems:
- The code for figuring out whitespace-only changes was extremely confusing and probably buggy (the code for figuring out unchanged files was equally confusing but probably less buggy).
- When rendering a whitespace shield, we did not offer a "Show Changes" link. Instead, show the "Show Changes" link: we can always render the content beneath this link.
- When clicking "Show Changes", we used the current whitespace mode, which might result in a diff with no changes. Instead, force "show all" whitespace mode.
- We never offered a "show changes" link for unchanged files. Instead, offer this link if we can service it.
- When clicking "Show Changes", we pierced the shield but didn't force file content, which would fold the entire file even if it was available. Instead, force the file content.
Test Plan: Generated whitespace-only and no-change diffs. Clicked shield links, or verified no shield link available in no-change-with-no-content. Generated an "@generated" change, verified shield worked correctly.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T181, T2009
Differential Revision: https://secure.phabricator.com/D4407
2013-01-12 00:27:42 +01:00
|
|
|
/**
|
|
|
|
* Render a "shield" over the diff, with a message like "This file is
|
|
|
|
* generated and does not need to be reviewed." or "This file was completely
|
|
|
|
* deleted." This UI element hides unimportant text so the reviewer doesn't
|
|
|
|
* need to scroll past it.
|
|
|
|
*
|
|
|
|
* The shield includes a link to view the underlying content. This link
|
|
|
|
* may force certain rendering modes when the link is clicked:
|
|
|
|
*
|
|
|
|
* - `"default"`: Render the diff normally, as though it was not
|
|
|
|
* shielded. This is the default and appropriate if the underlying
|
|
|
|
* diff is a normal change, but was hidden for reasons of not being
|
|
|
|
* important (e.g., generated code).
|
|
|
|
* - `"text"`: Force the text to be shown. This is probably only relevant
|
|
|
|
* when a file is not changed.
|
|
|
|
* - `"whitespace"`: Force the text to be shown, and the diff to be
|
|
|
|
* rendered with all whitespace shown. This is probably only relevant
|
|
|
|
* when a file is changed only by altering whitespace.
|
|
|
|
* - `"none"`: Don't show the link (e.g., text not available).
|
|
|
|
*
|
|
|
|
* @param string Message explaining why the diff is hidden.
|
|
|
|
* @param string|null Force mode, see above.
|
|
|
|
* @return string Shield markup.
|
|
|
|
*/
|
2013-01-14 23:20:54 +01:00
|
|
|
abstract public function renderShield($message, $force = 'default');
|
Fix whitespace and unchanged file shields
Summary:
Fixes T181. I actually have no idea what the original issue in T181 was, but this fixes several problems:
- The code for figuring out whitespace-only changes was extremely confusing and probably buggy (the code for figuring out unchanged files was equally confusing but probably less buggy).
- When rendering a whitespace shield, we did not offer a "Show Changes" link. Instead, show the "Show Changes" link: we can always render the content beneath this link.
- When clicking "Show Changes", we used the current whitespace mode, which might result in a diff with no changes. Instead, force "show all" whitespace mode.
- We never offered a "show changes" link for unchanged files. Instead, offer this link if we can service it.
- When clicking "Show Changes", we pierced the shield but didn't force file content, which would fold the entire file even if it was available. Instead, force the file content.
Test Plan: Generated whitespace-only and no-change diffs. Clicked shield links, or verified no shield link available in no-change-with-no-content. Generated an "@generated" change, verified shield worked correctly.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T181, T2009
Differential Revision: https://secure.phabricator.com/D4407
2013-01-12 00:27:42 +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
|
|
|
abstract protected function renderPropertyChangeHeader();
|
Fix whitespace and unchanged file shields
Summary:
Fixes T181. I actually have no idea what the original issue in T181 was, but this fixes several problems:
- The code for figuring out whitespace-only changes was extremely confusing and probably buggy (the code for figuring out unchanged files was equally confusing but probably less buggy).
- When rendering a whitespace shield, we did not offer a "Show Changes" link. Instead, show the "Show Changes" link: we can always render the content beneath this link.
- When clicking "Show Changes", we used the current whitespace mode, which might result in a diff with no changes. Instead, force "show all" whitespace mode.
- We never offered a "show changes" link for unchanged files. Instead, offer this link if we can service it.
- When clicking "Show Changes", we pierced the shield but didn't force file content, which would fold the entire file even if it was available. Instead, force the file content.
Test Plan: Generated whitespace-only and no-change diffs. Clicked shield links, or verified no shield link available in no-change-with-no-content. Generated an "@generated" change, verified shield worked correctly.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T181, T2009
Differential Revision: https://secure.phabricator.com/D4407
2013-01-12 00:27:42 +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
|
|
|
protected function buildPrimitives($range_start, $range_len) {
|
|
|
|
$primitives = array();
|
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
|
|
|
$hunk_starts = $this->getHunkStartLines();
|
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
|
|
|
$mask = $this->getMask();
|
|
|
|
$gaps = $this->getGaps();
|
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
|
|
|
$old = $this->getOldLines();
|
|
|
|
$new = $this->getNewLines();
|
|
|
|
$old_render = $this->getOldRender();
|
|
|
|
$new_render = $this->getNewRender();
|
|
|
|
$old_comments = $this->getOldComments();
|
|
|
|
$new_comments = $this->getNewComments();
|
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
|
|
|
$size = count($old);
|
|
|
|
for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) {
|
|
|
|
if (empty($mask[$ii])) {
|
|
|
|
list($top, $len) = array_pop($gaps);
|
|
|
|
$primitives[] = array(
|
|
|
|
'type' => 'context',
|
|
|
|
'top' => $top,
|
|
|
|
'len' => $len,
|
|
|
|
);
|
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
|
|
|
$ii += ($len - 1);
|
|
|
|
continue;
|
|
|
|
}
|
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
|
|
|
$ospec = array(
|
|
|
|
'type' => 'old',
|
|
|
|
'htype' => null,
|
|
|
|
'cursor' => $ii,
|
|
|
|
'line' => null,
|
2013-01-14 23:20:35 +01:00
|
|
|
'oline' => null,
|
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
|
|
|
'render' => null,
|
|
|
|
);
|
|
|
|
|
|
|
|
$nspec = array(
|
|
|
|
'type' => 'new',
|
|
|
|
'htype' => null,
|
|
|
|
'cursor' => $ii,
|
|
|
|
'line' => null,
|
2013-01-14 23:20:35 +01:00
|
|
|
'oline' => null,
|
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
|
|
|
'render' => null,
|
|
|
|
'copy' => null,
|
|
|
|
'coverage' => null,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (isset($old[$ii])) {
|
2013-01-14 23:20:35 +01:00
|
|
|
$ospec['line'] = (int)$old[$ii]['line'];
|
|
|
|
$nspec['oline'] = (int)$old[$ii]['line'];
|
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
|
|
|
$ospec['htype'] = $old[$ii]['type'];
|
|
|
|
if (isset($old_render[$ii])) {
|
|
|
|
$ospec['render'] = $old_render[$ii];
|
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
|
|
|
}
|
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
|
|
|
if (isset($new[$ii])) {
|
2013-01-14 23:20:35 +01:00
|
|
|
$nspec['line'] = (int)$new[$ii]['line'];
|
|
|
|
$ospec['oline'] = (int)$new[$ii]['line'];
|
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
|
|
|
$nspec['htype'] = $new[$ii]['type'];
|
|
|
|
if (isset($new_render[$ii])) {
|
|
|
|
$nspec['render'] = $new_render[$ii];
|
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
|
|
|
}
|
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
|
|
|
if (isset($hunk_starts[$ospec['line']])) {
|
|
|
|
$primitives[] = array(
|
|
|
|
'type' => 'no-context',
|
|
|
|
);
|
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
|
|
|
$primitives[] = $ospec;
|
|
|
|
$primitives[] = $nspec;
|
|
|
|
|
|
|
|
if ($ospec['line'] !== null && isset($old_comments[$ospec['line']])) {
|
|
|
|
foreach ($old_comments[$ospec['line']] as $comment) {
|
|
|
|
$primitives[] = array(
|
|
|
|
'type' => 'inline',
|
|
|
|
'comment' => $comment,
|
|
|
|
'right' => false,
|
|
|
|
);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
if ($nspec['line'] !== null && isset($new_comments[$nspec['line']])) {
|
|
|
|
foreach ($new_comments[$nspec['line']] as $comment) {
|
|
|
|
$primitives[] = array(
|
|
|
|
'type' => 'inline',
|
2013-01-14 23:20:35 +01:00
|
|
|
'comment' => $comment,
|
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
|
|
|
'right' => true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($hunk_starts && ($ii == $size - 1)) {
|
|
|
|
$primitives[] = array(
|
|
|
|
'type' => 'no-context',
|
|
|
|
);
|
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
|
|
|
if ($this->isOneUpRenderer()) {
|
|
|
|
$primitives = $this->processPrimitivesForOneUp($primitives);
|
|
|
|
}
|
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
|
|
|
return $primitives;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function processPrimitivesForOneUp(array $primitives) {
|
|
|
|
// Primitives come out of buildPrimitives() in two-up format, because it
|
|
|
|
// is the most general, flexible format. To put them into one-up format,
|
|
|
|
// we need to filter and reorder them. In particular:
|
|
|
|
//
|
|
|
|
// - We discard unchanged lines in the old file; in one-up format, we
|
|
|
|
// render them only once.
|
|
|
|
// - We group contiguous blocks of old-modified and new-modified lines, so
|
|
|
|
// they render in "block of old, block of new" order instead of
|
|
|
|
// alternating old and new lines.
|
|
|
|
|
|
|
|
$out = array();
|
|
|
|
|
|
|
|
$old_buf = array();
|
|
|
|
$new_buf = array();
|
|
|
|
foreach ($primitives as $primitive) {
|
|
|
|
$type = $primitive['type'];
|
2013-01-14 23:20:35 +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
|
|
|
if ($type == 'old') {
|
|
|
|
if (!$primitive['htype']) {
|
|
|
|
// This is a line which appears in both the old file and the new
|
|
|
|
// file, or the spacer corresponding to a line added in the new file.
|
|
|
|
// Ignore it when rendering a one-up diff.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($new_buf) {
|
|
|
|
$out[] = $new_buf;
|
|
|
|
$new_buf = array();
|
|
|
|
}
|
|
|
|
$old_buf[] = $primitive;
|
|
|
|
} else if ($type == 'new') {
|
|
|
|
if ($primitive['line'] === null) {
|
|
|
|
// This is an empty spacer corresponding to a line removed from the
|
|
|
|
// old file. Ignore it when rendering a one-up diff.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($old_buf) {
|
|
|
|
$out[] = $old_buf;
|
|
|
|
$old_buf = array();
|
|
|
|
}
|
|
|
|
$new_buf[] = $primitive;
|
|
|
|
} else if ($type == 'context' || $type == 'no-context') {
|
|
|
|
$out[] = $old_buf;
|
|
|
|
$out[] = $new_buf;
|
|
|
|
$old_buf = array();
|
|
|
|
$new_buf = array();
|
|
|
|
$out[] = array($primitive);
|
|
|
|
} else if ($type == 'inline') {
|
2013-01-14 23:20:35 +01:00
|
|
|
$out[] = $old_buf;
|
|
|
|
$out[] = $new_buf;
|
|
|
|
$old_buf = array();
|
|
|
|
$new_buf = array();
|
|
|
|
|
|
|
|
$out[] = array($primitive);
|
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
|
|
|
} else {
|
|
|
|
throw new Exception("Unknown primitive type '{$primitive}'!");
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
$out[] = $old_buf;
|
|
|
|
$out[] = $new_buf;
|
|
|
|
$out = array_mergev($out);
|
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
|
|
|
return $out;
|
2012-12-08 01:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|