From d199e6172971d929a59f80e9642ed8d4193ee05e Mon Sep 17 00:00:00 2001 From: Andrew Bonventre Date: Mon, 11 Jan 2016 12:24:16 -0500 Subject: [PATCH] Properly annotate parent comments with the patch number associated Comments/drafts on the base file (PARENT) are actually part of the patchset they are created under. PARENT is not a valid patch set to save them under. Account for this when saving/creating new ones. Change-Id: I151d83d03192efab50152ce5018e26b737e08e19 --- polygerrit-ui/app/elements/gr-diff-side.html | 2 +- polygerrit-ui/app/elements/gr-diff.html | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/polygerrit-ui/app/elements/gr-diff-side.html b/polygerrit-ui/app/elements/gr-diff-side.html index 695a0daf25..a61b1970df 100644 --- a/polygerrit-ui/app/elements/gr-diff-side.html +++ b/polygerrit-ui/app/elements/gr-diff-side.html @@ -397,7 +397,7 @@ limitations under the License. this._handleCommentThreadDiscard.bind(this)); threadEl.setAttribute('data-index', index); threadEl.changeNum = this.changeNum; - threadEl.patchNum = this.patchNum; + threadEl.patchNum = thread.patchNum || this.patchNum; threadEl.path = this.path; threadEl.comments = thread.comments; threadEl.showActions = this.canComment; diff --git a/polygerrit-ui/app/elements/gr-diff.html b/polygerrit-ui/app/elements/gr-diff.html index 454bf9b348..730e937474 100644 --- a/polygerrit-ui/app/elements/gr-diff.html +++ b/polygerrit-ui/app/elements/gr-diff.html @@ -406,6 +406,12 @@ limitations under the License. path: this.path, }] }; + if (diffEl == this.$.leftDiff && + this.patchRange.basePatchNum == 'PARENT') { + comment.comments[0].side = 'PARENT'; + comment.patchNum = this.patchRange.patchNum; + } + if (content[insertIndex] && content[insertIndex].type == 'FILLER') { content[insertIndex] = comment; @@ -642,10 +648,14 @@ limitations under the License. var leftComments = this._groupedBaseComments[ctx.left.lineNum]; var rightComments = this._groupedComments[ctx.right.lineNum]; if (leftComments) { - leftSide.push({ + var thread = { type: 'COMMENT_THREAD', comments: leftComments, - }); + }; + if (this.patchRange.basePatchNum == 'PARENT') { + thread.patchNum = this.patchRange.patchNum; + } + leftSide.push(thread); } if (rightComments) { rightSide.push({