mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-16 16:58:38 +01:00
Remove all whitespace options/configuration everywhere
Summary: Depends on D20181. Depends on D20182. Fixes T3498. Ref T13161. My claim, at least, is that D20181 can be tweaked to be good enough to throw away this "feature" completely. I think this feature was sort of a mistake, where the ease of access to `diff -bw` shaped behavior a very long time ago and then the train just ran a long way down the tracks in the same direction. Test Plan: Grepped for `whitespace`, deleted almost everything. Poked around the UI a bit. I'm expecting the whitespace changes to get some more iteration this week so I not being hugely pedantic about testing this stuff exhaustively. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13161, T3498 Differential Revision: https://secure.phabricator.com/D20185
This commit is contained in:
parent
661c758ff9
commit
5310f1cdd9
23 changed files with 33 additions and 375 deletions
|
@ -12,7 +12,7 @@ return array(
|
||||||
'core.pkg.css' => '261ee8cf',
|
'core.pkg.css' => '261ee8cf',
|
||||||
'core.pkg.js' => '5ace8a1e',
|
'core.pkg.js' => '5ace8a1e',
|
||||||
'differential.pkg.css' => 'c3f15714',
|
'differential.pkg.css' => 'c3f15714',
|
||||||
'differential.pkg.js' => '67c9ea4c',
|
'differential.pkg.js' => 'be031567',
|
||||||
'diffusion.pkg.css' => '42c75c37',
|
'diffusion.pkg.css' => '42c75c37',
|
||||||
'diffusion.pkg.js' => '91192d85',
|
'diffusion.pkg.js' => '91192d85',
|
||||||
'maniphest.pkg.css' => '35995d6d',
|
'maniphest.pkg.css' => '35995d6d',
|
||||||
|
@ -374,7 +374,7 @@ return array(
|
||||||
'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => '076bd092',
|
'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => '076bd092',
|
||||||
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9',
|
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9',
|
||||||
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '9b1cbd76',
|
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '9b1cbd76',
|
||||||
'rsrc/js/application/diff/DiffChangeset.js' => 'e7cf10d6',
|
'rsrc/js/application/diff/DiffChangeset.js' => 'd0a85a85',
|
||||||
'rsrc/js/application/diff/DiffChangesetList.js' => 'b91204e9',
|
'rsrc/js/application/diff/DiffChangesetList.js' => 'b91204e9',
|
||||||
'rsrc/js/application/diff/DiffInline.js' => 'a4a14a94',
|
'rsrc/js/application/diff/DiffInline.js' => 'a4a14a94',
|
||||||
'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17',
|
'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17',
|
||||||
|
@ -753,7 +753,7 @@ return array(
|
||||||
'phabricator-darklog' => '3b869402',
|
'phabricator-darklog' => '3b869402',
|
||||||
'phabricator-darkmessage' => '26cd4b73',
|
'phabricator-darkmessage' => '26cd4b73',
|
||||||
'phabricator-dashboard-css' => '4267d6c6',
|
'phabricator-dashboard-css' => '4267d6c6',
|
||||||
'phabricator-diff-changeset' => 'e7cf10d6',
|
'phabricator-diff-changeset' => 'd0a85a85',
|
||||||
'phabricator-diff-changeset-list' => 'b91204e9',
|
'phabricator-diff-changeset-list' => 'b91204e9',
|
||||||
'phabricator-diff-inline' => 'a4a14a94',
|
'phabricator-diff-inline' => 'a4a14a94',
|
||||||
'phabricator-drag-and-drop-file-upload' => '4370900d',
|
'phabricator-drag-and-drop-file-upload' => '4370900d',
|
||||||
|
@ -1973,6 +1973,17 @@ return array(
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
'javelin-util',
|
'javelin-util',
|
||||||
),
|
),
|
||||||
|
'd0a85a85' => array(
|
||||||
|
'javelin-dom',
|
||||||
|
'javelin-util',
|
||||||
|
'javelin-stratcom',
|
||||||
|
'javelin-install',
|
||||||
|
'javelin-workflow',
|
||||||
|
'javelin-router',
|
||||||
|
'javelin-behavior-device',
|
||||||
|
'javelin-vector',
|
||||||
|
'phabricator-diff-inline',
|
||||||
|
),
|
||||||
'd12d214f' => array(
|
'd12d214f' => array(
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
|
@ -2038,17 +2049,6 @@ return array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
'phabricator-draggable-list',
|
'phabricator-draggable-list',
|
||||||
),
|
),
|
||||||
'e7cf10d6' => array(
|
|
||||||
'javelin-dom',
|
|
||||||
'javelin-util',
|
|
||||||
'javelin-stratcom',
|
|
||||||
'javelin-install',
|
|
||||||
'javelin-workflow',
|
|
||||||
'javelin-router',
|
|
||||||
'javelin-behavior-device',
|
|
||||||
'javelin-vector',
|
|
||||||
'phabricator-diff-inline',
|
|
||||||
),
|
|
||||||
'e8240b50' => array(
|
'e8240b50' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
|
|
@ -533,6 +533,8 @@ final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck {
|
||||||
'This ancient extension point has been replaced with other '.
|
'This ancient extension point has been replaced with other '.
|
||||||
'mechanisms, including "AphrontSite".'),
|
'mechanisms, including "AphrontSite".'),
|
||||||
|
|
||||||
|
'differential.whitespace-matters' => pht(
|
||||||
|
'Whitespace rendering is now handled automatically.'),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $ancient_config;
|
return $ancient_config;
|
||||||
|
|
|
@ -31,7 +31,6 @@ final class DifferentialParseRenderTestCase extends PhabricatorTestCase {
|
||||||
foreach (array('one', 'two') as $type) {
|
foreach (array('one', 'two') as $type) {
|
||||||
$this->runParser($type, $data, $file, 'expect');
|
$this->runParser($type, $data, $file, 'expect');
|
||||||
$this->runParser($type, $data, $file, 'unshielded');
|
$this->runParser($type, $data, $file, 'unshielded');
|
||||||
$this->runParser($type, $data, $file, 'whitespace');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,25 +43,20 @@ final class DifferentialParseRenderTestCase extends PhabricatorTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$unshielded = false;
|
$unshielded = false;
|
||||||
$whitespace = false;
|
|
||||||
switch ($extension) {
|
switch ($extension) {
|
||||||
case 'unshielded':
|
case 'unshielded':
|
||||||
$unshielded = true;
|
$unshielded = true;
|
||||||
break;
|
break;
|
||||||
case 'whitespace';
|
|
||||||
$unshielded = true;
|
|
||||||
$whitespace = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$parsers = $this->buildChangesetParsers($type, $data, $file);
|
$parsers = $this->buildChangesetParsers($type, $data, $file);
|
||||||
$actual = $this->renderParsers($parsers, $unshielded, $whitespace);
|
$actual = $this->renderParsers($parsers, $unshielded);
|
||||||
$expect = Filesystem::readFile($test_file);
|
$expect = Filesystem::readFile($test_file);
|
||||||
|
|
||||||
$this->assertEqual($expect, $actual, basename($test_file));
|
$this->assertEqual($expect, $actual, basename($test_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderParsers(array $parsers, $unshield, $whitespace) {
|
private function renderParsers(array $parsers, $unshield) {
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($parsers as $parser) {
|
foreach ($parsers as $parser) {
|
||||||
if ($unshield) {
|
if ($unshield) {
|
||||||
|
@ -73,11 +67,6 @@ final class DifferentialParseRenderTestCase extends PhabricatorTestCase {
|
||||||
$e_range = null;
|
$e_range = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($whitespace) {
|
|
||||||
$parser->setWhitespaceMode(
|
|
||||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result[] = $parser->render($s_range, $e_range, array());
|
$result[] = $parser->render($s_range, $e_range, array());
|
||||||
}
|
}
|
||||||
return implode(str_repeat('~', 80)."\n", $result);
|
return implode(str_repeat('~', 80)."\n", $result);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
N 1 . @generated\n~
|
N 1 . @generated\n~
|
||||||
O 2 - \n~
|
N 2 . \n~
|
||||||
O 3 - This is a generated file.\n~
|
O 3 - This is a generated file.\n~
|
||||||
N 2 + \n~
|
|
||||||
N 3 + This is a generated file{(, full of generated code)}.\n~
|
N 3 + This is a generated file{(, full of generated code)}.\n~
|
||||||
N 4 . \n~
|
N 4 . \n~
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
O 1 . @generated\n~
|
O 1 . @generated\n~
|
||||||
N 1 . @generated\n~
|
N 1 . @generated\n~
|
||||||
O 2 - \n~
|
O 2 . \n~
|
||||||
N 2 + \n~
|
N 2 . \n~
|
||||||
O 3 - This is a generated file.\n~
|
O 3 - This is a generated file.\n~
|
||||||
N 3 + This is a generated file{(, full of generated code)}.\n~
|
N 3 + This is a generated file{(, full of generated code)}.\n~
|
||||||
O 4 . \n~
|
O 4 . \n~
|
||||||
|
|
|
@ -2,4 +2,5 @@ CTYPE 2 1 (unforced)
|
||||||
WHITESPACE
|
WHITESPACE
|
||||||
WHITESPACE
|
WHITESPACE
|
||||||
-
|
-
|
||||||
SHIELD (whitespace) This file was changed only by adding or removing whitespace.
|
O 1 - -=[-Rocket-Ship>\n~
|
||||||
|
N 1 + {> )}-=[-Rocket-Ship>\n~
|
||||||
|
|
|
@ -2,4 +2,5 @@ CTYPE 2 1 (unforced)
|
||||||
WHITESPACE
|
WHITESPACE
|
||||||
WHITESPACE
|
WHITESPACE
|
||||||
-
|
-
|
||||||
SHIELD (whitespace) This file was changed only by adding or removing whitespace.
|
O 1 - -=[-Rocket-Ship>\n~
|
||||||
|
N 1 + {> )}-=[-Rocket-Ship>\n~
|
||||||
|
|
|
@ -80,18 +80,6 @@ EOHELP
|
||||||
"Select and reorder revision fields.\n\n".
|
"Select and reorder revision fields.\n\n".
|
||||||
"NOTE: This feature is under active development and subject ".
|
"NOTE: This feature is under active development and subject ".
|
||||||
"to change.")),
|
"to change.")),
|
||||||
$this->newOption(
|
|
||||||
'differential.whitespace-matters',
|
|
||||||
'list<regex>',
|
|
||||||
array(
|
|
||||||
'/\.py$/',
|
|
||||||
'/\.l?hs$/',
|
|
||||||
'/\.ya?ml$/',
|
|
||||||
))
|
|
||||||
->setDescription(
|
|
||||||
pht(
|
|
||||||
"List of file regexps where whitespace is meaningful and should ".
|
|
||||||
"not use 'ignore-all' by default")),
|
|
||||||
$this->newOption('differential.require-test-plan-field', 'bool', true)
|
$this->newOption('differential.require-test-plan-field', 'bool', true)
|
||||||
->setBoolOptions(
|
->setBoolOptions(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -305,10 +305,6 @@ final class DifferentialRevisionViewController
|
||||||
$details = $this->buildDetails($revision, $field_list);
|
$details = $this->buildDetails($revision, $field_list);
|
||||||
$curtain = $this->buildCurtain($revision);
|
$curtain = $this->buildCurtain($revision);
|
||||||
|
|
||||||
$whitespace = $request->getStr(
|
|
||||||
'whitespace',
|
|
||||||
DifferentialChangesetParser::WHITESPACE_IGNORE_MOST);
|
|
||||||
|
|
||||||
$repository = $revision->getRepository();
|
$repository = $revision->getRepository();
|
||||||
if ($repository) {
|
if ($repository) {
|
||||||
$symbol_indexes = $this->buildSymbolIndexes(
|
$symbol_indexes = $this->buildSymbolIndexes(
|
||||||
|
@ -383,7 +379,6 @@ final class DifferentialRevisionViewController
|
||||||
->setDiff($target)
|
->setDiff($target)
|
||||||
->setRenderingReferences($rendering_references)
|
->setRenderingReferences($rendering_references)
|
||||||
->setVsMap($vs_map)
|
->setVsMap($vs_map)
|
||||||
->setWhitespace($whitespace)
|
|
||||||
->setSymbolIndexes($symbol_indexes)
|
->setSymbolIndexes($symbol_indexes)
|
||||||
->setTitle(pht('Diff %s', $target->getID()))
|
->setTitle(pht('Diff %s', $target->getID()))
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
||||||
|
@ -412,7 +407,6 @@ final class DifferentialRevisionViewController
|
||||||
->setDiffUnitStatuses($broken_diffs)
|
->setDiffUnitStatuses($broken_diffs)
|
||||||
->setSelectedVersusDiffID($diff_vs)
|
->setSelectedVersusDiffID($diff_vs)
|
||||||
->setSelectedDiffID($target->getID())
|
->setSelectedDiffID($target->getID())
|
||||||
->setSelectedWhitespace($whitespace)
|
|
||||||
->setCommitsForLinks($commits_for_links);
|
->setCommitsForLinks($commits_for_links);
|
||||||
|
|
||||||
$local_table = id(new DifferentialLocalCommitsView())
|
$local_table = id(new DifferentialLocalCommitsView())
|
||||||
|
@ -1095,7 +1089,7 @@ final class DifferentialRevisionViewController
|
||||||
// this ends up being something like
|
// this ends up being something like
|
||||||
// D123.diff
|
// D123.diff
|
||||||
// or the verbose
|
// or the verbose
|
||||||
// D123.vs123.id123.whitespaceignore-all.diff
|
// D123.vs123.id123.highlightjs.diff
|
||||||
// lame but nice to include these options
|
// lame but nice to include these options
|
||||||
$file_name = ltrim($request_uri->getPath(), '/').'.';
|
$file_name = ltrim($request_uri->getPath(), '/').'.';
|
||||||
foreach ($request_uri->getQueryParamsAsPairList() as $pair) {
|
foreach ($request_uri->getQueryParamsAsPairList() as $pair) {
|
||||||
|
|
|
@ -19,7 +19,6 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
protected $specialAttributes = array();
|
protected $specialAttributes = array();
|
||||||
|
|
||||||
protected $changeset;
|
protected $changeset;
|
||||||
protected $whitespaceMode = null;
|
|
||||||
|
|
||||||
protected $renderCacheKey = null;
|
protected $renderCacheKey = null;
|
||||||
|
|
||||||
|
@ -163,7 +162,6 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readParametersFromRequest(AphrontRequest $request) {
|
public function readParametersFromRequest(AphrontRequest $request) {
|
||||||
$this->setWhitespaceMode($request->getStr('whitespace'));
|
|
||||||
$this->setCharacterEncoding($request->getStr('encoding'));
|
$this->setCharacterEncoding($request->getStr('encoding'));
|
||||||
$this->setHighlightAs($request->getStr('highlight'));
|
$this->setHighlightAs($request->getStr('highlight'));
|
||||||
|
|
||||||
|
@ -191,20 +189,14 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CACHE_VERSION = 12;
|
const CACHE_VERSION = 13;
|
||||||
const CACHE_MAX_SIZE = 8e6;
|
const CACHE_MAX_SIZE = 8e6;
|
||||||
|
|
||||||
const ATTR_GENERATED = 'attr:generated';
|
const ATTR_GENERATED = 'attr:generated';
|
||||||
const ATTR_DELETED = 'attr:deleted';
|
const ATTR_DELETED = 'attr:deleted';
|
||||||
const ATTR_UNCHANGED = 'attr:unchanged';
|
const ATTR_UNCHANGED = 'attr:unchanged';
|
||||||
const ATTR_WHITELINES = 'attr:white';
|
|
||||||
const ATTR_MOVEAWAY = 'attr:moveaway';
|
const ATTR_MOVEAWAY = 'attr:moveaway';
|
||||||
|
|
||||||
const WHITESPACE_SHOW_ALL = 'show-all';
|
|
||||||
const WHITESPACE_IGNORE_TRAILING = 'ignore-trailing';
|
|
||||||
const WHITESPACE_IGNORE_MOST = 'ignore-most';
|
|
||||||
const WHITESPACE_IGNORE_ALL = 'ignore-all';
|
|
||||||
|
|
||||||
public function setOldLines(array $lines) {
|
public function setOldLines(array $lines) {
|
||||||
$this->old = $lines;
|
$this->old = $lines;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -336,11 +328,6 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWhitespaceMode($whitespace_mode) {
|
|
||||||
$this->whitespaceMode = $whitespace_mode;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setRenderingReference($ref) {
|
public function setRenderingReference($ref) {
|
||||||
$this->renderingReference = $ref;
|
$this->renderingReference = $ref;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -574,10 +561,6 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
return idx($this->specialAttributes, self::ATTR_UNCHANGED, false);
|
return idx($this->specialAttributes, self::ATTR_UNCHANGED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWhitespaceOnly() {
|
|
||||||
return idx($this->specialAttributes, self::ATTR_WHITELINES, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isMoveAway() {
|
public function isMoveAway() {
|
||||||
return idx($this->specialAttributes, self::ATTR_MOVEAWAY, false);
|
return idx($this->specialAttributes, self::ATTR_MOVEAWAY, false);
|
||||||
}
|
}
|
||||||
|
@ -624,18 +607,8 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function tryCacheStuff() {
|
private function tryCacheStuff() {
|
||||||
$whitespace_mode = $this->whitespaceMode;
|
$skip_cache = false;
|
||||||
switch ($whitespace_mode) {
|
|
||||||
case self::WHITESPACE_SHOW_ALL:
|
|
||||||
case self::WHITESPACE_IGNORE_TRAILING:
|
|
||||||
case self::WHITESPACE_IGNORE_ALL:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$whitespace_mode = self::WHITESPACE_IGNORE_MOST;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$skip_cache = ($whitespace_mode != self::WHITESPACE_IGNORE_MOST);
|
|
||||||
if ($this->disableCache) {
|
if ($this->disableCache) {
|
||||||
$skip_cache = true;
|
$skip_cache = true;
|
||||||
}
|
}
|
||||||
|
@ -648,8 +621,6 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
$skip_cache = true;
|
$skip_cache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->whitespaceMode = $whitespace_mode;
|
|
||||||
|
|
||||||
$changeset = $this->changeset;
|
$changeset = $this->changeset;
|
||||||
|
|
||||||
if ($changeset->getFileType() != DifferentialChangeType::FILE_TEXT &&
|
if ($changeset->getFileType() != DifferentialChangeType::FILE_TEXT &&
|
||||||
|
@ -668,71 +639,10 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function process() {
|
private function process() {
|
||||||
$whitespace_mode = $this->whitespaceMode;
|
|
||||||
$changeset = $this->changeset;
|
$changeset = $this->changeset;
|
||||||
|
|
||||||
$ignore_all = (($whitespace_mode == self::WHITESPACE_IGNORE_MOST) ||
|
|
||||||
($whitespace_mode == self::WHITESPACE_IGNORE_ALL));
|
|
||||||
|
|
||||||
$force_ignore = ($whitespace_mode == self::WHITESPACE_IGNORE_ALL);
|
|
||||||
|
|
||||||
if (!$force_ignore) {
|
|
||||||
if ($ignore_all && $changeset->getWhitespaceMatters()) {
|
|
||||||
$ignore_all = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The "ignore all whitespace" algorithm depends on rediffing the
|
|
||||||
// files, and we currently need complete representations of both
|
|
||||||
// files to do anything reasonable. If we only have parts of the files,
|
|
||||||
// don't use the "ignore all" algorithm.
|
|
||||||
if ($ignore_all) {
|
|
||||||
$hunks = $changeset->getHunks();
|
|
||||||
if (count($hunks) !== 1) {
|
|
||||||
$ignore_all = false;
|
|
||||||
} else {
|
|
||||||
$first_hunk = reset($hunks);
|
|
||||||
if ($first_hunk->getOldOffset() != 1 ||
|
|
||||||
$first_hunk->getNewOffset() != 1) {
|
|
||||||
$ignore_all = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ignore_all) {
|
|
||||||
$old_file = $changeset->makeOldFile();
|
|
||||||
$new_file = $changeset->makeNewFile();
|
|
||||||
if ($old_file == $new_file) {
|
|
||||||
// If the old and new files are exactly identical, the synthetic
|
|
||||||
// diff below will give us nonsense and whitespace modes are
|
|
||||||
// irrelevant anyway. This occurs when you, e.g., copy a file onto
|
|
||||||
// itself in Subversion (see T271).
|
|
||||||
$ignore_all = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$hunk_parser = new DifferentialHunkParser();
|
$hunk_parser = new DifferentialHunkParser();
|
||||||
$hunk_parser->setWhitespaceMode($whitespace_mode);
|
|
||||||
$hunk_parser->parseHunksForLineData($changeset->getHunks());
|
$hunk_parser->parseHunksForLineData($changeset->getHunks());
|
||||||
|
|
||||||
// Depending on the whitespace mode, we may need to compute a different
|
|
||||||
// set of changes than the set of changes in the hunk data (specifically,
|
|
||||||
// we might want to consider changed lines which have only whitespace
|
|
||||||
// changes as unchanged).
|
|
||||||
if ($ignore_all) {
|
|
||||||
$engine = new PhabricatorDifferenceEngine();
|
|
||||||
$engine->setIgnoreWhitespace(true);
|
|
||||||
$no_whitespace_changeset = $engine->generateChangesetFromFileContent(
|
|
||||||
$old_file,
|
|
||||||
$new_file);
|
|
||||||
|
|
||||||
$type_parser = new DifferentialHunkParser();
|
|
||||||
$type_parser->parseHunksForLineData($no_whitespace_changeset->getHunks());
|
|
||||||
|
|
||||||
$hunk_parser->setOldLineTypeMap($type_parser->getOldLineTypeMap());
|
|
||||||
$hunk_parser->setNewLineTypeMap($type_parser->getNewLineTypeMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
$hunk_parser->reparseHunksForSpecialAttributes();
|
$hunk_parser->reparseHunksForSpecialAttributes();
|
||||||
|
|
||||||
$unchanged = false;
|
$unchanged = false;
|
||||||
|
@ -753,7 +663,6 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
$this->setSpecialAttributes(array(
|
$this->setSpecialAttributes(array(
|
||||||
self::ATTR_UNCHANGED => $unchanged,
|
self::ATTR_UNCHANGED => $unchanged,
|
||||||
self::ATTR_DELETED => $hunk_parser->getIsDeleted(),
|
self::ATTR_DELETED => $hunk_parser->getIsDeleted(),
|
||||||
self::ATTR_WHITELINES => !$hunk_parser->getHasTextChanges(),
|
|
||||||
self::ATTR_MOVEAWAY => $moveaway,
|
self::ATTR_MOVEAWAY => $moveaway,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -971,10 +880,6 @@ final class DifferentialChangesetParser extends Phobject {
|
||||||
pht('The contents of this file were not changed.'),
|
pht('The contents of this file were not changed.'),
|
||||||
$type);
|
$type);
|
||||||
}
|
}
|
||||||
} else if ($this->isWhitespaceOnly()) {
|
|
||||||
$shield = $renderer->renderShield(
|
|
||||||
pht('This file was changed only by adding or removing whitespace.'),
|
|
||||||
'whitespace');
|
|
||||||
} else if ($this->isDeleted()) {
|
} else if ($this->isDeleted()) {
|
||||||
$shield = $renderer->renderShield(
|
$shield = $renderer->renderShield(
|
||||||
pht('This file was completely deleted.'));
|
pht('This file was completely deleted.'));
|
||||||
|
|
|
@ -7,7 +7,6 @@ final class DifferentialHunkParser extends Phobject {
|
||||||
private $intraLineDiffs;
|
private $intraLineDiffs;
|
||||||
private $depthOnlyLines;
|
private $depthOnlyLines;
|
||||||
private $visibleLinesMask;
|
private $visibleLinesMask;
|
||||||
private $whitespaceMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a map of lines on which hunks start, other than line 1. This
|
* Get a map of lines on which hunks start, other than line 1. This
|
||||||
|
@ -125,21 +124,6 @@ final class DifferentialHunkParser extends Phobject {
|
||||||
return $this->depthOnlyLines;
|
return $this->depthOnlyLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWhitespaceMode($white_space_mode) {
|
|
||||||
$this->whitespaceMode = $white_space_mode;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getWhitespaceMode() {
|
|
||||||
if ($this->whitespaceMode === null) {
|
|
||||||
throw new Exception(
|
|
||||||
pht(
|
|
||||||
'You must %s before accessing this data.',
|
|
||||||
'setWhitespaceMode'));
|
|
||||||
}
|
|
||||||
return $this->whitespaceMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIsDeleted() {
|
public function getIsDeleted() {
|
||||||
foreach ($this->getNewLines() as $line) {
|
foreach ($this->getNewLines() as $line) {
|
||||||
if ($line) {
|
if ($line) {
|
||||||
|
@ -159,13 +143,6 @@ final class DifferentialHunkParser extends Phobject {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the hunks change any text, not just whitespace.
|
|
||||||
*/
|
|
||||||
public function getHasTextChanges() {
|
|
||||||
return $this->getHasChanges('text');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the hunks change anything, including whitespace.
|
* Returns true if the hunks change anything, including whitespace.
|
||||||
*/
|
*/
|
||||||
|
@ -193,9 +170,6 @@ final class DifferentialHunkParser extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($o['type'] !== $n['type']) {
|
if ($o['type'] !== $n['type']) {
|
||||||
// The types are different, so either the underlying text is actually
|
|
||||||
// different or whatever whitespace rules we're using consider them
|
|
||||||
// different.
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,63 +252,6 @@ final class DifferentialHunkParser extends Phobject {
|
||||||
$this->setOldLines($rebuild_old);
|
$this->setOldLines($rebuild_old);
|
||||||
$this->setNewLines($rebuild_new);
|
$this->setNewLines($rebuild_new);
|
||||||
|
|
||||||
$this->updateChangeTypesForWhitespaceMode();
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function updateChangeTypesForWhitespaceMode() {
|
|
||||||
$mode = $this->getWhitespaceMode();
|
|
||||||
|
|
||||||
$mode_show_all = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
|
|
||||||
if ($mode === $mode_show_all) {
|
|
||||||
// If we're showing all whitespace, we don't need to perform any updates.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$mode_trailing = DifferentialChangesetParser::WHITESPACE_IGNORE_TRAILING;
|
|
||||||
$is_trailing = ($mode === $mode_trailing);
|
|
||||||
|
|
||||||
$new = $this->getNewLines();
|
|
||||||
$old = $this->getOldLines();
|
|
||||||
foreach ($old as $key => $o) {
|
|
||||||
$n = $new[$key];
|
|
||||||
|
|
||||||
if (!$o || !$n) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($is_trailing) {
|
|
||||||
// In "trailing" mode, we need to identify lines which are marked
|
|
||||||
// changed but differ only by trailing whitespace. We mark these lines
|
|
||||||
// unchanged.
|
|
||||||
if ($o['type'] != $n['type']) {
|
|
||||||
if (rtrim($o['text']) === rtrim($n['text'])) {
|
|
||||||
$old[$key]['type'] = null;
|
|
||||||
$new[$key]['type'] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// In "ignore most" and "ignore all" modes, we need to identify lines
|
|
||||||
// which are marked unchanged but have internal whitespace changes.
|
|
||||||
// We want to ignore leading and trailing whitespace changes only, not
|
|
||||||
// internal whitespace changes (`diff` doesn't have a mode for this, so
|
|
||||||
// we have to fix it here). If the text is marked unchanged but the
|
|
||||||
// old and new text differs by internal space, mark the lines changed.
|
|
||||||
if ($o['type'] === null && $n['type'] === null) {
|
|
||||||
if ($o['text'] !== $n['text']) {
|
|
||||||
if (trim($o['text']) !== trim($n['text'])) {
|
|
||||||
$old[$key]['type'] = '-';
|
|
||||||
$new[$key]['type'] = '+';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setOldLines($old);
|
|
||||||
$this->setNewLines($new);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,6 @@ final class DifferentialLineAdjustmentMap extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
$changeset = id(new PhabricatorDifferenceEngine())
|
$changeset = id(new PhabricatorDifferenceEngine())
|
||||||
->setIgnoreWhitespace(true)
|
|
||||||
->generateChangesetFromFileContent($u_old, $v_old);
|
->generateChangesetFromFileContent($u_old, $v_old);
|
||||||
|
|
||||||
$results[$u][$v] = self::newFromHunks(
|
$results[$u][$v] = self::newFromHunks(
|
||||||
|
|
|
@ -367,7 +367,6 @@ abstract class DifferentialChangesetHTMLRenderer
|
||||||
$reference = $this->getRenderingReference();
|
$reference = $this->getRenderingReference();
|
||||||
|
|
||||||
if ($force !== 'text' &&
|
if ($force !== 'text' &&
|
||||||
$force !== 'whitespace' &&
|
|
||||||
$force !== 'none' &&
|
$force !== 'none' &&
|
||||||
$force !== 'default') {
|
$force !== 'default') {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
@ -388,10 +387,6 @@ abstract class DifferentialChangesetHTMLRenderer
|
||||||
'range' => $range,
|
'range' => $range,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($force == 'whitespace') {
|
|
||||||
$meta['whitespace'] = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = array();
|
$content = array();
|
||||||
$content[] = $message;
|
$content[] = $message;
|
||||||
if ($force !== 'none') {
|
if ($force !== 'none') {
|
||||||
|
|
|
@ -406,9 +406,6 @@ abstract class DifferentialChangesetRenderer extends Phobject {
|
||||||
* important (e.g., generated code).
|
* important (e.g., generated code).
|
||||||
* - `"text"`: Force the text to be shown. This is probably only relevant
|
* - `"text"`: Force the text to be shown. This is probably only relevant
|
||||||
* when a file is not changed.
|
* 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).
|
* - `"none"`: Don't show the link (e.g., text not available).
|
||||||
*
|
*
|
||||||
* @param string Message explaining why the diff is hidden.
|
* @param string Message explaining why the diff is hidden.
|
||||||
|
|
|
@ -249,17 +249,6 @@ final class DifferentialChangeset
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWhitespaceMatters() {
|
|
||||||
$config = PhabricatorEnv::getEnvConfig('differential.whitespace-matters');
|
|
||||||
foreach ($config as $regexp) {
|
|
||||||
if (preg_match($regexp, $this->getFilename())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function attachDiff(DifferentialDiff $diff) {
|
public function attachDiff(DifferentialDiff $diff) {
|
||||||
$this->diff = $diff;
|
$this->diff = $diff;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -9,7 +9,6 @@ final class DifferentialChangesetDetailView extends AphrontView {
|
||||||
private $id;
|
private $id;
|
||||||
private $vsChangesetID;
|
private $vsChangesetID;
|
||||||
private $renderURI;
|
private $renderURI;
|
||||||
private $whitespace;
|
|
||||||
private $renderingRef;
|
private $renderingRef;
|
||||||
private $autoload;
|
private $autoload;
|
||||||
private $loaded;
|
private $loaded;
|
||||||
|
@ -42,15 +41,6 @@ final class DifferentialChangesetDetailView extends AphrontView {
|
||||||
return $this->renderingRef;
|
return $this->renderingRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWhitespace($whitespace) {
|
|
||||||
$this->whitespace = $whitespace;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWhitespace() {
|
|
||||||
return $this->whitespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setRenderURI($render_uri) {
|
public function setRenderURI($render_uri) {
|
||||||
$this->renderURI = $render_uri;
|
$this->renderURI = $render_uri;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -196,7 +186,6 @@ final class DifferentialChangesetDetailView extends AphrontView {
|
||||||
'left' => $left_id,
|
'left' => $left_id,
|
||||||
'right' => $right_id,
|
'right' => $right_id,
|
||||||
'renderURI' => $this->getRenderURI(),
|
'renderURI' => $this->getRenderURI(),
|
||||||
'whitespace' => $this->getWhitespace(),
|
|
||||||
'highlight' => null,
|
'highlight' => null,
|
||||||
'renderer' => $this->getRenderer(),
|
'renderer' => $this->getRenderer(),
|
||||||
'ref' => $this->getRenderingRef(),
|
'ref' => $this->getRenderingRef(),
|
||||||
|
|
|
@ -7,7 +7,6 @@ final class DifferentialChangesetListView extends AphrontView {
|
||||||
private $references = array();
|
private $references = array();
|
||||||
private $inlineURI;
|
private $inlineURI;
|
||||||
private $renderURI = '/differential/changeset/';
|
private $renderURI = '/differential/changeset/';
|
||||||
private $whitespace;
|
|
||||||
private $background;
|
private $background;
|
||||||
private $header;
|
private $header;
|
||||||
private $isStandalone;
|
private $isStandalone;
|
||||||
|
@ -100,11 +99,6 @@ final class DifferentialChangesetListView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWhitespace($whitespace) {
|
|
||||||
$this->whitespace = $whitespace;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setVsMap(array $vs_map) {
|
public function setVsMap(array $vs_map) {
|
||||||
$this->vsMap = $vs_map;
|
$this->vsMap = $vs_map;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -180,7 +174,6 @@ final class DifferentialChangesetListView extends AphrontView {
|
||||||
$detail->setRenderingRef($ref);
|
$detail->setRenderingRef($ref);
|
||||||
|
|
||||||
$detail->setRenderURI($this->renderURI);
|
$detail->setRenderURI($this->renderURI);
|
||||||
$detail->setWhitespace($this->whitespace);
|
|
||||||
$detail->setRenderer($renderer);
|
$detail->setRenderer($renderer);
|
||||||
|
|
||||||
if ($this->getParser()) {
|
if ($this->getParser()) {
|
||||||
|
@ -352,8 +345,7 @@ final class DifferentialChangesetListView extends AphrontView {
|
||||||
$meta = array();
|
$meta = array();
|
||||||
|
|
||||||
$qparams = array(
|
$qparams = array(
|
||||||
'ref' => $ref,
|
'ref' => $ref,
|
||||||
'whitespace' => $this->whitespace,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->standaloneURI) {
|
if ($this->standaloneURI) {
|
||||||
|
|
|
@ -5,7 +5,6 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
||||||
private $diffs = array();
|
private $diffs = array();
|
||||||
private $selectedVersusDiffID;
|
private $selectedVersusDiffID;
|
||||||
private $selectedDiffID;
|
private $selectedDiffID;
|
||||||
private $selectedWhitespace;
|
|
||||||
private $commitsForLinks = array();
|
private $commitsForLinks = array();
|
||||||
private $unitStatus = array();
|
private $unitStatus = array();
|
||||||
|
|
||||||
|
@ -25,11 +24,6 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSelectedWhitespace($whitespace) {
|
|
||||||
$this->selectedWhitespace = $whitespace;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCommitsForLinks(array $commits) {
|
public function setCommitsForLinks(array $commits) {
|
||||||
assert_instances_of($commits, 'PhabricatorRepositoryCommit');
|
assert_instances_of($commits, 'PhabricatorRepositoryCommit');
|
||||||
$this->commitsForLinks = $commits;
|
$this->commitsForLinks = $commits;
|
||||||
|
@ -224,28 +218,6 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
||||||
'radios' => $radios,
|
'radios' => $radios,
|
||||||
));
|
));
|
||||||
|
|
||||||
$options = array(
|
|
||||||
DifferentialChangesetParser::WHITESPACE_IGNORE_ALL => pht('Ignore All'),
|
|
||||||
DifferentialChangesetParser::WHITESPACE_IGNORE_MOST => pht('Ignore Most'),
|
|
||||||
DifferentialChangesetParser::WHITESPACE_IGNORE_TRAILING =>
|
|
||||||
pht('Ignore Trailing'),
|
|
||||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL => pht('Show All'),
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($options as $value => $label) {
|
|
||||||
$options[$value] = phutil_tag(
|
|
||||||
'option',
|
|
||||||
array(
|
|
||||||
'value' => $value,
|
|
||||||
'selected' => ($value == $this->selectedWhitespace)
|
|
||||||
? 'selected'
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
$label);
|
|
||||||
}
|
|
||||||
$select = phutil_tag('select', array('name' => 'whitespace'), $options);
|
|
||||||
|
|
||||||
|
|
||||||
$table = id(new AphrontTableView($rows));
|
$table = id(new AphrontTableView($rows));
|
||||||
$table->setHeaders(
|
$table->setHeaders(
|
||||||
array(
|
array(
|
||||||
|
@ -291,13 +263,6 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
||||||
'class' => 'differential-update-history-footer',
|
'class' => 'differential-update-history-footer',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
phutil_tag(
|
|
||||||
'label',
|
|
||||||
array(),
|
|
||||||
array(
|
|
||||||
pht('Whitespace Changes:'),
|
|
||||||
$select,
|
|
||||||
)),
|
|
||||||
phutil_tag(
|
phutil_tag(
|
||||||
'button',
|
'button',
|
||||||
array(),
|
array(),
|
||||||
|
|
|
@ -64,9 +64,6 @@ final class DiffusionChangeController extends DiffusionController {
|
||||||
$changeset_view->setRawFileURIs($left_uri, $right_uri);
|
$changeset_view->setRawFileURIs($left_uri, $right_uri);
|
||||||
|
|
||||||
$changeset_view->setRenderURI($repository->getPathURI('diff/'));
|
$changeset_view->setRenderURI($repository->getPathURI('diff/'));
|
||||||
|
|
||||||
$changeset_view->setWhitespace(
|
|
||||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
|
||||||
$changeset_view->setUser($viewer);
|
$changeset_view->setUser($viewer);
|
||||||
$changeset_view->setHeader($changeset_header);
|
$changeset_view->setHeader($changeset_header);
|
||||||
|
|
||||||
|
|
|
@ -88,9 +88,6 @@ final class DiffusionDiffController extends DiffusionController {
|
||||||
($viewer->getPHID() == $commit->getAuthorPHID()));
|
($viewer->getPHID() == $commit->getAuthorPHID()));
|
||||||
$parser->setObjectOwnerPHID($commit->getAuthorPHID());
|
$parser->setObjectOwnerPHID($commit->getAuthorPHID());
|
||||||
|
|
||||||
$parser->setWhitespaceMode(
|
|
||||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
|
||||||
|
|
||||||
$inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments(
|
$inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments(
|
||||||
$viewer,
|
$viewer,
|
||||||
$commit->getPHID(),
|
$commit->getPHID(),
|
||||||
|
|
|
@ -51,22 +51,6 @@ You need to install and configure **Pygments** to highlight anything else than
|
||||||
PHP. See the `pygments.enabled` configuration setting.
|
PHP. See the `pygments.enabled` configuration setting.
|
||||||
|
|
||||||
|
|
||||||
= What do the whitespace options mean? =
|
|
||||||
|
|
||||||
Most of these are pretty straightforward, but "Ignore Most" is not:
|
|
||||||
|
|
||||||
- **Show All**: Show all whitespace.
|
|
||||||
- **Ignore Trailing**: Ignore changes which only affect trailing whitespace.
|
|
||||||
- **Ignore Most**: Ignore changes which only affect leading or trailing
|
|
||||||
whitespace (but not whitespace changes between non-whitespace characters)
|
|
||||||
in files which are not marked as having significant whitespace.
|
|
||||||
In those files, show whitespace changes. By default, Python (.py) and
|
|
||||||
Haskell (.lhs, .hs) are marked as having significant whitespace, but this
|
|
||||||
can be changed in the `differential.whitespace-matters` configuration
|
|
||||||
setting.
|
|
||||||
- **Ignore All**: Ignore all whitespace changes in all files.
|
|
||||||
|
|
||||||
|
|
||||||
= What do the very light green and red backgrounds mean? =
|
= What do the very light green and red backgrounds mean? =
|
||||||
|
|
||||||
Differential uses these colors to mark changes coming from rebase: they are
|
Differential uses these colors to mark changes coming from rebase: they are
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
final class PhabricatorDifferenceEngine extends Phobject {
|
final class PhabricatorDifferenceEngine extends Phobject {
|
||||||
|
|
||||||
|
|
||||||
private $ignoreWhitespace;
|
|
||||||
private $oldName;
|
private $oldName;
|
||||||
private $newName;
|
private $newName;
|
||||||
|
|
||||||
|
@ -18,19 +17,6 @@ final class PhabricatorDifferenceEngine extends Phobject {
|
||||||
/* -( Configuring the Engine )--------------------------------------------- */
|
/* -( Configuring the Engine )--------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If true, ignore whitespace when computing differences.
|
|
||||||
*
|
|
||||||
* @param bool Ignore whitespace?
|
|
||||||
* @return this
|
|
||||||
* @task config
|
|
||||||
*/
|
|
||||||
public function setIgnoreWhitespace($ignore_whitespace) {
|
|
||||||
$this->ignoreWhitespace = $ignore_whitespace;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name to identify the old file with. Primarily cosmetic.
|
* Set the name to identify the old file with. Primarily cosmetic.
|
||||||
*
|
*
|
||||||
|
@ -73,9 +59,6 @@ final class PhabricatorDifferenceEngine extends Phobject {
|
||||||
public function generateRawDiffFromFileContent($old, $new) {
|
public function generateRawDiffFromFileContent($old, $new) {
|
||||||
|
|
||||||
$options = array();
|
$options = array();
|
||||||
if ($this->ignoreWhitespace) {
|
|
||||||
$options[] = '-bw';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate diffs with full context.
|
// Generate diffs with full context.
|
||||||
$options[] = '-U65535';
|
$options[] = '-U65535';
|
||||||
|
@ -100,12 +83,10 @@ final class PhabricatorDifferenceEngine extends Phobject {
|
||||||
$new_tmp);
|
$new_tmp);
|
||||||
|
|
||||||
if (!$err) {
|
if (!$err) {
|
||||||
// This indicates that the two files are the same (or, possibly, the
|
// This indicates that the two files are the same. Build a synthetic,
|
||||||
// same modulo whitespace differences, which is why we can't do this
|
// changeless diff so that we can still render the raw, unchanged file
|
||||||
// check trivially before running `diff`). Build a synthetic, changeless
|
// instead of being forced to just say "this file didn't change" since we
|
||||||
// diff so that we can still render the raw, unchanged file instead of
|
// don't have the content.
|
||||||
// being forced to just say "this file didn't change" since we don't have
|
|
||||||
// the content.
|
|
||||||
|
|
||||||
$entire_file = explode("\n", $old);
|
$entire_file = explode("\n", $old);
|
||||||
foreach ($entire_file as $k => $line) {
|
foreach ($entire_file as $k => $line) {
|
||||||
|
@ -123,26 +104,6 @@ final class PhabricatorDifferenceEngine extends Phobject {
|
||||||
"+++ {$new_name}\n".
|
"+++ {$new_name}\n".
|
||||||
"@@ -1,{$len} +1,{$len} @@\n".
|
"@@ -1,{$len} +1,{$len} @@\n".
|
||||||
$entire_file."\n";
|
$entire_file."\n";
|
||||||
} else {
|
|
||||||
if ($this->ignoreWhitespace) {
|
|
||||||
|
|
||||||
// Under "-bw", `diff` is inconsistent about emitting "\ No newline
|
|
||||||
// at end of file". For instance, a long file with a change in the
|
|
||||||
// middle will emit a contextless "\ No newline..." at the end if a
|
|
||||||
// newline is removed, but not if one is added. A file with a change
|
|
||||||
// at the end will emit the "old" "\ No newline..." block only, even
|
|
||||||
// if the newline was not removed. Since we're ostensibly ignoring
|
|
||||||
// whitespace changes, just drop these lines if they appear anywhere
|
|
||||||
// in the diff.
|
|
||||||
|
|
||||||
$lines = explode("\n", $diff);
|
|
||||||
foreach ($lines as $key => $line) {
|
|
||||||
if (isset($line[0]) && $line[0] == '\\') {
|
|
||||||
unset($lines[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$diff = implode("\n", $lines);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $diff;
|
return $diff;
|
||||||
|
|
|
@ -22,7 +22,6 @@ JX.install('DiffChangeset', {
|
||||||
|
|
||||||
this._renderURI = data.renderURI;
|
this._renderURI = data.renderURI;
|
||||||
this._ref = data.ref;
|
this._ref = data.ref;
|
||||||
this._whitespace = data.whitespace;
|
|
||||||
this._renderer = data.renderer;
|
this._renderer = data.renderer;
|
||||||
this._highlight = data.highlight;
|
this._highlight = data.highlight;
|
||||||
this._encoding = data.encoding;
|
this._encoding = data.encoding;
|
||||||
|
@ -46,7 +45,6 @@ JX.install('DiffChangeset', {
|
||||||
|
|
||||||
_renderURI: null,
|
_renderURI: null,
|
||||||
_ref: null,
|
_ref: null,
|
||||||
_whitespace: null,
|
|
||||||
_renderer: null,
|
_renderer: null,
|
||||||
_highlight: null,
|
_highlight: null,
|
||||||
_encoding: null,
|
_encoding: null,
|
||||||
|
@ -310,7 +308,6 @@ JX.install('DiffChangeset', {
|
||||||
_getViewParameters: function() {
|
_getViewParameters: function() {
|
||||||
return {
|
return {
|
||||||
ref: this._ref,
|
ref: this._ref,
|
||||||
whitespace: this._whitespace || '',
|
|
||||||
renderer: this.getRenderer() || '',
|
renderer: this.getRenderer() || '',
|
||||||
highlight: this._highlight || '',
|
highlight: this._highlight || '',
|
||||||
encoding: this._encoding || ''
|
encoding: this._encoding || ''
|
||||||
|
|
Loading…
Add table
Reference in a new issue