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

In Jupyter notebooks, apply intraline diffing to source code lines

Summary: Ref T13425. When we render a diff between two source lines, highlight intraline changes.

Test Plan: Viewed a Jupyter notebook with a code diff in it, saw the changed subsequences in the line highlighted.

Maniphest Tasks: T13425

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

+63 -9
+3 -3
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => '3c8a0668', 11 11 'conpherence.pkg.js' => '020aebcf', 12 - 'core.pkg.css' => '7ce5a944', 12 + 'core.pkg.css' => '88366522', 13 13 'core.pkg.js' => '6e5c894f', 14 14 'differential.pkg.css' => '607c84be', 15 15 'differential.pkg.js' => 'a0212a0b', ··· 169 169 'rsrc/css/phui/phui-pager.css' => 'd022c7ad', 170 170 'rsrc/css/phui/phui-pinboard-view.css' => '1f08f5d8', 171 171 'rsrc/css/phui/phui-policy-section-view.css' => '139fdc64', 172 - 'rsrc/css/phui/phui-property-list-view.css' => '807b1632', 172 + 'rsrc/css/phui/phui-property-list-view.css' => '9c477af1', 173 173 'rsrc/css/phui/phui-remarkup-preview.css' => '91767007', 174 174 'rsrc/css/phui/phui-segment-bar-view.css' => '5166b370', 175 175 'rsrc/css/phui/phui-spacing.css' => 'b05cadc3', ··· 865 865 'phui-pager-css' => 'd022c7ad', 866 866 'phui-pinboard-view-css' => '1f08f5d8', 867 867 'phui-policy-section-view-css' => '139fdc64', 868 - 'phui-property-list-view-css' => '807b1632', 868 + 'phui-property-list-view-css' => '9c477af1', 869 869 'phui-remarkup-preview-css' => '91767007', 870 870 'phui-segment-bar-view-css' => '5166b370', 871 871 'phui-spacing-css' => 'b05cadc3',
+58 -4
src/applications/files/document/PhabricatorJupyterDocumentEngine.php
··· 98 98 ->addOldClass('old') 99 99 ->setNewContent($v_content) 100 100 ->addNewClass('new'); 101 + case 'code/line': 102 + $usource = idx($ucell, 'raw'); 103 + $vsource = idx($vcell, 'raw'); 104 + $udisplay = idx($ucell, 'display'); 105 + $vdisplay = idx($vcell, 'display'); 106 + $ulabel = idx($ucell, 'label'); 107 + $vlabel = idx($vcell, 'label'); 108 + 109 + $intraline_segments = ArcanistDiffUtils::generateIntralineDiff( 110 + $usource, 111 + $vsource); 112 + 113 + $u_segments = array(); 114 + foreach ($intraline_segments[0] as $u_segment) { 115 + $u_segments[] = $u_segment; 116 + } 117 + 118 + $v_segments = array(); 119 + foreach ($intraline_segments[1] as $v_segment) { 120 + $v_segments[] = $v_segment; 121 + } 122 + 123 + $usource = ArcanistDiffUtils::applyIntralineDiff( 124 + $udisplay, 125 + $u_segments); 126 + 127 + $vsource = ArcanistDiffUtils::applyIntralineDiff( 128 + $vdisplay, 129 + $v_segments); 130 + 131 + $u_content = $this->newCodeLineCell($ucell, $usource); 132 + $v_content = $this->newCodeLineCell($vcell, $vsource); 133 + 134 + $classes = array( 135 + 'jupyter-cell-flush', 136 + ); 137 + 138 + $u_content = $this->newJupyterCell($ulabel, $u_content, $classes); 139 + $v_content = $this->newJupyterCell($vlabel, $v_content, $classes); 140 + 141 + $u_content = $this->newCellContainer($u_content); 142 + $v_content = $this->newCellContainer($v_content); 143 + 144 + return id(new PhabricatorDocumentEngineBlockDiff()) 145 + ->setOldContent($u_content) 146 + ->addOldClass('old') 147 + ->setNewContent($v_content) 148 + ->addNewClass('new'); 101 149 } 102 150 } 103 151 ··· 441 489 return $this->newCodeOutputCell($cell); 442 490 } 443 491 444 - return $this->newRawCell(id(new PhutilJSON()) 445 - ->encodeFormatted($cell)); 492 + $json_content = id(new PhutilJSON()) 493 + ->encodeFormatted($cell); 494 + 495 + return $this->newRawCell($json_content); 446 496 } 447 497 448 498 private function newRawCell($content) { ··· 514 564 ); 515 565 } 516 566 517 - private function newCodeLineCell(array $cell) { 567 + private function newCodeLineCell(array $cell, $content = null) { 518 568 $classes = array(); 519 569 $classes[] = 'PhabricatorMonospaced'; 520 570 $classes[] = 'remarkup-code'; ··· 531 581 532 582 $classes = implode(' ', $classes); 533 583 584 + if ($content === null) { 585 + $content = $cell['display']; 586 + } 587 + 534 588 return array( 535 589 $cell['label'], 536 590 array( ··· 540 594 'class' => $classes, 541 595 ), 542 596 array( 543 - $cell['display'], 597 + $content, 544 598 )), 545 599 ), 546 600 );
+2 -2
webroot/rsrc/css/phui/phui-property-list-view.css
··· 316 316 } 317 317 318 318 td.new .jupyter-cell-code-line { 319 - background: {$new-background}; 319 + background: rgba(255, 255, 255, 0.5); 320 320 border-color: {$new-bright}; 321 321 } 322 322 323 323 td.old .jupyter-cell-code-line { 324 - background: {$old-background}; 324 + background: rgba(255, 255, 255, 0.5); 325 325 border-color: {$old-bright}; 326 326 } 327 327