Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/parser/DifferentialChangesetParser.php
| Show First 20 Lines • Show All 974 Lines • ▼ Show 20 Lines | if ($this->comments) { | ||||
| // partial-context diff. | // partial-context diff. | ||||
| list($old_backmap, $new_backmap) = $this->buildLineBackmaps(); | list($old_backmap, $new_backmap) = $this->buildLineBackmaps(); | ||||
| foreach ($this->comments as $comment) { | foreach ($this->comments as $comment) { | ||||
| $new_side = $this->isCommentOnRightSideWhenDisplayed($comment); | $new_side = $this->isCommentOnRightSideWhenDisplayed($comment); | ||||
| $line = $comment->getLineNumber(); | $line = $comment->getLineNumber(); | ||||
| if ($new_side) { | |||||
| $back_line = $new_backmap[$line]; | // See T13524. Lint inlines from Harbormaster may not have a line | ||||
| // number. | |||||
| if ($line === null) { | |||||
| $back_line = null; | |||||
| } else if ($new_side) { | |||||
| $back_line = idx($new_backmap, $line); | |||||
| } else { | } else { | ||||
| $back_line = $old_backmap[$line]; | $back_line = idx($old_backmap, $line); | ||||
| } | } | ||||
| if ($back_line != $line) { | if ($back_line != $line) { | ||||
| // TODO: This should probably be cleaner, but just be simple and | // TODO: This should probably be cleaner, but just be simple and | ||||
| // obvious for now. | // obvious for now. | ||||
| $ghost = $comment->getIsGhost(); | $ghost = $comment->getIsGhost(); | ||||
| if ($ghost) { | if ($ghost) { | ||||
| $moved = pht( | $moved = pht( | ||||
| 'This comment originally appeared on line %s, but that line '. | 'This comment originally appeared on line %s, but that line '. | ||||
| 'does not exist in this version of the diff. It has been '. | 'does not exist in this version of the diff. It has been '. | ||||
| 'moved backward to the nearest line.', | 'moved backward to the nearest line.', | ||||
| new PhutilNumber($line)); | new PhutilNumber($line)); | ||||
| $ghost['reason'] = $ghost['reason']."\n\n".$moved; | $ghost['reason'] = $ghost['reason']."\n\n".$moved; | ||||
| $comment->setIsGhost($ghost); | $comment->setIsGhost($ghost); | ||||
| } | } | ||||
| $comment->setLineNumber($back_line); | $comment->setLineNumber($back_line); | ||||
| $comment->setLineLength(0); | $comment->setLineLength(0); | ||||
| } | } | ||||
| $start = max($comment->getLineNumber() - $lines_context, 0); | $start = max($comment->getLineNumber() - $lines_context, 0); | ||||
| $end = $comment->getLineNumber() + | $end = $comment->getLineNumber() + | ||||
| $comment->getLineLength() + | $comment->getLineLength() + | ||||
| $lines_context; | $lines_context; | ||||
| for ($ii = $start; $ii <= $end; $ii++) { | for ($ii = $start; $ii <= $end; $ii++) { | ||||
| if ($new_side) { | if ($new_side) { | ||||
| ▲ Show 20 Lines • Show All 911 Lines • Show Last 20 Lines | |||||