@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.

Further improve line grouping in unified views

Summary:
Ref T2009. This tweaks things a bit more to improve consecuitive groups of added and removed lines.

Generally, it gives us "old, old, old, new, new, new" intead of "old, new, old, new, old, new".

Feelin' real good about having unit tests for this stuff.

Test Plan: Unit tests, looked at diffs in web UI.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2009

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

+64 -14
+1 -1
src/applications/differential/__tests__/data/generated.diff.one.unshielded
··· 1 1 N 1 . @generated\n~ 2 2 O 2 - \n~ 3 - N 2 + \n~ 4 3 O 3 - This is a generated file.\n~ 4 + N 2 + \n~ 5 5 N 3 + This is a generated file{(, full of generated code)}.\n~ 6 6 N 4 . \n~
+16
src/applications/differential/__tests__/data/groups.diff
··· 1 + diff --git a/style b/style 2 + index a5fc249..18edce4 100644 3 + --- a/style 4 + +++ b/style 5 + @@ -57,8 +57,8 @@ 6 + .dashboard-panel div.phabricator-feed-frame { 7 + background: #fff; 8 + margin: 0; 9 + - border-left: 1px solid {$lightblueborder}; 10 + - border-right: 1px solid {$lightblueborder}; 11 + - border-bottom: 1px solid {$blueborder}; 12 + + border-back: 1px solid {$lightblueborder}; 13 + + border-front: 1px solid {$lightblueborder}; 14 + + border-inside: 1px solid {$blueborder}; 15 + max-width: none; 16 + }
+17
src/applications/differential/__tests__/data/groups.diff.one.expect
··· 1 + CTYPE 2 1 (unforced) 2 + style 3 + style 4 + - 5 + X <MISSING-CONTEXT> 6 + N 57 . .dashboard-panel div.phabricator-feed-frame {\n~ 7 + N 58 . background: #fff;\n~ 8 + N 59 . margin: 0;\n~ 9 + O 60 - border-{(left)}: 1px solid {$lightblueborder};\n~ 10 + O 61 - border-{(righ)}t: 1px solid {$lightblueborder};\n~ 11 + O 62 - border-{(bottom)}: 1px solid {$blueborder};\n~ 12 + N 60 + border-{(back)}: 1px solid {$lightblueborder};\n~ 13 + N 61 + border-{(fron)}t: 1px solid {$lightblueborder};\n~ 14 + N 62 + border-{(inside)}: 1px solid {$blueborder};\n~ 15 + N 63 . max-width: none;\n~ 16 + N 64 . }\n~ 17 + X <MISSING-CONTEXT>
+22
src/applications/differential/__tests__/data/groups.diff.two.expect
··· 1 + CTYPE 2 1 (unforced) 2 + style 3 + style 4 + - 5 + X <MISSING-CONTEXT> 6 + O 57 . .dashboard-panel div.phabricator-feed-frame {\n~ 7 + N 57 . .dashboard-panel div.phabricator-feed-frame {\n~ 8 + O 58 . background: #fff;\n~ 9 + N 58 . background: #fff;\n~ 10 + O 59 . margin: 0;\n~ 11 + N 59 . margin: 0;\n~ 12 + O 60 - border-{(left)}: 1px solid {$lightblueborder};\n~ 13 + N 60 + border-{(back)}: 1px solid {$lightblueborder};\n~ 14 + O 61 - border-{(righ)}t: 1px solid {$lightblueborder};\n~ 15 + N 61 + border-{(fron)}t: 1px solid {$lightblueborder};\n~ 16 + O 62 - border-{(bottom)}: 1px solid {$blueborder};\n~ 17 + N 62 + border-{(inside)}: 1px solid {$blueborder};\n~ 18 + O 63 . max-width: none;\n~ 19 + N 63 . max-width: none;\n~ 20 + O 64 . }\n~ 21 + N 64 . }\n~ 22 + X <MISSING-CONTEXT>
+8 -13
src/applications/differential/render/DifferentialChangesetRenderer.php
··· 503 503 // Ignore it when rendering a one-up diff. 504 504 continue; 505 505 } 506 - if ($new_buf) { 507 - $out[] = $new_buf; 508 - $new_buf = array(); 509 - } 510 506 $old_buf[] = $primitive; 511 507 } else if ($type == 'new') { 512 508 if ($primitive['line'] === null) { ··· 514 510 // old file. Ignore it when rendering a one-up diff. 515 511 continue; 516 512 } 517 - if ($old_buf) { 518 - $out[] = $old_buf; 519 - $old_buf = array(); 520 - } 521 513 if (!$primitive['htype']) { 522 514 // If this line is the same in both versions of the file, put it in 523 515 // the old line buffer. This makes sure inlines on old, unchanged 524 516 // lines end up in the right place. 525 517 526 - // First, we need to flush the new line buffer if there's anything 527 - // in it. 518 + // First, we need to flush the line buffers if they're not empty. 519 + if ($old_buf) { 520 + $out[] = $old_buf; 521 + $old_buf = array(); 522 + } 528 523 if ($new_buf) { 529 524 $out[] = $new_buf; 530 525 $new_buf = array(); ··· 545 540 if (!$primitive['right']) { 546 541 $out[] = $old_buf; 547 542 $out[] = array($primitive); 548 - $out[] = $new_buf; 543 + $old_buf = array(); 549 544 } else { 550 545 $out[] = $old_buf; 551 546 $out[] = $new_buf; 552 547 $out[] = array($primitive); 548 + $old_buf = array(); 549 + $new_buf = array(); 553 550 } 554 551 555 - $old_buf = array(); 556 - $new_buf = array(); 557 552 } else { 558 553 throw new Exception("Unknown primitive type '{$primitive}'!"); 559 554 }