Remove changeId from RevisionNoteData.CommentKey

Inline comments are stored in refs that contain the change ID, hence
it's redundant to store the change ID again for each comment. Remove
the changeId from CommentKey, so that it cannot be inconsistent with
the changeId from the ref.

Change-Id: Ibcbb59cf9ad4f1e6fbe94e1ac134daf6d50a4c05
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-09-20 10:39:30 +02:00
parent a05a22f59e
commit e555239d09
2 changed files with 9 additions and 9 deletions

View File

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

View File

@@ -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);
}
@@ -112,9 +110,10 @@ class RevisionNoteData {
this.serverId = serverId;
}
PatchLineComment export(PatchLineComment.Status status) {
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.setMessage(message);
if (range != null) {
@@ -131,11 +130,12 @@ class RevisionNoteData {
String pushCert;
List<Comment> comments;
ImmutableList<PatchLineComment> exportComments(
ImmutableList<PatchLineComment> exportComments(Change.Id changeId,
PatchLineComment.Status status) {
return ImmutableList.copyOf(
comments.stream()
.map(c -> c.export(status))
.map(c -> c.export(changeId, status))
.collect(toList()));
}
}