diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/PatchLineCommentsUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/PatchLineCommentsUtil.java index 732a9b88de..11389e6871 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/PatchLineCommentsUtil.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/PatchLineCommentsUtil.java @@ -348,7 +348,7 @@ public class PatchLineCommentsUtil { return sort(result); } - public static RevId setCommentRevId(PatchLineComment c, + public static void setCommentRevId(PatchLineComment c, PatchListCache cache, Change change, PatchSet ps) throws OrmException { checkArgument(c.getPatchSetId().equals(ps.getId()), "cannot set RevId for patch set %s on comment %s", ps.getId(), c); @@ -369,7 +369,6 @@ public class PatchLineCommentsUtil { throw new OrmException(e); } } - return c.getRevId(); } public Collection getDraftRefs(Change.Id changeId) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/RevisionNote.java b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/RevisionNote.java index d93336a3da..4c9f7026e8 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/RevisionNote.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/RevisionNote.java @@ -83,7 +83,7 @@ class RevisionNote { if (isJson(raw, p.value)) { RevisionNoteData data = parseJson(noteUtil, p.value); - comments = data.exportComments(status); + comments = data.exportComments(changeId, status); if (status == PatchLineComment.Status.PUBLISHED) { pushCert = data.pushCert; } else { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/RevisionNoteData.java b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/RevisionNoteData.java index 8d020bdbd6..73083b797d 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/RevisionNoteData.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/RevisionNoteData.java @@ -48,19 +48,17 @@ class RevisionNoteData { String uuid; String filename; int patchSetId; - int changeId; CommentKey(PatchLineComment.Key k) { uuid = k.get(); filename = k.getParentKey().getFileName(); patchSetId = k.getParentKey().getParentKey().get(); - changeId = k.getParentKey().getParentKey().getParentKey().get(); } - PatchLineComment.Key export() { + PatchLineComment.Key export(Change.Id changeId) { return new PatchLineComment.Key( new Patch.Key( - new PatchSet.Id(new Change.Id(changeId), patchSetId), + new PatchSet.Id(changeId, patchSetId), filename), uuid); } @@ -90,7 +88,6 @@ class RevisionNoteData { int lineNbr; Identity author; Timestamp writtenOn; - char status; short side; String message; String parentUuid; @@ -104,7 +101,6 @@ class RevisionNoteData { lineNbr = plc.getLine(); author = new Identity(plc.getAuthor()); writtenOn = plc.getWrittenOn(); - status = plc.getStatus().getCode(); side = plc.getSide(); message = plc.getMessage(); parentUuid = plc.getParentUuid(); @@ -114,17 +110,18 @@ class RevisionNoteData { this.serverId = serverId; } - PatchLineComment export() { + PatchLineComment export(Change.Id changeId, + PatchLineComment.Status status) { PatchLineComment plc = new PatchLineComment( - key.export(), lineNbr, author.export(), parentUuid, writtenOn); + key.export(changeId), lineNbr, author.export(), parentUuid, writtenOn); plc.setSide(side); - plc.setStatus(PatchLineComment.Status.forCode(status)); plc.setMessage(message); if (range != null) { plc.setRange(range.export()); } plc.setTag(tag); plc.setRevId(new RevId(revId)); + plc.setStatus(status); return plc; } } @@ -133,16 +130,12 @@ class RevisionNoteData { String pushCert; List comments; - ImmutableList exportComments( + + ImmutableList exportComments(Change.Id changeId, PatchLineComment.Status status) { return ImmutableList.copyOf( comments.stream() - .map( - c -> { - PatchLineComment plc = c.export(); - plc.setStatus(status); - return plc; - }) + .map(c -> c.export(changeId, status)) .collect(toList())); } }