Select the types of activity you want to include in your feed.
@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
···3939 protected $whitespaceMode = null;
40404141 protected $subparser;
4242+ protected $oldChangesetID = null;
4243 protected $noHighlight;
43444445 protected $renderCacheKey = null;
···4647 private $handles;
4748 private $user;
48494949- private $leftSideChangesetID;
5050- private $leftSideAttachesToNewFile;
5151-5252- private $rightSideChangesetID;
5353- private $rightSideAttachesToNewFile;
5454-5550 const CACHE_VERSION = 4;
56515752 const ATTR_GENERATED = 'attr:generated';
···6560 const WHITESPACE_IGNORE_TRAILING = 'ignore-trailing';
6661 const WHITESPACE_IGNORE_ALL = 'ignore-all';
67626868- /**
6969- * Configure which Changeset comments added to the right side of the visible
7070- * diff will be attached to. The ID must be the ID of a real Differential
7171- * Changeset.
7272- *
7373- * The complexity here is that we may show an arbitrary side of an arbitrary
7474- * changeset as either the left or right part of a diff. This method allows
7575- * the left and right halves of the displayed diff to be correctly mapped to
7676- * storage changesets.
7777- *
7878- * @param id The Differential Changeset ID that comments added to the right
7979- * side of the visible diff should be attached to.
8080- * @param bool If true, attach new comments to the right side of the storage
8181- * changeset. Note that this may be false, if the left side of
8282- * some storage changeset is being shown as the right side of
8383- * a display diff.
8484- * @return this
8585- */
8663 public function setRightSideCommentMapping($id, $is_new) {
8787- $this->rightSideChangesetID = $id;
8888- $this->rightSideAttachesToNewFile = $is_new;
8989- return $this;
6464+9065 }
91669292- /**
9393- * See setRightSideCommentMapping(), but this sets information for the left
9494- * side of the display diff.
9595- */
9667 public function setLeftSideCommentMapping($id, $is_new) {
9797- $this->leftSideChangesetID = $id;
9898- $this->leftSideAttachesToNewFile = $is_new;
9999- return $this;
6868+10069 }
1017010271 /**
···132101133102 public function setWhitespaceMode($whitespace_mode) {
134103 $this->whitespaceMode = $whitespace_mode;
104104+ return $this;
105105+ }
106106+107107+ public function setOldChangesetID($old_changeset_id) {
108108+ $this->oldChangesetID = $old_changeset_id;
135109 return $this;
136110 }
137111···262236 }
263237264238 public function parseInlineComment(DifferentialInlineComment $comment) {
265265- // Parse only comments which are actually visible.
266266- if ($this->isCommentVisibleOnRenderedDiff($comment)) {
267267- $this->comments[] = $comment;
268268- }
239239+ $this->comments[] = $comment;
269240 return $this;
270241 }
271242···866837 $end = $comment->getLineNumber() +
867838 $comment->getLineLength() +
868839 self::LINES_CONTEXT;
869869- $new = $this->isCommentOnRightSideWhenDisplayed($comment);
840840+ $new = $this->isCommentInNewFile($comment);
870841 for ($ii = $start; $ii <= $end; $ii++) {
871842 if ($new) {
872843 $new_mask[$ii] = true;
···891862 foreach ($this->comments as $comment) {
892863 $final = $comment->getLineNumber() +
893864 $comment->getLineLength();
894894- if ($this->isCommentOnRightSideWhenDisplayed($comment)) {
865865+ if ($this->isCommentInNewFile($comment)) {
895866 $new_comments[$final][] = $comment;
896867 } else {
897868 $old_comments[$final][] = $comment;
···910881 return $this->renderChangesetTable($this->changeset, $html);
911882 }
912883913913- /**
914914- * Determine if an inline comment will appear on the rendered diff,
915915- * taking into consideration which halves of which changesets will actually
916916- * be shown.
917917- *
918918- * @param DifferentialInlineComment Comment to test for visibility.
919919- * @return bool True if the comment is visible on the rendered diff.
920920- */
921921- private function isCommentVisibleOnRenderedDiff(
922922- DifferentialInlineComment $comment) {
923923-924924- $changeset_id = $comment->getChangesetID();
925925- $is_new = $comment->getIsNewFile();
926926-927927- if ($changeset_id == $this->rightSideChangesetID &&
928928- $is_new == $this->rightSideAttachesToNewFile) {
929929- return true;
930930- }
931931-932932- if ($changeset_id == $this->leftSideChangesetID &&
933933- $is_new == $this->leftSideAttachesToNewFile) {
934934- return true;
935935- }
936936-937937- return false;
938938- }
939939-940940-941941- /**
942942- * Determine if a comment will appear on the right side of the display diff.
943943- * Note that the comment must appear somewhere on the rendered changeset, as
944944- * per isCommentVisibleOnRenderedDiff().
945945- *
946946- * @param DifferentialInlineComment Comment to test for display location.
947947- * @return bool True for right, false for left.
948948- */
949949- private function isCommentOnRightSideWhenDisplayed(
950950- DifferentialInlineComment $comment) {
951951-952952- if (!$this->isCommentVisibleOnRenderedDiff($comment)) {
953953- throw new Exception("Comment is not visible on changeset!");
884884+ private function isCommentInNewFile(DifferentialInlineComment $comment) {
885885+ if ($this->oldChangesetID) {
886886+ return ($comment->getChangesetID() != $this->oldChangesetID);
887887+ } else {
888888+ return $comment->getIsNewFile();
954889 }
955955-956956- $changeset_id = $comment->getChangesetID();
957957- $is_new = $comment->getIsNewFile();
958958-959959- if ($changeset_id == $this->rightSideChangesetID &&
960960- $is_new == $this->rightSideAttachesToNewFile) {
961961- return true;
962962- }
963963-964964- return false;
965890 }
966891967892 protected function renderShield($message, $more) {
···10369611037962 $range_len = min($range_len, $rows - $range_start);
103896310391039- // Gaps - compute gaps in the visible display diff, where we will render
10401040- // "Show more context" spacers. This builds an aggregate $mask of all the
10411041- // lines we must show (because they are near changed lines, near inline
10421042- // comments, or the request has explicitly asked for them, i.e. resulting
10431043- // from the user clicking "show more") and then finds all the gaps between
10441044- // visible lines. If a gap is smaller than the context size, we just
10451045- // display it. Otherwise, we record it into $gaps and will render a
10461046- // "show more context" element instead of diff text below.
10471047-1048964 $gaps = array();
1049965 $gap_start = 0;
1050966 $in_gap = false;
···10739891074990 $gaps = array_reverse($gaps);
1075991992992+ $changeset = $this->changesetID;
1076993 $reference = $this->getChangeset()->getRenderingReference();
107799410781078- $left_id = $this->leftSideChangesetID;
10791079- $right_id = $this->rightSideChangesetID;
10801080-10811081- // "N" stands for 'new' and means the comment should attach to the new file
10821082- // when stored, i.e. DifferentialInlineComment->setIsNewFile().
10831083- // "O" stands for 'old' and means the comment should attach to the old file.
10841084-10851085- $left_char = $this->leftSideAttachesToNewFile
10861086- ? 'N'
10871087- : 'O';
10881088- $right_char = $this->rightSideAttachesToNewFile
10891089- ? 'N'
10901090- : 'O';
10911091-1092995 for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) {
1093996 if (empty($mask[$ii])) {
10941094- // If we aren't going to show this line, we've just entered a gap.
10951095- // Pop information about the next gap off the $gaps stack and render
10961096- // an appropriate "Show more context" element. This branch eventually
10971097- // increments $ii by the entire size of the gap and then continues
10981098- // the loop.
1099997 $gap = array_pop($gaps);
1100998 $top = $gap[0];
1101999 $len = $gap[1];
···12021100 $html[] = $context_not_available;
12031101 }
1204110212051205- if ($o_num && $left_id) {
12061206- $o_id = ' id="C'.$left_id.$left_char.'L'.$o_num.'"';
11031103+ if ($o_num && $changeset) {
11041104+ $o_id = ' id="C'.$changeset.'OL'.$o_num.'"';
12071105 } else {
12081106 $o_id = null;
12091107 }
1210110812111211- if ($n_num && $right_id) {
12121212- $n_id = ' id="C'.$right_id.$right_char.'L'.$n_num.'"';
11091109+ if ($n_num && $changeset) {
11101110+ $n_id = ' id="C'.$changeset.'NL'.$n_num.'"';
12131111 } else {
12141112 $n_id = null;
12151113 }
···12581156 ($comment->getAuthorPHID() == $user->getPHID()) &&
12591157 (!$comment->getCommentID());
1260115812611261- $on_right = $this->isCommentOnRightSideWhenDisplayed($comment);
11591159+ $on_right = $this->isCommentInNewFile($comment);
1262116012631161 return id(new DifferentialInlineCommentView())
12641162 ->setInlineComment($comment)