From a6c770217dc8f08298ed7c0323333328da3b1cc6 Mon Sep 17 00:00:00 2001 From: tuomaspelkonen Date: Mon, 18 Apr 2011 13:38:54 -0700 Subject: [PATCH] Fixed whitespace options in Differential. Summary: Whitespace options could not be selected and the 'ignore_all' was not working. Test Plan: Made sure that whitespace is ignored correctly and selected option is handled correctly. Reviewed By: jungejason Reviewers: jungejason CC: epriestley, jungejason, tuomaspelkonen Differential Revision: 149 --- .../DifferentialChangesetViewController.php | 1 + .../DifferentialRevisionViewController.php | 2 ++ .../changeset/DifferentialChangesetParser.php | 4 +-- .../DifferentialChangesetListView.php | 11 +++++--- .../DifferentialRevisionUpdateHistoryView.php | 26 ++++++++++++++++++- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php b/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php index 1c1f09ca22..ff978805c7 100644 --- a/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php +++ b/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php @@ -132,6 +132,7 @@ class DifferentialChangesetViewController extends DifferentialController { $parser->setChangeset($changeset); $parser->setRightSideCommentMapping($right_source, $right_new); $parser->setLeftSideCommentMapping($left_source, $left_new); + $parser->setWhitespaceMode($request->getStr('whitespace')); $phids = array(); $inlines = $this->loadInlineComments($id, $author_phid); diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index d7d5fa59ec..5a03483b2e 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -173,6 +173,7 @@ class DifferentialRevisionViewController extends DifferentialController { $diff_history->setDiffs($diffs); $diff_history->setSelectedVersusDiffID($diff_vs); $diff_history->setSelectedDiffID($target->getID()); + $diff_history->setSelectedWhitespace($request->getStr('whitespace')); $toc_view = new DifferentialDiffTableOfContentsView(); $toc_view->setChangesets($changesets); @@ -185,6 +186,7 @@ class DifferentialRevisionViewController extends DifferentialController { $changeset_view->setEditable(true); $changeset_view->setRevision($revision); $changeset_view->setVsMap($vs_map); + $changeset_view->setWhitespace($request->getStr('whitespace')); $draft = id(new PhabricatorDraft())->loadOneWhere( 'authorPHID = %s AND draftKey = %s', diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index 121347568f..f03c88ce79 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -675,10 +675,10 @@ EOSYNTHETIC; $diff = DifferentialDiff::newFromRawChanges($changes); $changesets = $diff->getChangesets(); - $alt_changeset = reset($changesets); + $changeset = reset($changesets); $this->subparser = new DifferentialChangesetParser(); - $this->subparser->setChangeset($alt_changeset); + $this->subparser->setChangeset($changeset); $this->subparser->setWhitespaceMode(self::WHITESPACE_IGNORE_TRAILING); } foreach ($changeset->getHunks() as $hunk) { diff --git a/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php b/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php index 1dc86e05d8..35eacc4c9b 100644 --- a/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php +++ b/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php @@ -23,6 +23,7 @@ class DifferentialChangesetListView extends AphrontView { private $revision; private $renderURI = '/differential/changeset/'; private $vsMap = array(); + private $whitespace = null; public function setChangesets($changesets) { $this->changesets = $changesets; @@ -49,6 +50,11 @@ class DifferentialChangesetListView extends AphrontView { return $this; } + public function setWhitespace($whitespace) { + $this->whitespace = $whitespace; + return $this; + } + public function render() { require_celerity_resource('differential-changeset-view-css'); @@ -77,7 +83,7 @@ class DifferentialChangesetListView extends AphrontView { array( 'id' => $ref, 'vs' => $vs_id, - 'whitespace' => 'TODO', + 'whitespace' => $this->whitespace, )); $detail_button = phutil_render_tag( @@ -109,10 +115,9 @@ class DifferentialChangesetListView extends AphrontView { $vs_id); } - $whitespace = null; Javelin::initBehavior('differential-populate', array( 'registry' => $mapping, - 'whitespace' => $whitespace, + 'whitespace' => $this->whitespace, 'uri' => $this->renderURI, )); diff --git a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php index d7fcd54c9a..56fc368878 100644 --- a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php +++ b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php @@ -21,6 +21,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { private $diffs = array(); private $selectedVersusDiffID; private $selectedDiffID; + private $selectedWhitespace; public function setDiffs($diffs) { $this->diffs = $diffs; @@ -37,6 +38,11 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { return $this; } + public function setSelectedWhitespace($whitespace) { + $this->selectedWhitespace = $whitespace; + return $this; + } + public function render() { require_celerity_resource('differential-core-view-css'); @@ -157,7 +163,25 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { 'radios' => $radios, )); - $select = ''; + $options = array( + 'ignore-all' => 'Ignore All', + 'ignore-trailing' => 'Ignore Trailing', + 'show-all' => 'Show All', + ); + + $select = ''; return '
'.