@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Unhighlight lines modified in rebase

Summary:
Diff of diffs display changes between new versions of file.
This is bad after rebase because there can be many unrelated changes so it is hard to spot the real change.

This diff unhighlights the lines that were added or removed in rebase.
The changes are still visible (they can be sometimes relevant) but very subtle.

Test Plan:
# Add, change and delete line. Display diff.
# Add and change some lines in parent. Rebase. Display diff. Display diff of diff.
# Change and add some lines. Display diff. Display diff to first diff. Display diff to second diff.

Reviewers: epriestley, jungejason

Reviewed By: jungejason

CC: jungejason, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2761

vrana 99df72b8 d70f8dad

+178 -27
+16 -16
src/__celerity_resource_map__.php
··· 566 566 ), 567 567 'differential-changeset-view-css' => 568 568 array( 569 - 'uri' => '/res/8e2ace51/rsrc/css/application/differential/changeset-view.css', 569 + 'uri' => '/res/c9706669/rsrc/css/application/differential/changeset-view.css', 570 570 'type' => 'css', 571 571 'requires' => 572 572 array( ··· 2628 2628 'uri' => '/res/pkg/f363b322/core.pkg.js', 2629 2629 'type' => 'js', 2630 2630 ), 2631 - '32f461a4' => 2631 + '96bc37d6' => 2632 2632 array( 2633 2633 'name' => 'differential.pkg.css', 2634 2634 'symbols' => ··· 2647 2647 11 => 'differential-local-commits-view-css', 2648 2648 12 => 'inline-comment-summary-css', 2649 2649 ), 2650 - 'uri' => '/res/pkg/32f461a4/differential.pkg.css', 2650 + 'uri' => '/res/pkg/96bc37d6/differential.pkg.css', 2651 2651 'type' => 'css', 2652 2652 ), 2653 2653 'f4bbbd84' => ··· 2770 2770 'aphront-dialog-view-css' => 'a05e3ec6', 2771 2771 'aphront-error-view-css' => 'a05e3ec6', 2772 2772 'aphront-form-view-css' => 'a05e3ec6', 2773 - 'aphront-headsup-action-list-view-css' => '32f461a4', 2773 + 'aphront-headsup-action-list-view-css' => '96bc37d6', 2774 2774 'aphront-headsup-view-css' => 'a05e3ec6', 2775 2775 'aphront-list-filter-view-css' => 'a05e3ec6', 2776 2776 'aphront-pager-view-css' => 'a05e3ec6', ··· 2780 2780 'aphront-tokenizer-control-css' => 'a05e3ec6', 2781 2781 'aphront-tooltip-css' => 'a05e3ec6', 2782 2782 'aphront-typeahead-control-css' => 'a05e3ec6', 2783 - 'differential-changeset-view-css' => '32f461a4', 2784 - 'differential-core-view-css' => '32f461a4', 2783 + 'differential-changeset-view-css' => '96bc37d6', 2784 + 'differential-core-view-css' => '96bc37d6', 2785 2785 'differential-inline-comment-editor' => 'f4bbbd84', 2786 - 'differential-local-commits-view-css' => '32f461a4', 2787 - 'differential-results-table-css' => '32f461a4', 2788 - 'differential-revision-add-comment-css' => '32f461a4', 2789 - 'differential-revision-comment-css' => '32f461a4', 2790 - 'differential-revision-comment-list-css' => '32f461a4', 2791 - 'differential-revision-history-css' => '32f461a4', 2792 - 'differential-table-of-contents-css' => '32f461a4', 2786 + 'differential-local-commits-view-css' => '96bc37d6', 2787 + 'differential-results-table-css' => '96bc37d6', 2788 + 'differential-revision-add-comment-css' => '96bc37d6', 2789 + 'differential-revision-comment-css' => '96bc37d6', 2790 + 'differential-revision-comment-list-css' => '96bc37d6', 2791 + 'differential-revision-history-css' => '96bc37d6', 2792 + 'differential-table-of-contents-css' => '96bc37d6', 2793 2793 'diffusion-commit-view-css' => 'c8ce2d88', 2794 2794 'diffusion-icons-css' => 'c8ce2d88', 2795 - 'inline-comment-summary-css' => '32f461a4', 2795 + 'inline-comment-summary-css' => '96bc37d6', 2796 2796 'javelin-behavior' => '6fb20113', 2797 2797 'javelin-behavior-aphront-basic-tokenizer' => '97f65640', 2798 2798 'javelin-behavior-aphront-drag-and-drop' => 'f4bbbd84', ··· 2846 2846 'maniphest-task-summary-css' => '7839ae2d', 2847 2847 'maniphest-transaction-detail-css' => '7839ae2d', 2848 2848 'phabricator-app-buttons-css' => 'a05e3ec6', 2849 - 'phabricator-content-source-view-css' => '32f461a4', 2849 + 'phabricator-content-source-view-css' => '96bc37d6', 2850 2850 'phabricator-core-buttons-css' => 'a05e3ec6', 2851 2851 'phabricator-core-css' => 'a05e3ec6', 2852 2852 'phabricator-directory-css' => 'a05e3ec6', ··· 2857 2857 'phabricator-keyboard-shortcut' => 'f363b322', 2858 2858 'phabricator-keyboard-shortcut-manager' => 'f363b322', 2859 2859 'phabricator-menu-item' => 'f363b322', 2860 - 'phabricator-object-selector-css' => '32f461a4', 2860 + 'phabricator-object-selector-css' => '96bc37d6', 2861 2861 'phabricator-paste-file-upload' => 'f363b322', 2862 2862 'phabricator-prefab' => 'f363b322', 2863 2863 'phabricator-project-tag-css' => '7839ae2d',
+2
src/__phutil_library_map__.php
··· 235 235 'DifferentialChangesetDetailView' => 'applications/differential/view/DifferentialChangesetDetailView.php', 236 236 'DifferentialChangesetListView' => 'applications/differential/view/DifferentialChangesetListView.php', 237 237 'DifferentialChangesetParser' => 'applications/differential/parser/DifferentialChangesetParser.php', 238 + 'DifferentialChangesetParserTestCase' => 'applications/differential/parser/__tests__/DifferentialChangesetParserTestCase.php', 238 239 'DifferentialChangesetViewController' => 'applications/differential/controller/DifferentialChangesetViewController.php', 239 240 'DifferentialComment' => 'applications/differential/storage/DifferentialComment.php', 240 241 'DifferentialCommentEditor' => 'applications/differential/editor/DifferentialCommentEditor.php', ··· 1304 1305 'DifferentialChangeset' => 'DifferentialDAO', 1305 1306 'DifferentialChangesetDetailView' => 'AphrontView', 1306 1307 'DifferentialChangesetListView' => 'AphrontView', 1308 + 'DifferentialChangesetParserTestCase' => 'ArcanistPhutilTestCase', 1307 1309 'DifferentialChangesetViewController' => 'DifferentialController', 1308 1310 'DifferentialComment' => 'DifferentialDAO', 1309 1311 'DifferentialCommentMail' => 'DifferentialMail',
+5 -1
src/applications/differential/controller/DifferentialChangesetViewController.php
··· 122 122 $left_data, 123 123 $right_data); 124 124 125 - $choice = nonempty($left, $right); 125 + $choice = clone nonempty($left, $right); 126 126 $choice->attachHunks($synthetic->getHunks()); 127 127 128 128 $changeset = $choice; ··· 165 165 $parser->setRightSideCommentMapping($right_source, $right_new); 166 166 $parser->setLeftSideCommentMapping($left_source, $left_new); 167 167 $parser->setWhitespaceMode($request->getStr('whitespace')); 168 + 169 + if ($left && $right) { 170 + $parser->setOriginals($left, $right); 171 + } 168 172 169 173 // Load both left-side and right-side inline comments. 170 174 $inlines = $this->loadInlineComments(
+80 -2
src/applications/differential/parser/DifferentialChangesetParser.php
··· 48 48 private $rightSideChangesetID; 49 49 private $rightSideAttachesToNewFile; 50 50 51 + private $originalLeft; 52 + private $originalRight; 53 + 51 54 private $renderingReference; 52 55 private $isSubparser; 53 56 ··· 106 109 $this->leftSideChangesetID = $id; 107 110 $this->leftSideAttachesToNewFile = $is_new; 108 111 return $this; 112 + } 113 + 114 + public function setOriginals( 115 + DifferentialChangeset $left, 116 + DifferentialChangeset $right) { 117 + 118 + $this->originalLeft = $left; 119 + $this->originalRight = $right; 120 + } 121 + 122 + public function diffOriginals() { 123 + $engine = new PhabricatorDifferenceEngine(); 124 + $changeset = $engine->generateChangesetFromFileContent( 125 + implode('', mpull($this->originalLeft->getHunks(), 'getChanges')), 126 + implode('', mpull($this->originalRight->getHunks(), 'getChanges'))); 127 + 128 + // Put changes side by side. 129 + $olds = array(); 130 + $news = array(); 131 + foreach ($changeset->getHunks() as $hunk) { 132 + $n_old = $hunk->getOldOffset(); 133 + $n_new = $hunk->getNewOffset(); 134 + $changes = rtrim($hunk->getChanges(), "\n"); 135 + foreach (explode("\n", $changes) as $line) { 136 + $type = $line[1]; // Change type in the original diff. 137 + if ($line[0] == ' ') { 138 + // Use the same key for lines that are next to each other. 139 + $key = max(last_key($olds), last_key($news)) + 1; 140 + $olds[$key] = null; 141 + $news[$key] = null; 142 + $n_old++; 143 + $n_new++; 144 + } else if ($line[0] == '-') { 145 + $olds[] = array($n_old, $type); 146 + $n_old++; 147 + } else if ($line[0] == '+') { 148 + $news[] = array($n_new, $type); 149 + $n_new++; 150 + } 151 + } 152 + } 153 + 154 + $offsets_old = $this->originalLeft->computeOffsets(); 155 + $offsets_new = $this->originalRight->computeOffsets(); 156 + 157 + // Highlight lines that were add on each side or removed on the other side. 158 + $highlight_old = array(); 159 + $highlight_new = array(); 160 + $last = max(last_key($olds), last_key($news)); 161 + for ($i = 0; $i <= $last; $i++) { 162 + if (isset($olds[$i])) { 163 + list($n, $type) = $olds[$i]; 164 + if ($type == '+' || 165 + ($type == ' ' && isset($news[$i]) && $news[$i][1] == '-')) { 166 + $highlight_old[] = $offsets_old[$n]; 167 + } 168 + } 169 + if (isset($news[$i])) { 170 + list($n, $type) = $news[$i]; 171 + if ($type == '+' || 172 + ($type == ' ' && isset($olds[$i]) && $olds[$i][1] == '-')) { 173 + $highlight_new[] = $offsets_new[$n]; 174 + } 175 + } 176 + } 177 + 178 + return array($highlight_old, $highlight_new); 109 179 } 110 180 111 181 /** ··· 269 339 270 340 $old = array(); 271 341 $new = array(); 272 - 273 - $n = 0; 274 342 275 343 $this->old = array_reverse($this->old); 276 344 $this->new = array_reverse($this->new); ··· 1290 1358 1291 1359 $copy_lines = idx($this->changeset->getMetadata(), 'copy:lines', array()); 1292 1360 1361 + if ($this->originalLeft && $this->originalRight) { 1362 + list($highlight_old, $highlight_new) = $this->diffOriginals(); 1363 + $highlight_old = array_flip($highlight_old); 1364 + $highlight_new = array_flip($highlight_new); 1365 + } 1366 + 1293 1367 for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) { 1294 1368 if (empty($mask[$ii])) { 1295 1369 // If we aren't going to show this line, we've just entered a gap. ··· 1386 1460 if ($this->old[$ii]['type'] == '\\') { 1387 1461 $o_text = $this->old[$ii]['text']; 1388 1462 $o_attr = ' class="comment"'; 1463 + } else if ($this->originalLeft && !isset($highlight_old[$o_num])) { 1464 + $o_attr = ' class="old-rebase"'; 1389 1465 } else if (empty($this->new[$ii])) { 1390 1466 $o_attr = ' class="old old-full"'; 1391 1467 } else { ··· 1421 1497 if ($this->new[$ii]['type'] == '\\') { 1422 1498 $n_text = $this->new[$ii]['text']; 1423 1499 $n_class = 'comment'; 1500 + } else if ($this->originalRight && !isset($highlight_new[$n_num])) { 1501 + $n_class = 'new-rebase'; 1424 1502 } else if (empty($this->old[$ii])) { 1425 1503 $n_class = 'new new-full'; 1426 1504 } else {
+53
src/applications/differential/parser/__tests__/DifferentialChangesetParserTestCase.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class DifferentialChangesetParserTestCase extends ArcanistPhutilTestCase { 20 + 21 + public function testDiffChangesets() { 22 + $hunk = new DifferentialHunk(); 23 + $hunk->setChanges("+a\n b\n-c"); 24 + $hunk->setNewOffset(1); 25 + $hunk->setNewLen(2); 26 + $left = new DifferentialChangeset(); 27 + $left->attachHunks(array($hunk)); 28 + 29 + $tests = array( 30 + "+a\n b\n-c" => array(array(), array()), 31 + "+a\n x\n-c" => array(array(), array()), 32 + "+aa\n b\n-c" => array(array(1), array(11)), 33 + " b\n-c" => array(array(1), array()), 34 + " x\n-c" => array(array(1), array()), 35 + "+a\n b\n c" => array(array(), array(13)), 36 + "+a\n x\n c" => array(array(), array(13)), 37 + ); 38 + 39 + foreach ($tests as $changes => $expected) { 40 + $hunk = new DifferentialHunk(); 41 + $hunk->setChanges($changes); 42 + $hunk->setNewOffset(11); 43 + $hunk->setNewLen(3); 44 + $right = new DifferentialChangeset(); 45 + $right->attachHunks(array($hunk)); 46 + 47 + $parser = new DifferentialChangesetParser(); 48 + $parser->setOriginals($left, $right); 49 + $this->assertEqual($expected, $parser->diffOriginals(), $changes); 50 + } 51 + } 52 + 53 + }
+14 -8
src/applications/differential/storage/DifferentialChangeset.php
··· 126 126 } 127 127 128 128 public function makeNewFile() { 129 - $file = array(); 130 - foreach ($this->getHunks() as $hunk) { 131 - $file[] = $hunk->makeNewFile(); 132 - } 133 - return implode("\n", $file); 129 + $file = mpull($this->getHunks(), 'makeNewFile'); 130 + return implode('', $file); 134 131 } 135 132 136 133 public function makeOldFile() { 137 - $file = array(); 134 + $file = mpull($this->getHunks(), 'makeOldFile'); 135 + return implode('', $file); 136 + } 137 + 138 + public function computeOffsets() { 139 + $offsets = array(); 140 + $n = 1; 138 141 foreach ($this->getHunks() as $hunk) { 139 - $file[] = $hunk->makeOldFile(); 142 + for ($i = 0; $i < $hunk->getNewLen(); $i++) { 143 + $offsets[$n] = $hunk->getNewOffset() + $i; 144 + $n++; 145 + } 140 146 } 141 - return implode("\n", $file); 147 + return $offsets; 142 148 } 143 149 144 150 public function makeChangesWithContext($num_lines = 3) {
+8
webroot/rsrc/css/application/differential/changeset-view.css
··· 75 75 background: #d0ffd0; 76 76 } 77 77 78 + .differential-diff td.old-rebase { 79 + background: #ffeeee; 80 + } 81 + 82 + .differential-diff td.new-rebase { 83 + background: #eeffee; 84 + } 85 + 78 86 .differential-diff td.old-full, 79 87 .differential-diff td.old span.bright { 80 88 background: #ffaaaa;