From 09c1bd34f1c98652102e42f0c4c6301fb4de7bad Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 12 Mar 2012 17:06:36 -0700 Subject: [PATCH] Add an "ignore all" whitespace mode Summary: We used to have "ignore all", but it became "ignore most". It does not ignore in-line whitespace changes or whitespace changes in language where whitespace is marked semantic. Add an explicit "ignore all" option. Test Plan: Used "ignore all" to view a change with heuristically-detected semantic whitespace, the change was ignored. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T970 Differential Revision: https://secure.phabricator.com/D1865 --- .../changeset/DifferentialChangesetParser.php | 22 ++++++++++++++++--- .../DifferentialRevisionUpdateHistoryView.php | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index 2b5ade54e4..525010fa04 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -66,8 +66,12 @@ class DifferentialChangesetParser { const WHITESPACE_SHOW_ALL = 'show-all'; const WHITESPACE_IGNORE_TRAILING = 'ignore-trailing'; + + // TODO: This is now "Ignore Most" in the UI. const WHITESPACE_IGNORE_ALL = 'ignore-all'; + const WHITESPACE_IGNORE_FORCE = 'ignore-force'; + /** * Configure which Changeset comments added to the right side of the visible * diff will be attached to. The ID must be the ID of a real Differential @@ -395,6 +399,12 @@ class DifferentialChangesetParser { } $new[$k]['text'] = idx($new_text, $desc['line']); + if ($this->whitespaceMode == self::WHITESPACE_IGNORE_FORCE) { + // Under forced ignore mode, ignore even internal whitespace + // changes. + continue; + } + // If there's a corresponding "old" text and the line is marked as // unchanged, test if there are internal whitespace changes between // non-whitespace characters, e.g. spaces added to a string or spaces @@ -700,6 +710,7 @@ class DifferentialChangesetParser { switch ($whitespace_mode) { case self::WHITESPACE_SHOW_ALL: case self::WHITESPACE_IGNORE_TRAILING: + case self::WHITESPACE_IGNORE_FORCE: break; default: $whitespace_mode = self::WHITESPACE_IGNORE_ALL; @@ -715,10 +726,15 @@ class DifferentialChangesetParser { $changeset->getFileType() == DifferentialChangeType::FILE_SYMLINK) { if ($skip_cache || !$this->loadCache()) { - $ignore_all = ($this->whitespaceMode == self::WHITESPACE_IGNORE_ALL); + $ignore_all = (($whitespace_mode == self::WHITESPACE_IGNORE_ALL) || + ($whitespace_mode == self::WHITESPACE_IGNORE_FORCE)); - if ($ignore_all && $changeset->getWhitespaceMatters()) { - $ignore_all = false; + $force_ignore = ($whitespace_mode == self::WHITESPACE_IGNORE_FORCE); + + if (!$force_ignore) { + if ($ignore_all && $changeset->getWhitespaceMatters()) { + $ignore_all = false; + } } // The "ignore all whitespace" algorithm depends on rediffing the diff --git a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php index 385ae8ce32..ff5c23435d 100644 --- a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php +++ b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php @@ -191,6 +191,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { )); $options = array( + DifferentialChangesetParser::WHITESPACE_IGNORE_FORCE => 'Ignore All', DifferentialChangesetParser::WHITESPACE_IGNORE_ALL => 'Ignore Most', DifferentialChangesetParser::WHITESPACE_IGNORE_TRAILING => 'Ignore Trailing',