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

Clean up Diffusion behaviors for inline edit suggestions

Summary: Ref T13513. For now, I'm not supporting inline edit suggestions in Diffusion, although it's likely not difficult to do so in the future. Clean up some of the code so that plain ol' inlines work the same way they did before.

Test Plan:
- Created, edited, reloaded, submitted inlines in Diffusion: familiar old behavior.
- Created, edited, reloaded, submitted inlines with suggestions in Differential: familiar new behavior.

Maniphest Tasks: T13513

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

+91 -73
+6 -6
resources/celerity/map.php
··· 13 13 'core.pkg.js' => '845355f4', 14 14 'dark-console.pkg.js' => '187792c2', 15 15 'differential.pkg.css' => '5c459f92', 16 - 'differential.pkg.js' => '256a327a', 16 + 'differential.pkg.js' => '24616785', 17 17 'diffusion.pkg.css' => '42c75c37', 18 18 'diffusion.pkg.js' => 'a98c0bf7', 19 19 'maniphest.pkg.css' => '35995d6d', ··· 381 381 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 382 382 'rsrc/js/application/diff/DiffChangeset.js' => '6e5e03d2', 383 383 'rsrc/js/application/diff/DiffChangesetList.js' => 'b51ba93a', 384 - 'rsrc/js/application/diff/DiffInline.js' => '829b88bf', 384 + 'rsrc/js/application/diff/DiffInline.js' => '008b6a15', 385 385 'rsrc/js/application/diff/DiffPathView.js' => '8207abf9', 386 386 'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b', 387 387 'rsrc/js/application/differential/behavior-diff-radios.js' => '925fe8cd', ··· 776 776 'phabricator-dashboard-css' => '5a205b9d', 777 777 'phabricator-diff-changeset' => '6e5e03d2', 778 778 'phabricator-diff-changeset-list' => 'b51ba93a', 779 - 'phabricator-diff-inline' => '829b88bf', 779 + 'phabricator-diff-inline' => '008b6a15', 780 780 'phabricator-diff-path-view' => '8207abf9', 781 781 'phabricator-diff-tree-view' => '5d83623b', 782 782 'phabricator-drag-and-drop-file-upload' => '4370900d', ··· 917 917 'unhandled-exception-css' => '9ecfc00d', 918 918 ), 919 919 'requires' => array( 920 + '008b6a15' => array( 921 + 'javelin-dom', 922 + ), 920 923 '0116d3e8' => array( 921 924 'javelin-behavior', 922 925 'javelin-dom', ··· 1637 1640 'javelin-vector', 1638 1641 ), 1639 1642 '8207abf9' => array( 1640 - 'javelin-dom', 1641 - ), 1642 - '829b88bf' => array( 1643 1643 'javelin-dom', 1644 1644 ), 1645 1645 83754533 => array(
+74
src/applications/differential/query/DifferentialDiffInlineCommentQuery.php
··· 67 67 return $id_map; 68 68 } 69 69 70 + protected function newInlineContextMap(array $inlines) { 71 + $viewer = $this->getViewer(); 72 + 73 + $map = array(); 74 + 75 + foreach ($inlines as $key => $inline) { 76 + $changeset = id(new DifferentialChangesetQuery()) 77 + ->setViewer($viewer) 78 + ->withIDs(array($inline->getChangesetID())) 79 + ->needHunks(true) 80 + ->executeOne(); 81 + if (!$changeset) { 82 + continue; 83 + } 84 + 85 + $hunks = $changeset->getHunks(); 86 + 87 + $is_simple = 88 + (count($hunks) === 1) && 89 + ((int)head($hunks)->getOldOffset() <= 1) && 90 + ((int)head($hunks)->getNewOffset() <= 1); 91 + 92 + if (!$is_simple) { 93 + continue; 94 + } 95 + 96 + if ($inline->getIsNewFile()) { 97 + $vector = $changeset->getNewStatePathVector(); 98 + $filename = last($vector); 99 + $corpus = $changeset->makeNewFile(); 100 + } else { 101 + $vector = $changeset->getOldStatePathVector(); 102 + $filename = last($vector); 103 + $corpus = $changeset->makeOldFile(); 104 + } 105 + 106 + $corpus = phutil_split_lines($corpus); 107 + 108 + // Adjust the line number into a 0-based offset. 109 + $offset = $inline->getLineNumber(); 110 + $offset = $offset - 1; 111 + 112 + // Adjust the inclusive range length into a row count. 113 + $length = $inline->getLineLength(); 114 + $length = $length + 1; 115 + 116 + $head_min = max(0, $offset - 3); 117 + $head_max = $offset; 118 + $head_len = $head_max - $head_min; 119 + 120 + if ($head_len) { 121 + $head = array_slice($corpus, $head_min, $head_len, true); 122 + $head = $this->simplifyContext($head, true); 123 + } else { 124 + $head = array(); 125 + } 126 + 127 + $body = array_slice($corpus, $offset, $length, true); 128 + 129 + $tail = array_slice($corpus, $offset + $length, 3, true); 130 + $tail = $this->simplifyContext($tail, false); 131 + 132 + $context = id(new PhabricatorDiffInlineCommentContext()) 133 + ->setFilename($filename) 134 + ->setHeadLines($head) 135 + ->setBodyLines($body) 136 + ->setTailLines($tail); 137 + 138 + $map[$key] = $context; 139 + } 140 + 141 + return $map; 142 + } 143 + 70 144 }
+4
src/applications/diffusion/query/DiffusionDiffInlineCommentQuery.php
··· 66 66 return array(); 67 67 } 68 68 69 + protected function newInlineContextMap(array $inlines) { 70 + return array(); 71 + } 72 + 69 73 }
+7 -65
src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php
··· 18 18 $viewer_phid, 19 19 array $comments); 20 20 21 + abstract protected function newInlineContextMap(array $inlines); 22 + 21 23 final public function withFixedStates(array $states) { 22 24 $this->fixedStates = $states; 23 25 return $this; ··· 265 267 $need_context[] = $inline; 266 268 } 267 269 268 - foreach ($need_context as $inline) { 269 - $changeset = id(new DifferentialChangesetQuery()) 270 - ->setViewer($viewer) 271 - ->withIDs(array($inline->getChangesetID())) 272 - ->needHunks(true) 273 - ->executeOne(); 274 - if (!$changeset) { 275 - $inline->attachInlineContext(null); 276 - continue; 277 - } 278 - 279 - $hunks = $changeset->getHunks(); 280 - 281 - $is_simple = 282 - (count($hunks) === 1) && 283 - ((int)head($hunks)->getOldOffset() <= 1) && 284 - ((int)head($hunks)->getNewOffset() <= 1); 285 - 286 - if (!$is_simple) { 287 - $inline->attachInlineContext(null); 288 - continue; 289 - } 290 - 291 - if ($inline->getIsNewFile()) { 292 - $vector = $changeset->getNewStatePathVector(); 293 - $filename = last($vector); 294 - $corpus = $changeset->makeNewFile(); 295 - } else { 296 - $vector = $changeset->getOldStatePathVector(); 297 - $filename = last($vector); 298 - $corpus = $changeset->makeOldFile(); 299 - } 300 - 301 - $corpus = phutil_split_lines($corpus); 302 - 303 - // Adjust the line number into a 0-based offset. 304 - $offset = $inline->getLineNumber(); 305 - $offset = $offset - 1; 306 - 307 - // Adjust the inclusive range length into a row count. 308 - $length = $inline->getLineLength(); 309 - $length = $length + 1; 310 - 311 - $head_min = max(0, $offset - 3); 312 - $head_max = $offset; 313 - $head_len = $head_max - $head_min; 270 + if ($need_context) { 271 + $context_map = $this->newInlineContextMap($need_context); 314 272 315 - if ($head_len) { 316 - $head = array_slice($corpus, $head_min, $head_len, true); 317 - $head = $this->simplifyContext($head, true); 318 - } else { 319 - $head = array(); 273 + foreach ($need_context as $key => $inline) { 274 + $inline->attachInlineContext(idx($context_map, $key)); 320 275 } 321 - 322 - $body = array_slice($corpus, $offset, $length, true); 323 - 324 - $tail = array_slice($corpus, $offset + $length, 3, true); 325 - $tail = $this->simplifyContext($tail, false); 326 - 327 - $context = id(new PhabricatorDiffInlineCommentContext()) 328 - ->setFilename($filename) 329 - ->setHeadLines($head) 330 - ->setBodyLines($body) 331 - ->setTailLines($tail); 332 - 333 - $inline->attachInlineContext($context); 334 276 } 335 277 336 278 } ··· 338 280 return $inlines; 339 281 } 340 282 341 - private function simplifyContext(array $lines, $is_head) { 283 + final protected function simplifyContext(array $lines, $is_head) { 342 284 // We want to provide the smallest amount of context we can while still 343 285 // being useful, since the actual code is visible nearby and showing a 344 286 // ton of context is silly.
-2
webroot/rsrc/js/application/diff/DiffInline.js
··· 668 668 this._editRow = this._drawRows(rows, null, 'edit'); 669 669 670 670 this._drawSuggestionState(this._editRow); 671 - JX.log(this._originalState); 672 - 673 671 this.setHasSuggestion(this._originalState.hasSuggestion); 674 672 }, 675 673