mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
c82066408d
Summary: See D11468 and D11465. Fixes T5163. Fixes T4105. This makes it practical to test shields, unshielding, moves, etc. This fixes the issue in D11468, where line maps from whitespace-ignored hunks could have fewer lines than line maps from whitespace-respected hunks, causing a warning. This encodes the behavior which D11465 changed, making it the canon behavior. Specifically, we do **not** show a shield. I think this is correct. It seems misleading to show "the contents of this file were not changed", because they were changed in both the sense that the file was completely removed, and also changed in the sense that the content itself was (or may have been) changed at the destination. Instead, we just show nothing. Test Plan: - Added test coverage. - Ran tests. - Used `arc diff --raw --browse` to verify that web behavior was consistent with CLI/test behavior. Reviewers: joshuaspence, btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4105, T5163 Differential Revision: https://secure.phabricator.com/D11970
129 lines
2.9 KiB
PHP
129 lines
2.9 KiB
PHP
<?php
|
|
|
|
abstract class DifferentialChangesetTestRenderer
|
|
extends DifferentialChangesetRenderer {
|
|
|
|
protected function renderChangeTypeHeader($force) {
|
|
$changeset = $this->getChangeset();
|
|
|
|
$old = nonempty($changeset->getOldFile(), '-');
|
|
$current = nonempty($changeset->getFilename(), '-');
|
|
$away = nonempty(implode(', ', $changeset->getAwayPaths()), '-');
|
|
|
|
$ctype = $changeset->getChangeType();
|
|
$ftype = $changeset->getFileType();
|
|
$force = ($force ? '(forced)' : '(unforced)');
|
|
|
|
return "CTYPE {$ctype} {$ftype} {$force}\n".
|
|
"{$old}\n".
|
|
"{$current}\n".
|
|
"{$away}\n";
|
|
}
|
|
|
|
public function renderShield($message, $force = 'default') {
|
|
return "SHIELD ({$force}) {$message}\n";
|
|
}
|
|
|
|
protected function renderPropertyChangeHeader() {
|
|
$changeset = $this->getChangeset();
|
|
list($old, $new) = $this->getChangesetProperties($changeset);
|
|
|
|
if (!$old && !$new) {
|
|
return null;
|
|
}
|
|
|
|
$props = '';
|
|
foreach ($old as $key => $value) {
|
|
$props .= "P - {$key} {$value}~\n";
|
|
}
|
|
foreach ($new as $key => $value) {
|
|
$props .= "P + {$key} {$value}~\n";
|
|
}
|
|
|
|
return "PROPERTIES\n".$props;
|
|
}
|
|
|
|
public function renderTextChange(
|
|
$range_start,
|
|
$range_len,
|
|
$rows) {
|
|
|
|
$out = array();
|
|
|
|
$any_old = false;
|
|
$any_new = false;
|
|
$primitives = $this->buildPrimitives($range_start, $range_len);
|
|
foreach ($primitives as $p) {
|
|
$type = $p['type'];
|
|
switch ($type) {
|
|
case 'old':
|
|
case 'new':
|
|
if ($type == 'old') {
|
|
$any_old = true;
|
|
}
|
|
if ($type == 'new') {
|
|
$any_new = true;
|
|
}
|
|
$num = nonempty($p['line'], '-');
|
|
$render = $p['render'];
|
|
$htype = nonempty($p['htype'], '.');
|
|
|
|
// TODO: This should probably happen earlier, whenever we deal with
|
|
// \r and \t normalization?
|
|
$render = str_replace(
|
|
array(
|
|
"\r",
|
|
"\n",
|
|
),
|
|
array(
|
|
'\\r',
|
|
'\\n',
|
|
),
|
|
$render);
|
|
|
|
$render = str_replace(
|
|
array(
|
|
'<span class="bright">',
|
|
'</span>',
|
|
),
|
|
array(
|
|
'{(',
|
|
')}',
|
|
),
|
|
$render);
|
|
|
|
$render = html_entity_decode($render);
|
|
|
|
$t = ($type == 'old') ? 'O' : 'N';
|
|
|
|
$out[] = "{$t} {$num} {$htype} {$render}~";
|
|
break;
|
|
default:
|
|
$out[] = $type;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!$any_old) {
|
|
$out[] = 'O X <EMPTY>';
|
|
}
|
|
|
|
if (!$any_new) {
|
|
$out[] = 'N X <EMPTY>';
|
|
}
|
|
|
|
$out = implode("\n", $out)."\n";
|
|
return $out;
|
|
}
|
|
|
|
|
|
public function renderFileChange(
|
|
$old_file = null,
|
|
$new_file = null,
|
|
$id = 0,
|
|
$vs = 0) {
|
|
|
|
throw new PhutilMethodNotImplementedException();
|
|
}
|
|
|
|
}
|