Use ObjectId instead of RevId throughout NoteDb comment code
See Iff5644e2 context on removing RevId usages. Change-Id: Ic586756132ace9d4d4c651294e4a1cf56cbb0536
This commit is contained in:
@@ -21,6 +21,7 @@ import java.sql.Timestamp;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
import org.eclipse.jgit.lib.AnyObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
/**
|
||||
* This class represents inline comments in NoteDb. This means it determines the JSON format for
|
||||
@@ -196,8 +197,10 @@ public class Comment {
|
||||
|
||||
// Hex commit SHA1 of the commit of the patchset to which this comment applies. Other classes call
|
||||
// this "commitId", but this class uses the old ReviewDb term "revId", and this field name is
|
||||
// serialized into JSON in NoteDb, so it can't easily be changed.
|
||||
public String revId;
|
||||
// serialized into JSON in NoteDb, so it can't easily be changed. Callers do not access this field
|
||||
// directly, and instead use the public getter/setter that wraps an ObjectId.
|
||||
private String revId;
|
||||
|
||||
public String serverId;
|
||||
public boolean unresolved;
|
||||
|
||||
@@ -254,8 +257,13 @@ public class Comment {
|
||||
this.range = range != null ? range.asCommentRange() : null;
|
||||
}
|
||||
|
||||
public void setRevId(@Nullable AnyObjectId revId) {
|
||||
this.revId = revId != null ? revId.name() : null;
|
||||
@Nullable
|
||||
public ObjectId getCommitId() {
|
||||
return revId != null ? ObjectId.fromString(revId) : null;
|
||||
}
|
||||
|
||||
public void setCommitId(@Nullable AnyObjectId commitId) {
|
||||
this.revId = commitId != null ? commitId.name() : null;
|
||||
}
|
||||
|
||||
public void setRealAuthor(Account.Id id) {
|
||||
|
@@ -70,7 +70,7 @@ public final class PatchLineComment {
|
||||
plc.setRange(new CommentRange(r.startLine, r.startChar, r.endLine, r.endChar));
|
||||
}
|
||||
plc.setTag(c.tag);
|
||||
plc.setCommitId(ObjectId.fromString(c.revId));
|
||||
plc.setCommitId(c.getCommitId());
|
||||
plc.setStatus(status);
|
||||
plc.setRealAuthor(c.getRealAuthor().getId());
|
||||
plc.setUnresolved(c.unresolved);
|
||||
@@ -268,7 +268,7 @@ public final class PatchLineComment {
|
||||
message,
|
||||
serverId,
|
||||
unresolved);
|
||||
c.setRevId(commitId);
|
||||
c.setCommitId(commitId);
|
||||
c.setRange(range);
|
||||
c.lineNbr = lineNbr;
|
||||
c.parentUuid = parentUuid;
|
||||
|
@@ -306,22 +306,22 @@ public class CommentsUtil {
|
||||
return sort(result);
|
||||
}
|
||||
|
||||
public static void setCommentRevId(Comment c, PatchListCache cache, Change change, PatchSet ps)
|
||||
public static void setCommentCommitId(Comment c, PatchListCache cache, Change change, PatchSet ps)
|
||||
throws PatchListNotAvailableException {
|
||||
checkArgument(
|
||||
c.key.patchSetId == ps.getId().get(),
|
||||
"cannot set RevId for patch set %s on comment %s",
|
||||
"cannot set commit ID for patch set %s on comment %s",
|
||||
ps.getId(),
|
||||
c);
|
||||
if (c.revId == null) {
|
||||
if (c.getCommitId() == null) {
|
||||
if (Side.fromShort(c.side) == Side.PARENT) {
|
||||
if (c.side < 0) {
|
||||
c.revId = ObjectId.toString(cache.getOldId(change, ps, -c.side));
|
||||
c.setCommitId(cache.getOldId(change, ps, -c.side));
|
||||
} else {
|
||||
c.revId = ObjectId.toString(cache.getOldId(change, ps, null));
|
||||
c.setCommitId(cache.getOldId(change, ps, null));
|
||||
}
|
||||
} else {
|
||||
c.revId = ps.getRevision().get();
|
||||
c.setCommitId(ObjectId.fromString(ps.getRevision().get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ public class PublishCommentUtil {
|
||||
// applies to X-Gerrit-RunAs, since modifying drafts via on_behalf_of is not allowed.)
|
||||
ctx.getUser().updateRealAccountId(d::setRealAuthor);
|
||||
try {
|
||||
CommentsUtil.setCommentRevId(d, patchListCache, notes.getChange(), ps);
|
||||
CommentsUtil.setCommentCommitId(d, patchListCache, notes.getChange(), ps);
|
||||
} catch (PatchListNotAvailableException e) {
|
||||
throw new StorageException(e);
|
||||
}
|
||||
|
@@ -399,7 +399,7 @@ public class MailProcessor {
|
||||
comment.range = mailComment.getInReplyTo().range;
|
||||
comment.unresolved = mailComment.getInReplyTo().unresolved;
|
||||
}
|
||||
CommentsUtil.setCommentRevId(comment, patchListCache, ctx.getChange(), patchSetForComment);
|
||||
CommentsUtil.setCommentCommitId(comment, patchListCache, ctx.getChange(), patchSetForComment);
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
|
@@ -271,7 +271,7 @@ public abstract class AbstractChangeUpdate {
|
||||
}
|
||||
|
||||
protected void verifyComment(Comment c) {
|
||||
checkArgument(c.revId != null, "RevId required for comment: %s", c);
|
||||
checkArgument(c.getCommitId() != null, "commit ID required for comment: %s", c);
|
||||
checkArgument(
|
||||
c.author.getId().equals(getAccountId()),
|
||||
"The author for the following comment does not match the author of this %s (%s): %s",
|
||||
|
@@ -26,7 +26,6 @@ import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.config.AllUsersName;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -74,13 +73,13 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate {
|
||||
|
||||
@AutoValue
|
||||
abstract static class Key {
|
||||
abstract String revId();
|
||||
abstract ObjectId commitId();
|
||||
|
||||
abstract Comment.Key key();
|
||||
}
|
||||
|
||||
private static Key key(Comment c) {
|
||||
return new AutoValue_ChangeDraftUpdate_Key(c.revId, c.key);
|
||||
return new AutoValue_ChangeDraftUpdate_Key(c.getCommitId(), c.key);
|
||||
}
|
||||
|
||||
private final AllUsersName draftsProject;
|
||||
@@ -126,32 +125,32 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate {
|
||||
delete.add(key(c));
|
||||
}
|
||||
|
||||
public void deleteComment(String revId, Comment.Key key) {
|
||||
delete.add(new AutoValue_ChangeDraftUpdate_Key(revId, key));
|
||||
public void deleteComment(ObjectId commitId, Comment.Key key) {
|
||||
delete.add(new AutoValue_ChangeDraftUpdate_Key(commitId, key));
|
||||
}
|
||||
|
||||
private CommitBuilder storeCommentsInNotes(
|
||||
RevWalk rw, ObjectInserter ins, ObjectId curr, CommitBuilder cb)
|
||||
throws ConfigInvalidException, IOException {
|
||||
RevisionNoteMap<ChangeRevisionNote> rnm = getRevisionNoteMap(rw, curr);
|
||||
Set<RevId> updatedRevs = Sets.newHashSetWithExpectedSize(rnm.revisionNotes.size());
|
||||
Set<ObjectId> updatedCommits = Sets.newHashSetWithExpectedSize(rnm.revisionNotes.size());
|
||||
RevisionNoteBuilder.Cache cache = new RevisionNoteBuilder.Cache(rnm);
|
||||
|
||||
for (Comment c : put) {
|
||||
if (!delete.contains(key(c))) {
|
||||
cache.get(new RevId(c.revId)).putComment(c);
|
||||
cache.get(c.getCommitId()).putComment(c);
|
||||
}
|
||||
}
|
||||
for (Key k : delete) {
|
||||
cache.get(new RevId(k.revId())).deleteComment(k.key());
|
||||
cache.get(k.commitId()).deleteComment(k.key());
|
||||
}
|
||||
|
||||
Map<RevId, RevisionNoteBuilder> builders = cache.getBuilders();
|
||||
Map<ObjectId, RevisionNoteBuilder> builders = cache.getBuilders();
|
||||
boolean touchedAnyRevs = false;
|
||||
boolean hasComments = false;
|
||||
for (Map.Entry<RevId, RevisionNoteBuilder> e : builders.entrySet()) {
|
||||
updatedRevs.add(e.getKey());
|
||||
ObjectId id = ObjectId.fromString(e.getKey().get());
|
||||
for (Map.Entry<ObjectId, RevisionNoteBuilder> e : builders.entrySet()) {
|
||||
updatedCommits.add(e.getKey());
|
||||
ObjectId id = e.getKey();
|
||||
byte[] data = e.getValue().build(noteUtil.getChangeNoteJson());
|
||||
if (!Arrays.equals(data, e.getValue().baseRaw)) {
|
||||
touchedAnyRevs = true;
|
||||
@@ -174,7 +173,7 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate {
|
||||
|
||||
// If we touched every revision and there are no comments left, tell the
|
||||
// caller to delete the entire ref.
|
||||
boolean touchedAllRevs = updatedRevs.equals(rnm.revisionNotes.keySet());
|
||||
boolean touchedAllRevs = updatedCommits.equals(rnm.revisionNotes.keySet());
|
||||
if (touchedAllRevs && !hasComments) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -46,7 +46,6 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.client.RobotComment;
|
||||
import com.google.gerrit.server.ReviewerByEmailSet;
|
||||
import com.google.gerrit.server.ReviewerSet;
|
||||
@@ -403,7 +402,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
}
|
||||
|
||||
/** @return inline comments on each revision. */
|
||||
public ImmutableListMultimap<RevId, Comment> getComments() {
|
||||
public ImmutableListMultimap<ObjectId, Comment> getComments() {
|
||||
return state.publishedComments();
|
||||
}
|
||||
|
||||
@@ -422,11 +421,11 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
return state.updateCount();
|
||||
}
|
||||
|
||||
public ImmutableListMultimap<RevId, Comment> getDraftComments(Account.Id author) {
|
||||
public ImmutableListMultimap<ObjectId, Comment> getDraftComments(Account.Id author) {
|
||||
return getDraftComments(author, null);
|
||||
}
|
||||
|
||||
public ImmutableListMultimap<RevId, Comment> getDraftComments(
|
||||
public ImmutableListMultimap<ObjectId, Comment> getDraftComments(
|
||||
Account.Id author, @Nullable Ref ref) {
|
||||
loadDraftComments(author, ref);
|
||||
// Filter out any zombie draft comments. These are drafts that are also in
|
||||
@@ -437,7 +436,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
draftCommentNotes.getComments(), e -> !getCommentKeys().contains(e.getValue().key)));
|
||||
}
|
||||
|
||||
public ImmutableListMultimap<RevId, RobotComment> getRobotComments() {
|
||||
public ImmutableListMultimap<ObjectId, RobotComment> getRobotComments() {
|
||||
loadRobotComments();
|
||||
return robotCommentNotes.getComments();
|
||||
}
|
||||
|
@@ -134,7 +134,7 @@ class ChangeNotesParser {
|
||||
private final List<Account.Id> allPastReviewers;
|
||||
private final List<ReviewerStatusUpdate> reviewerUpdates;
|
||||
private final List<SubmitRecord> submitRecords;
|
||||
private final ListMultimap<RevId, Comment> comments;
|
||||
private final ListMultimap<ObjectId, Comment> comments;
|
||||
private final Map<PatchSet.Id, PatchSet> patchSets;
|
||||
private final Set<PatchSet.Id> deletedPatchSets;
|
||||
private final Map<PatchSet.Id, PatchSetState> patchSetStates;
|
||||
@@ -721,16 +721,16 @@ class ChangeNotesParser {
|
||||
reader,
|
||||
NoteMap.read(reader, tipCommit),
|
||||
PatchLineComment.Status.PUBLISHED);
|
||||
Map<RevId, ChangeRevisionNote> rns = revisionNoteMap.revisionNotes;
|
||||
Map<ObjectId, ChangeRevisionNote> rns = revisionNoteMap.revisionNotes;
|
||||
|
||||
for (Map.Entry<RevId, ChangeRevisionNote> e : rns.entrySet()) {
|
||||
for (Map.Entry<ObjectId, ChangeRevisionNote> e : rns.entrySet()) {
|
||||
for (Comment c : e.getValue().getEntities()) {
|
||||
comments.put(e.getKey(), c);
|
||||
}
|
||||
}
|
||||
|
||||
for (PatchSet ps : patchSets.values()) {
|
||||
ChangeRevisionNote rn = rns.get(ps.getRevision());
|
||||
ChangeRevisionNote rn = rns.get(ObjectId.fromString(ps.getRevision().get()));
|
||||
if (rn != null && rn.getPushCert() != null) {
|
||||
ps.setPushCertificate(rn.getPushCert());
|
||||
}
|
||||
|
@@ -46,7 +46,6 @@ import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.converter.ChangeMessageProtoConverter;
|
||||
import com.google.gerrit.reviewdb.converter.PatchSetApprovalProtoConverter;
|
||||
import com.google.gerrit.reviewdb.converter.PatchSetProtoConverter;
|
||||
@@ -117,7 +116,7 @@ public abstract class ChangeNotesState {
|
||||
List<ReviewerStatusUpdate> reviewerUpdates,
|
||||
List<SubmitRecord> submitRecords,
|
||||
List<ChangeMessage> changeMessages,
|
||||
ListMultimap<RevId, Comment> publishedComments,
|
||||
ListMultimap<ObjectId, Comment> publishedComments,
|
||||
boolean isPrivate,
|
||||
boolean workInProgress,
|
||||
boolean reviewStarted,
|
||||
@@ -297,7 +296,7 @@ public abstract class ChangeNotesState {
|
||||
|
||||
abstract ImmutableList<ChangeMessage> changeMessages();
|
||||
|
||||
abstract ImmutableListMultimap<RevId, Comment> publishedComments();
|
||||
abstract ImmutableListMultimap<ObjectId, Comment> publishedComments();
|
||||
|
||||
abstract int updateCount();
|
||||
|
||||
@@ -401,7 +400,7 @@ public abstract class ChangeNotesState {
|
||||
|
||||
abstract Builder changeMessages(List<ChangeMessage> changeMessages);
|
||||
|
||||
abstract Builder publishedComments(ListMultimap<RevId, Comment> publishedComments);
|
||||
abstract Builder publishedComments(ListMultimap<ObjectId, Comment> publishedComments);
|
||||
|
||||
abstract Builder updateCount(int updateCount);
|
||||
|
||||
@@ -581,7 +580,7 @@ public abstract class ChangeNotesState {
|
||||
.publishedComments(
|
||||
proto.getPublishedCommentList().stream()
|
||||
.map(r -> GSON.fromJson(r, Comment.class))
|
||||
.collect(toImmutableListMultimap(c -> new RevId(c.revId), c -> c)))
|
||||
.collect(toImmutableListMultimap(Comment::getCommitId, c -> c)))
|
||||
.updateCount(proto.getUpdateCount());
|
||||
return b.build();
|
||||
}
|
||||
|
@@ -57,7 +57,6 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.client.RobotComment;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
@@ -432,18 +431,18 @@ public class ChangeUpdate extends AbstractChangeUpdate {
|
||||
RevisionNoteBuilder.Cache cache = new RevisionNoteBuilder.Cache(rnm);
|
||||
for (Comment c : comments) {
|
||||
c.tag = tag;
|
||||
cache.get(new RevId(c.revId)).putComment(c);
|
||||
cache.get(c.getCommitId()).putComment(c);
|
||||
}
|
||||
if (pushCert != null) {
|
||||
checkState(commit != null);
|
||||
cache.get(new RevId(commit)).setPushCertificate(pushCert);
|
||||
cache.get(ObjectId.fromString(commit)).setPushCertificate(pushCert);
|
||||
}
|
||||
Map<RevId, RevisionNoteBuilder> builders = cache.getBuilders();
|
||||
Map<ObjectId, RevisionNoteBuilder> builders = cache.getBuilders();
|
||||
checkComments(rnm.revisionNotes, builders);
|
||||
|
||||
for (Map.Entry<RevId, RevisionNoteBuilder> e : builders.entrySet()) {
|
||||
for (Map.Entry<ObjectId, RevisionNoteBuilder> e : builders.entrySet()) {
|
||||
ObjectId data = inserter.insert(OBJ_BLOB, e.getValue().build(noteUtil.getChangeNoteJson()));
|
||||
rnm.noteMap.set(ObjectId.fromString(e.getKey().get()), data);
|
||||
rnm.noteMap.set(e.getKey(), data);
|
||||
}
|
||||
|
||||
return rnm.noteMap.writeTree(inserter);
|
||||
@@ -476,7 +475,8 @@ public class ChangeUpdate extends AbstractChangeUpdate {
|
||||
}
|
||||
|
||||
private void checkComments(
|
||||
Map<RevId, ChangeRevisionNote> existingNotes, Map<RevId, RevisionNoteBuilder> toUpdate) {
|
||||
Map<ObjectId, ChangeRevisionNote> existingNotes,
|
||||
Map<ObjectId, RevisionNoteBuilder> toUpdate) {
|
||||
// Prohibit various kinds of illegal operations on comments.
|
||||
Set<Comment.Key> existing = new HashSet<>();
|
||||
for (ChangeRevisionNote rn : existingNotes.values()) {
|
||||
@@ -498,7 +498,7 @@ public class ChangeUpdate extends AbstractChangeUpdate {
|
||||
// separate commit. But note that we don't care much about the commit
|
||||
// graph of the draft ref, particularly because the ref is completely
|
||||
// deleted when all drafts are gone.
|
||||
draftUpdate.deleteComment(c.revId, c.key);
|
||||
draftUpdate.deleteComment(c.getCommitId(), c.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -224,16 +223,16 @@ public class DeleteCommentRewriter implements NoteDbRewriter {
|
||||
RevisionNoteBuilder.Cache cache = new RevisionNoteBuilder.Cache(revNotesMap);
|
||||
|
||||
for (Comment c : putInComments) {
|
||||
cache.get(new RevId(c.revId)).putComment(c);
|
||||
cache.get(c.getCommitId()).putComment(c);
|
||||
}
|
||||
|
||||
for (Comment c : deletedComments) {
|
||||
cache.get(new RevId(c.revId)).deleteComment(c.key);
|
||||
cache.get(c.getCommitId()).deleteComment(c.key);
|
||||
}
|
||||
|
||||
Map<RevId, RevisionNoteBuilder> builders = cache.getBuilders();
|
||||
for (Map.Entry<RevId, RevisionNoteBuilder> entry : builders.entrySet()) {
|
||||
ObjectId objectId = ObjectId.fromString(entry.getKey().get());
|
||||
Map<ObjectId, RevisionNoteBuilder> builders = cache.getBuilders();
|
||||
for (Map.Entry<ObjectId, RevisionNoteBuilder> entry : builders.entrySet()) {
|
||||
ObjectId objectId = entry.getKey();
|
||||
byte[] data = entry.getValue().build(noteUtil.getChangeNoteJson());
|
||||
if (data.length == 0) {
|
||||
revNotesMap.noteMap.remove(objectId);
|
||||
|
@@ -29,7 +29,6 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import java.io.IOException;
|
||||
@@ -52,7 +51,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
||||
private final Account.Id author;
|
||||
private final Ref ref;
|
||||
|
||||
private ImmutableListMultimap<RevId, Comment> comments;
|
||||
private ImmutableListMultimap<ObjectId, Comment> comments;
|
||||
private RevisionNoteMap<ChangeRevisionNote> revisionNoteMap;
|
||||
|
||||
@AssistedInject
|
||||
@@ -82,7 +81,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
||||
return author;
|
||||
}
|
||||
|
||||
public ImmutableListMultimap<RevId, Comment> getComments() {
|
||||
public ImmutableListMultimap<ObjectId, Comment> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@@ -128,10 +127,10 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
||||
reader,
|
||||
NoteMap.read(reader, tipCommit),
|
||||
PatchLineComment.Status.DRAFT);
|
||||
ListMultimap<RevId, Comment> cs = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
ListMultimap<ObjectId, Comment> cs = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
for (ChangeRevisionNote rn : revisionNoteMap.revisionNotes.values()) {
|
||||
for (Comment c : rn.getEntities()) {
|
||||
cs.put(new RevId(c.revId), c);
|
||||
cs.put(c.getCommitId(), c);
|
||||
}
|
||||
}
|
||||
comments = ImmutableListMultimap.copyOf(cs);
|
||||
|
@@ -190,7 +190,7 @@ public class LegacyChangeNoteRead {
|
||||
c.lineNbr = range.getEndLine();
|
||||
c.parentUuid = parentUUID;
|
||||
c.tag = tag;
|
||||
c.setRevId(commitId);
|
||||
c.setCommitId(commitId);
|
||||
if (raId != null) {
|
||||
c.setRealAuthor(raId);
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ import java.io.PrintWriter;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.util.QuotedString;
|
||||
|
||||
@@ -91,8 +92,9 @@ public class LegacyChangeNoteWrite {
|
||||
|
||||
OutputStreamWriter streamWriter = new OutputStreamWriter(out, UTF_8);
|
||||
try (PrintWriter writer = new PrintWriter(streamWriter)) {
|
||||
String revId = comments.values().iterator().next().revId;
|
||||
appendHeaderField(writer, ChangeNoteUtil.REVISION, revId);
|
||||
ObjectId commitId = comments.values().iterator().next().getCommitId();
|
||||
String commitName = commitId.name();
|
||||
appendHeaderField(writer, ChangeNoteUtil.REVISION, commitName);
|
||||
|
||||
for (int psId : psIds) {
|
||||
List<Comment> psComments = COMMENT_ORDER.sortedCopy(comments.get(psId));
|
||||
@@ -111,11 +113,11 @@ public class LegacyChangeNoteWrite {
|
||||
|
||||
for (Comment c : psComments) {
|
||||
checkArgument(
|
||||
revId.equals(c.revId),
|
||||
commitId.equals(c.getCommitId()),
|
||||
"All comments being added must have all the same RevId. The "
|
||||
+ "comment below does not have the same RevId as the others "
|
||||
+ "(%s).\n%s",
|
||||
revId,
|
||||
commitId,
|
||||
c);
|
||||
checkArgument(
|
||||
side == c.side,
|
||||
|
@@ -22,7 +22,6 @@ import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -33,27 +32,29 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.eclipse.jgit.lib.AnyObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
class RevisionNoteBuilder {
|
||||
static class Cache {
|
||||
private final RevisionNoteMap<? extends RevisionNote<? extends Comment>> revisionNoteMap;
|
||||
private final Map<RevId, RevisionNoteBuilder> builders;
|
||||
private final Map<ObjectId, RevisionNoteBuilder> builders;
|
||||
|
||||
Cache(RevisionNoteMap<? extends RevisionNote<? extends Comment>> revisionNoteMap) {
|
||||
this.revisionNoteMap = revisionNoteMap;
|
||||
this.builders = new HashMap<>();
|
||||
}
|
||||
|
||||
RevisionNoteBuilder get(RevId revId) {
|
||||
RevisionNoteBuilder b = builders.get(revId);
|
||||
RevisionNoteBuilder get(AnyObjectId commitId) {
|
||||
RevisionNoteBuilder b = builders.get(commitId);
|
||||
if (b == null) {
|
||||
b = new RevisionNoteBuilder(revisionNoteMap.revisionNotes.get(revId));
|
||||
builders.put(revId, b);
|
||||
b = new RevisionNoteBuilder(revisionNoteMap.revisionNotes.get(commitId));
|
||||
builders.put(commitId.copy(), b);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
Map<RevId, RevisionNoteBuilder> getBuilders() {
|
||||
Map<ObjectId, RevisionNoteBuilder> getBuilders() {
|
||||
return Collections.unmodifiableMap(builders);
|
||||
}
|
||||
}
|
||||
|
@@ -18,18 +18,18 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectReader;
|
||||
import org.eclipse.jgit.notes.Note;
|
||||
import org.eclipse.jgit.notes.NoteMap;
|
||||
|
||||
class RevisionNoteMap<T extends RevisionNote<? extends Comment>> {
|
||||
final NoteMap noteMap;
|
||||
final ImmutableMap<RevId, T> revisionNotes;
|
||||
final ImmutableMap<ObjectId, T> revisionNotes;
|
||||
|
||||
static RevisionNoteMap<ChangeRevisionNote> parse(
|
||||
ChangeNoteJson noteJson,
|
||||
@@ -39,13 +39,13 @@ class RevisionNoteMap<T extends RevisionNote<? extends Comment>> {
|
||||
NoteMap noteMap,
|
||||
PatchLineComment.Status status)
|
||||
throws ConfigInvalidException, IOException {
|
||||
Map<RevId, ChangeRevisionNote> result = new HashMap<>();
|
||||
Map<ObjectId, ChangeRevisionNote> result = new HashMap<>();
|
||||
for (Note note : noteMap) {
|
||||
ChangeRevisionNote rn =
|
||||
new ChangeRevisionNote(
|
||||
noteJson, legacyChangeNoteRead, changeId, reader, note.getData(), status);
|
||||
rn.parse();
|
||||
result.put(new RevId(note.name()), rn);
|
||||
result.put(note.copy(), rn);
|
||||
}
|
||||
return new RevisionNoteMap<>(noteMap, ImmutableMap.copyOf(result));
|
||||
}
|
||||
@@ -53,12 +53,12 @@ class RevisionNoteMap<T extends RevisionNote<? extends Comment>> {
|
||||
static RevisionNoteMap<RobotCommentsRevisionNote> parseRobotComments(
|
||||
ChangeNoteJson changeNoteJson, ObjectReader reader, NoteMap noteMap)
|
||||
throws ConfigInvalidException, IOException {
|
||||
Map<RevId, RobotCommentsRevisionNote> result = new HashMap<>();
|
||||
Map<ObjectId, RobotCommentsRevisionNote> result = new HashMap<>();
|
||||
for (Note note : noteMap) {
|
||||
RobotCommentsRevisionNote rn =
|
||||
new RobotCommentsRevisionNote(changeNoteJson, reader, note.getData());
|
||||
rn.parse();
|
||||
result.put(new RevId(note.name()), rn);
|
||||
result.put(note.copy(), rn);
|
||||
}
|
||||
return new RevisionNoteMap<>(noteMap, ImmutableMap.copyOf(result));
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class RevisionNoteMap<T extends RevisionNote<? extends Comment>> {
|
||||
return new RevisionNoteMap<>(NoteMap.newEmptyMap(), ImmutableMap.of());
|
||||
}
|
||||
|
||||
private RevisionNoteMap(NoteMap noteMap, ImmutableMap<RevId, T> revisionNotes) {
|
||||
private RevisionNoteMap(NoteMap noteMap, ImmutableMap<ObjectId, T> revisionNotes) {
|
||||
this.noteMap = noteMap;
|
||||
this.revisionNotes = revisionNotes;
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.client.RobotComment;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -42,7 +41,7 @@ public class RobotCommentNotes extends AbstractChangeNotes<RobotCommentNotes> {
|
||||
|
||||
private final Change change;
|
||||
|
||||
private ImmutableListMultimap<RevId, RobotComment> comments;
|
||||
private ImmutableListMultimap<ObjectId, RobotComment> comments;
|
||||
private RevisionNoteMap<RobotCommentsRevisionNote> revisionNoteMap;
|
||||
private ObjectId metaId;
|
||||
|
||||
@@ -56,7 +55,7 @@ public class RobotCommentNotes extends AbstractChangeNotes<RobotCommentNotes> {
|
||||
return revisionNoteMap;
|
||||
}
|
||||
|
||||
public ImmutableListMultimap<RevId, RobotComment> getComments() {
|
||||
public ImmutableListMultimap<ObjectId, RobotComment> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@@ -95,10 +94,10 @@ public class RobotCommentNotes extends AbstractChangeNotes<RobotCommentNotes> {
|
||||
revisionNoteMap =
|
||||
RevisionNoteMap.parseRobotComments(
|
||||
args.changeNoteJson, reader, NoteMap.read(reader, tipCommit));
|
||||
ListMultimap<RevId, RobotComment> cs = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
ListMultimap<ObjectId, RobotComment> cs = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
for (RobotCommentsRevisionNote rn : revisionNoteMap.revisionNotes.values()) {
|
||||
for (RobotComment c : rn.getEntities()) {
|
||||
cs.put(new RevId(c.revId), c);
|
||||
cs.put(c.getCommitId(), c);
|
||||
}
|
||||
}
|
||||
comments = ImmutableListMultimap.copyOf(cs);
|
||||
|
@@ -23,7 +23,6 @@ import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.client.RobotComment;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -103,19 +102,19 @@ public class RobotCommentUpdate extends AbstractChangeUpdate {
|
||||
RevWalk rw, ObjectInserter ins, ObjectId curr, CommitBuilder cb)
|
||||
throws ConfigInvalidException, IOException {
|
||||
RevisionNoteMap<RobotCommentsRevisionNote> rnm = getRevisionNoteMap(rw, curr);
|
||||
Set<RevId> updatedRevs = Sets.newHashSetWithExpectedSize(rnm.revisionNotes.size());
|
||||
Set<ObjectId> updatedRevs = Sets.newHashSetWithExpectedSize(rnm.revisionNotes.size());
|
||||
RevisionNoteBuilder.Cache cache = new RevisionNoteBuilder.Cache(rnm);
|
||||
|
||||
for (RobotComment c : put) {
|
||||
cache.get(new RevId(c.revId)).putComment(c);
|
||||
cache.get(c.getCommitId()).putComment(c);
|
||||
}
|
||||
|
||||
Map<RevId, RevisionNoteBuilder> builders = cache.getBuilders();
|
||||
Map<ObjectId, RevisionNoteBuilder> builders = cache.getBuilders();
|
||||
boolean touchedAnyRevs = false;
|
||||
boolean hasComments = false;
|
||||
for (Map.Entry<RevId, RevisionNoteBuilder> e : builders.entrySet()) {
|
||||
updatedRevs.add(e.getKey());
|
||||
ObjectId id = ObjectId.fromString(e.getKey().get());
|
||||
for (Map.Entry<ObjectId, RevisionNoteBuilder> e : builders.entrySet()) {
|
||||
ObjectId id = e.getKey();
|
||||
updatedRevs.add(id);
|
||||
byte[] data = e.getValue().build(noteUtil);
|
||||
if (!Arrays.equals(data, e.getValue().baseRaw)) {
|
||||
touchedAnyRevs = true;
|
||||
|
@@ -15,7 +15,7 @@
|
||||
package com.google.gerrit.server.restapi.account;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentRevId;
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentCommitId;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Strings;
|
||||
@@ -181,7 +181,7 @@ public class DeleteDraftComments
|
||||
for (Comment c : commentsUtil.draftByChangeAuthor(ctx.getNotes(), accountId)) {
|
||||
dirty = true;
|
||||
PatchSet.Id psId = PatchSet.id(ctx.getChange().getId(), c.key.patchSetId);
|
||||
setCommentRevId(c, patchListCache, ctx.getChange(), psUtil.get(ctx.getNotes(), psId));
|
||||
setCommentCommitId(c, patchListCache, ctx.getChange(), psUtil.get(ctx.getNotes(), psId));
|
||||
commentsUtil.deleteComments(ctx.getUpdate(psId), Collections.singleton(c));
|
||||
comments.add(commentFormatter.format(c));
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentRevId;
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentCommitId;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.api.changes.DraftInput;
|
||||
@@ -119,7 +119,7 @@ public class CreateDraftComment
|
||||
comment.setLineNbrAndRange(in.line, in.range);
|
||||
comment.tag = in.tag;
|
||||
|
||||
setCommentRevId(comment, patchListCache, ctx.getChange(), ps);
|
||||
setCommentCommitId(comment, patchListCache, ctx.getChange(), ps);
|
||||
|
||||
commentsUtil.putComments(ctx.getUpdate(psId), Status.DRAFT, Collections.singleton(comment));
|
||||
return true;
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentRevId;
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentCommitId;
|
||||
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
@@ -94,7 +94,7 @@ public class DeleteDraftComment
|
||||
throw new ResourceNotFoundException("patch set not found: " + psId);
|
||||
}
|
||||
Comment c = maybeComment.get();
|
||||
setCommentRevId(c, patchListCache, ctx.getChange(), ps);
|
||||
setCommentCommitId(c, patchListCache, ctx.getChange(), ps);
|
||||
commentsUtil.deleteComments(ctx.getUpdate(psId), Collections.singleton(c));
|
||||
return true;
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentRevId;
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentCommitId;
|
||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||
import static com.google.gerrit.server.permissions.LabelPermission.ForUser.ON_BEHALF_OF;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
@@ -921,7 +921,7 @@ public class PostReview
|
||||
e.message = c.message;
|
||||
}
|
||||
|
||||
setCommentRevId(e, patchListCache, ctx.getChange(), ps);
|
||||
setCommentCommitId(e, patchListCache, ctx.getChange(), ps);
|
||||
e.setLineNbrAndRange(c.line, c.range);
|
||||
e.tag = in.tag;
|
||||
|
||||
@@ -996,7 +996,7 @@ public class PostReview
|
||||
robotComment.properties = robotCommentInput.properties;
|
||||
robotComment.setLineNbrAndRange(robotCommentInput.line, robotCommentInput.range);
|
||||
robotComment.tag = in.tag;
|
||||
setCommentRevId(robotComment, patchListCache, ctx.getChange(), ps);
|
||||
setCommentCommitId(robotComment, patchListCache, ctx.getChange(), ps);
|
||||
robotComment.fixSuggestions = createFixSuggestionsFromInput(robotCommentInput.fixSuggestions);
|
||||
return robotComment;
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentRevId;
|
||||
import static com.google.gerrit.server.CommentsUtil.setCommentCommitId;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.DraftInput;
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
@@ -138,7 +138,7 @@ public class PutDraftComment
|
||||
commentsUtil.deleteComments(update, Collections.singleton(origComment));
|
||||
comment.key.filename = in.path;
|
||||
}
|
||||
setCommentRevId(comment, patchListCache, ctx.getChange(), ps);
|
||||
setCommentCommitId(comment, patchListCache, ctx.getChange(), ps);
|
||||
commentsUtil.putComments(
|
||||
update, Status.DRAFT, Collections.singleton(update(comment, in, ctx.getWhen())));
|
||||
return true;
|
||||
|
@@ -66,6 +66,7 @@ import java.util.TimeZone;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.junit.After;
|
||||
@@ -247,7 +248,7 @@ public abstract class AbstractChangeNotesTest extends GerritBaseTests {
|
||||
Timestamp t,
|
||||
String message,
|
||||
short side,
|
||||
String commitSHA1,
|
||||
ObjectId commitId,
|
||||
boolean unresolved) {
|
||||
Comment c =
|
||||
new Comment(
|
||||
@@ -260,7 +261,7 @@ public abstract class AbstractChangeNotesTest extends GerritBaseTests {
|
||||
unresolved);
|
||||
c.lineNbr = line;
|
||||
c.parentUuid = parentUUID;
|
||||
c.revId = commitSHA1;
|
||||
c.setCommitId(commitId);
|
||||
c.setRange(range);
|
||||
return c;
|
||||
}
|
||||
|
@@ -663,7 +663,7 @@ public class ChangeNotesStateTest extends GerritBaseTests {
|
||||
"message 1",
|
||||
"serverId",
|
||||
false);
|
||||
c1.setRevId(ObjectId.fromString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
|
||||
c1.setCommitId(ObjectId.fromString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
|
||||
String c1Json = Serializer.GSON.toJson(c1);
|
||||
|
||||
Comment c2 =
|
||||
@@ -675,13 +675,12 @@ public class ChangeNotesStateTest extends GerritBaseTests {
|
||||
"message 2",
|
||||
"serverId",
|
||||
true);
|
||||
c2.setRevId(ObjectId.fromString("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"));
|
||||
c2.setCommitId(ObjectId.fromString("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"));
|
||||
String c2Json = Serializer.GSON.toJson(c2);
|
||||
|
||||
assertRoundTrip(
|
||||
newBuilder()
|
||||
.publishedComments(
|
||||
ImmutableListMultimap.of(new RevId(c2.revId), c2, new RevId(c1.revId), c1))
|
||||
.publishedComments(ImmutableListMultimap.of(c2.getCommitId(), c2, c1.getCommitId(), c1))
|
||||
.build(),
|
||||
ChangeNotesStateProto.newBuilder()
|
||||
.setMetaId(SHA_BYTES)
|
||||
@@ -733,7 +732,7 @@ public class ChangeNotesStateTest extends GerritBaseTests {
|
||||
.put("changeMessages", new TypeLiteral<ImmutableList<ChangeMessage>>() {}.getType())
|
||||
.put(
|
||||
"publishedComments",
|
||||
new TypeLiteral<ImmutableListMultimap<RevId, Comment>>() {}.getType())
|
||||
new TypeLiteral<ImmutableListMultimap<ObjectId, Comment>>() {}.getType())
|
||||
.put("updateCount", int.class)
|
||||
.build());
|
||||
}
|
||||
|
@@ -47,7 +47,6 @@ import com.google.gerrit.reviewdb.client.CommentRange;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment.Status;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.ReviewerSet;
|
||||
@@ -132,14 +131,14 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
TimeUtil.nowTs(),
|
||||
"Comment",
|
||||
(short) 1,
|
||||
commit.name(),
|
||||
commit,
|
||||
false));
|
||||
update.setTag(tag);
|
||||
update.commit();
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
|
||||
ImmutableListMultimap<RevId, Comment> comments = notes.getComments();
|
||||
ImmutableListMultimap<ObjectId, Comment> comments = notes.getComments();
|
||||
assertThat(comments).hasSize(1);
|
||||
assertThat(comments.entries().asList().get(0).getValue().tag).isEqualTo(tag);
|
||||
}
|
||||
@@ -194,7 +193,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
TimeUtil.nowTs(),
|
||||
"Comment",
|
||||
(short) 1,
|
||||
commit.name(),
|
||||
commit,
|
||||
false));
|
||||
update.setChangeMessage("coverage verification");
|
||||
update.setTag(coverageTag);
|
||||
@@ -213,7 +212,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(approval.getTag()).isEqualTo(integrationTag);
|
||||
assertThat(approval.getValue()).isEqualTo(-1);
|
||||
|
||||
ImmutableListMultimap<RevId, Comment> comments = notes.getComments();
|
||||
ImmutableListMultimap<ObjectId, Comment> comments = notes.getComments();
|
||||
assertThat(comments).hasSize(1);
|
||||
assertThat(comments.entries().asList().get(0).getValue().tag).isEqualTo(coverageTag);
|
||||
|
||||
@@ -1066,7 +1065,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
TimeUtil.nowTs(),
|
||||
"Comment",
|
||||
(short) 1,
|
||||
commit.name(),
|
||||
commit,
|
||||
false));
|
||||
update.commit();
|
||||
|
||||
@@ -1166,7 +1165,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
ts,
|
||||
"Comment",
|
||||
(short) 1,
|
||||
commit.name(),
|
||||
commit,
|
||||
false));
|
||||
update.commit();
|
||||
|
||||
@@ -1236,7 +1235,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
time1,
|
||||
message1,
|
||||
(short) 0,
|
||||
"abcd1234abcd1234abcd1234abcd1234abcd1234",
|
||||
ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"),
|
||||
false);
|
||||
update1.setPatchSetId(psId);
|
||||
update1.putComment(Status.PUBLISHED, comment1);
|
||||
@@ -1446,7 +1445,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
|
||||
Comment comment =
|
||||
newComment(
|
||||
@@ -1460,14 +1459,14 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
TimeUtil.nowTs(),
|
||||
"message",
|
||||
(short) 1,
|
||||
revId.get(),
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
update.commit();
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(revId, comment));
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(commitId, comment));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1475,7 +1474,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
CommentRange range = new CommentRange(1, 0, 2, 0);
|
||||
|
||||
Comment comment =
|
||||
@@ -1490,14 +1489,14 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
TimeUtil.nowTs(),
|
||||
"message",
|
||||
(short) 1,
|
||||
revId.get(),
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
update.commit();
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(revId, comment));
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(commitId, comment));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1505,7 +1504,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
CommentRange range = new CommentRange(0, 0, 0, 0);
|
||||
|
||||
Comment comment =
|
||||
@@ -1520,14 +1519,14 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
TimeUtil.nowTs(),
|
||||
"message",
|
||||
(short) 1,
|
||||
revId.get(),
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
update.commit();
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(revId, comment));
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(commitId, comment));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1535,7 +1534,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
CommentRange range = new CommentRange(1, 2, 3, 4);
|
||||
|
||||
Comment comment =
|
||||
@@ -1550,14 +1549,14 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
TimeUtil.nowTs(),
|
||||
"message",
|
||||
(short) 1,
|
||||
revId.get(),
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
update.commit();
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(revId, comment));
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(commitId, comment));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1575,7 +1574,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
CommentRange range1 = new CommentRange(1, 1, 2, 1);
|
||||
CommentRange range2 = new CommentRange(2, 1, 3, 1);
|
||||
Timestamp time = TimeUtil.nowTs();
|
||||
RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
|
||||
Comment comment1 =
|
||||
newComment(
|
||||
@@ -1589,7 +1588,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
time,
|
||||
message1,
|
||||
(short) 0,
|
||||
revId.get(),
|
||||
commitId,
|
||||
false);
|
||||
Comment comment2 =
|
||||
newComment(
|
||||
@@ -1603,7 +1602,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
time,
|
||||
message2,
|
||||
(short) 0,
|
||||
revId.get(),
|
||||
commitId,
|
||||
false);
|
||||
Comment comment3 =
|
||||
newComment(
|
||||
@@ -1617,7 +1616,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
time,
|
||||
message3,
|
||||
(short) 0,
|
||||
revId.get(),
|
||||
commitId,
|
||||
false);
|
||||
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
@@ -1631,9 +1630,9 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(notes.getComments())
|
||||
.isEqualTo(
|
||||
ImmutableListMultimap.of(
|
||||
revId, comment1,
|
||||
revId, comment2,
|
||||
revId, comment3));
|
||||
commitId, comment1,
|
||||
commitId, comment2,
|
||||
commitId, comment3));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1646,7 +1645,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
Timestamp time = TimeUtil.nowTs();
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
|
||||
Comment comment =
|
||||
newComment(
|
||||
@@ -1660,7 +1659,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
time,
|
||||
message,
|
||||
(short) 1,
|
||||
revId.get(),
|
||||
commitId,
|
||||
false);
|
||||
comment.setRealAuthor(changeOwner.getAccountId());
|
||||
update.setPatchSetId(psId);
|
||||
@@ -1669,7 +1668,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(revId, comment));
|
||||
assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(commitId, comment));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1699,7 +1698,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
time,
|
||||
"comment",
|
||||
(short) 1,
|
||||
"abcd1234abcd1234abcd1234abcd1234abcd1234",
|
||||
ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"),
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
@@ -1708,7 +1707,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
ChangeNotes notes = newNotes(c);
|
||||
|
||||
assertThat(notes.getComments())
|
||||
.isEqualTo(ImmutableListMultimap.of(new RevId(comment.revId), comment));
|
||||
.isEqualTo(ImmutableListMultimap.of(comment.getCommitId(), comment));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1717,8 +1716,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
String uuid1 = "uuid1";
|
||||
String uuid2 = "uuid2";
|
||||
String rev1 = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
String rev2 = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId2 = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
String messageForBase = "comment for base";
|
||||
String messageForPS = "comment for ps";
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
@@ -1737,7 +1736,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
messageForBase,
|
||||
(short) 0,
|
||||
rev1,
|
||||
commitId1,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, commentForBase);
|
||||
@@ -1756,7 +1755,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
messageForPS,
|
||||
(short) 1,
|
||||
rev2,
|
||||
commitId2,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, commentForPS);
|
||||
@@ -1765,8 +1764,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(newNotes(c).getComments())
|
||||
.containsExactlyEntriesIn(
|
||||
ImmutableListMultimap.of(
|
||||
new RevId(rev1), commentForBase,
|
||||
new RevId(rev2), commentForPS));
|
||||
commitId1, commentForBase,
|
||||
commitId2, commentForPS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1774,7 +1773,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
String uuid1 = "uuid1";
|
||||
String uuid2 = "uuid2";
|
||||
String rev = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
String filename = "filename";
|
||||
@@ -1795,7 +1794,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
timeForComment1,
|
||||
"comment 1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment1);
|
||||
@@ -1814,7 +1813,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
timeForComment2,
|
||||
"comment 2",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment2);
|
||||
@@ -1823,8 +1822,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(newNotes(c).getComments())
|
||||
.containsExactlyEntriesIn(
|
||||
ImmutableListMultimap.of(
|
||||
new RevId(rev), comment1,
|
||||
new RevId(rev), comment2))
|
||||
commitId, comment1,
|
||||
commitId, comment2))
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
@@ -1832,7 +1831,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
public void patchLineCommentMultipleOnePatchsetMultipleFiles() throws Exception {
|
||||
Change c = newChange();
|
||||
String uuid = "uuid";
|
||||
String rev = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
String filename1 = "filename1";
|
||||
@@ -1853,7 +1852,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment 1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment1);
|
||||
@@ -1872,7 +1871,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment 2",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment2);
|
||||
@@ -1881,8 +1880,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(newNotes(c).getComments())
|
||||
.containsExactlyEntriesIn(
|
||||
ImmutableListMultimap.of(
|
||||
new RevId(rev), comment1,
|
||||
new RevId(rev), comment2))
|
||||
commitId, comment1,
|
||||
commitId, comment2))
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
@@ -1890,8 +1889,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
public void patchLineCommentMultiplePatchsets() throws Exception {
|
||||
Change c = newChange();
|
||||
String uuid = "uuid";
|
||||
String rev1 = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
String rev2 = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId2 = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id ps1 = c.currentPatchSetId();
|
||||
String filename = "filename1";
|
||||
@@ -1911,7 +1910,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev1,
|
||||
commitId1,
|
||||
false);
|
||||
update.setPatchSetId(ps1);
|
||||
update.putComment(Status.PUBLISHED, comment1);
|
||||
@@ -1934,7 +1933,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps2",
|
||||
side,
|
||||
rev2,
|
||||
commitId2,
|
||||
false);
|
||||
update.setPatchSetId(ps2);
|
||||
update.putComment(Status.PUBLISHED, comment2);
|
||||
@@ -1943,15 +1942,15 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(newNotes(c).getComments())
|
||||
.containsExactlyEntriesIn(
|
||||
ImmutableListMultimap.of(
|
||||
new RevId(rev1), comment1,
|
||||
new RevId(rev2), comment2));
|
||||
commitId1, comment1,
|
||||
commitId2, comment2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patchLineCommentSingleDraftToPublished() throws Exception {
|
||||
Change c = newChange();
|
||||
String uuid = "uuid";
|
||||
String rev = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId commitId = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id ps1 = c.currentPatchSetId();
|
||||
String filename = "filename1";
|
||||
@@ -1971,7 +1970,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(ps1);
|
||||
update.putComment(Status.DRAFT, comment1);
|
||||
@@ -1979,7 +1978,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
assertThat(notes.getDraftComments(otherUserId))
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(new RevId(rev), comment1));
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment1));
|
||||
assertThat(notes.getComments()).isEmpty();
|
||||
|
||||
update = newUpdate(c, otherUser);
|
||||
@@ -1990,7 +1989,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
notes = newNotes(c);
|
||||
assertThat(notes.getDraftComments(otherUserId)).isEmpty();
|
||||
assertThat(notes.getComments())
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(new RevId(rev), comment1));
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1998,7 +1997,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
String uuid1 = "uuid1";
|
||||
String uuid2 = "uuid2";
|
||||
String rev = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId commitId = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
CommentRange range1 = new CommentRange(1, 1, 2, 2);
|
||||
CommentRange range2 = new CommentRange(2, 2, 3, 3);
|
||||
String filename = "filename1";
|
||||
@@ -2021,7 +2020,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
Comment comment2 =
|
||||
newComment(
|
||||
@@ -2035,7 +2034,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"other on ps1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.putComment(Status.DRAFT, comment1);
|
||||
update.putComment(Status.DRAFT, comment2);
|
||||
@@ -2045,8 +2044,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(notes.getDraftComments(otherUserId))
|
||||
.containsExactlyEntriesIn(
|
||||
ImmutableListMultimap.of(
|
||||
new RevId(rev), comment1,
|
||||
new RevId(rev), comment2))
|
||||
commitId, comment1,
|
||||
commitId, comment2))
|
||||
.inOrder();
|
||||
assertThat(notes.getComments()).isEmpty();
|
||||
|
||||
@@ -2058,9 +2057,9 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
|
||||
notes = newNotes(c);
|
||||
assertThat(notes.getDraftComments(otherUserId))
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(new RevId(rev), comment2));
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment2));
|
||||
assertThat(notes.getComments())
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(new RevId(rev), comment1));
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2068,8 +2067,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
String uuid1 = "uuid1";
|
||||
String uuid2 = "uuid2";
|
||||
String rev1 = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
String rev2 = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId2 = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
CommentRange range1 = new CommentRange(1, 1, 2, 2);
|
||||
CommentRange range2 = new CommentRange(2, 2, 3, 3);
|
||||
String filename = "filename1";
|
||||
@@ -2091,7 +2090,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on base",
|
||||
(short) 0,
|
||||
rev1,
|
||||
commitId1,
|
||||
false);
|
||||
Comment psComment =
|
||||
newComment(
|
||||
@@ -2105,7 +2104,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps",
|
||||
(short) 1,
|
||||
rev2,
|
||||
commitId2,
|
||||
false);
|
||||
|
||||
update.putComment(Status.DRAFT, baseComment);
|
||||
@@ -2116,8 +2115,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(notes.getDraftComments(otherUserId))
|
||||
.containsExactlyEntriesIn(
|
||||
ImmutableListMultimap.of(
|
||||
new RevId(rev1), baseComment,
|
||||
new RevId(rev2), psComment));
|
||||
commitId1, baseComment,
|
||||
commitId2, psComment));
|
||||
assertThat(notes.getComments()).isEmpty();
|
||||
|
||||
// Publish both comments.
|
||||
@@ -2133,16 +2132,15 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(notes.getComments())
|
||||
.containsExactlyEntriesIn(
|
||||
ImmutableListMultimap.of(
|
||||
new RevId(rev1), baseComment,
|
||||
new RevId(rev2), psComment));
|
||||
commitId1, baseComment,
|
||||
commitId2, psComment));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patchLineCommentsDeleteAllDrafts() throws Exception {
|
||||
Change c = newChange();
|
||||
String uuid = "uuid";
|
||||
String rev = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
ObjectId objId = ObjectId.fromString(rev);
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
String filename = "filename";
|
||||
@@ -2162,7 +2160,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.DRAFT, comment);
|
||||
@@ -2170,7 +2168,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
assertThat(notes.getDraftComments(otherUserId)).hasSize(1);
|
||||
assertThat(notes.getDraftCommentNotes().getNoteMap().contains(objId)).isTrue();
|
||||
assertThat(notes.getDraftCommentNotes().getNoteMap().contains(commitId)).isTrue();
|
||||
|
||||
update = newUpdate(c, otherUser);
|
||||
update.setPatchSetId(psId);
|
||||
@@ -2186,10 +2184,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
public void patchLineCommentsDeleteAllDraftsForOneRevision() throws Exception {
|
||||
Change c = newChange();
|
||||
String uuid = "uuid";
|
||||
String rev1 = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
String rev2 = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId objId1 = ObjectId.fromString(rev1);
|
||||
ObjectId objId2 = ObjectId.fromString(rev2);
|
||||
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId2 = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id ps1 = c.currentPatchSetId();
|
||||
String filename = "filename1";
|
||||
@@ -2209,7 +2205,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev1,
|
||||
commitId1,
|
||||
false);
|
||||
update.setPatchSetId(ps1);
|
||||
update.putComment(Status.DRAFT, comment1);
|
||||
@@ -2232,7 +2228,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps2",
|
||||
side,
|
||||
rev2,
|
||||
commitId2,
|
||||
false);
|
||||
update.setPatchSetId(ps2);
|
||||
update.putComment(Status.DRAFT, comment2);
|
||||
@@ -2249,15 +2245,15 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
notes = newNotes(c);
|
||||
assertThat(notes.getDraftComments(otherUserId)).hasSize(1);
|
||||
NoteMap noteMap = notes.getDraftCommentNotes().getNoteMap();
|
||||
assertThat(noteMap.contains(objId1)).isTrue();
|
||||
assertThat(noteMap.contains(objId2)).isFalse();
|
||||
assertThat(noteMap.contains(commitId1)).isTrue();
|
||||
assertThat(noteMap.contains(commitId2)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addingPublishedCommentDoesNotCreateNoOpCommitOnEmptyDraftRef() throws Exception {
|
||||
Change c = newChange();
|
||||
String uuid = "uuid";
|
||||
String rev = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId commitId = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id ps1 = c.currentPatchSetId();
|
||||
String filename = "filename1";
|
||||
@@ -2277,7 +2273,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
update.commit();
|
||||
@@ -2290,7 +2286,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
@Test
|
||||
public void addingPublishedCommentDoesNotCreateNoOpCommitOnNonEmptyDraftRef() throws Exception {
|
||||
Change c = newChange();
|
||||
String rev = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId commitId = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id ps1 = c.currentPatchSetId();
|
||||
String filename = "filename1";
|
||||
@@ -2310,7 +2306,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"draft comment on ps1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.putComment(Status.DRAFT, draft);
|
||||
update.commit();
|
||||
@@ -2332,7 +2328,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.putComment(Status.PUBLISHED, pub);
|
||||
update.commit();
|
||||
@@ -2345,7 +2341,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
String uuid = "uuid";
|
||||
String rev = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
String messageForBase = "comment for base";
|
||||
Timestamp now = TimeUtil.nowTs();
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
@@ -2362,14 +2358,14 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
messageForBase,
|
||||
(short) 0,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
update.commit();
|
||||
|
||||
assertThat(newNotes(c).getComments())
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(new RevId(rev), comment));
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2377,7 +2373,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
Change c = newChange();
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
String uuid = "uuid";
|
||||
String rev = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
String messageForBase = "comment for base";
|
||||
Timestamp now = TimeUtil.nowTs();
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
@@ -2394,22 +2390,22 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
messageForBase,
|
||||
(short) 0,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update.setPatchSetId(psId);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
update.commit();
|
||||
|
||||
assertThat(newNotes(c).getComments())
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(new RevId(rev), comment));
|
||||
.containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void putCommentsForMultipleRevisions() throws Exception {
|
||||
Change c = newChange();
|
||||
String uuid = "uuid";
|
||||
String rev1 = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
String rev2 = "abcd4567abcd4567abcd4567abcd4567abcd4567";
|
||||
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId2 = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id ps1 = c.currentPatchSetId();
|
||||
String filename = "filename1";
|
||||
@@ -2433,7 +2429,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev1,
|
||||
commitId1,
|
||||
false);
|
||||
Comment comment2 =
|
||||
newComment(
|
||||
@@ -2447,7 +2443,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps2",
|
||||
side,
|
||||
rev2,
|
||||
commitId2,
|
||||
false);
|
||||
update.putComment(Status.DRAFT, comment1);
|
||||
update.putComment(Status.DRAFT, comment2);
|
||||
@@ -2471,7 +2467,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
@Test
|
||||
public void publishSubsetOfCommentsOnRevision() throws Exception {
|
||||
Change c = newChange();
|
||||
RevId rev1 = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id ps1 = c.currentPatchSetId();
|
||||
short side = (short) 1;
|
||||
@@ -2491,7 +2487,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment1",
|
||||
side,
|
||||
rev1.get(),
|
||||
commitId1,
|
||||
false);
|
||||
Comment comment2 =
|
||||
newComment(
|
||||
@@ -2505,14 +2501,15 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment2",
|
||||
side,
|
||||
rev1.get(),
|
||||
commitId1,
|
||||
false);
|
||||
update.putComment(Status.DRAFT, comment1);
|
||||
update.putComment(Status.DRAFT, comment2);
|
||||
update.commit();
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
assertThat(notes.getDraftComments(otherUserId).get(rev1)).containsExactly(comment1, comment2);
|
||||
assertThat(notes.getDraftComments(otherUserId).get(commitId1))
|
||||
.containsExactly(comment1, comment2);
|
||||
assertThat(notes.getComments()).isEmpty();
|
||||
|
||||
update = newUpdate(c, otherUser);
|
||||
@@ -2521,8 +2518,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
update.commit();
|
||||
|
||||
notes = newNotes(c);
|
||||
assertThat(notes.getDraftComments(otherUserId).get(rev1)).containsExactly(comment1);
|
||||
assertThat(notes.getComments().get(rev1)).containsExactly(comment2);
|
||||
assertThat(notes.getDraftComments(otherUserId).get(commitId1)).containsExactly(comment1);
|
||||
assertThat(notes.getComments().get(commitId1)).containsExactly(comment2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2544,7 +2541,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
@Test
|
||||
public void filterOutAndFixUpZombieDraftComments() throws Exception {
|
||||
Change c = newChange();
|
||||
RevId rev1 = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
PatchSet.Id ps1 = c.currentPatchSetId();
|
||||
short side = (short) 1;
|
||||
@@ -2563,7 +2560,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"comment on ps1",
|
||||
side,
|
||||
rev1.get(),
|
||||
commitId1,
|
||||
false);
|
||||
Comment comment2 =
|
||||
newComment(
|
||||
@@ -2577,7 +2574,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
now,
|
||||
"another comment",
|
||||
side,
|
||||
rev1.get(),
|
||||
commitId1,
|
||||
false);
|
||||
update.putComment(Status.DRAFT, comment1);
|
||||
update.putComment(Status.DRAFT, comment2);
|
||||
@@ -2605,12 +2602,12 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
|
||||
// Looking at drafts directly shows the zombie comment.
|
||||
DraftCommentNotes draftNotes = draftNotesFactory.create(c.getId(), otherUserId);
|
||||
assertThat(draftNotes.load().getComments().get(rev1)).containsExactly(comment1, comment2);
|
||||
assertThat(draftNotes.load().getComments().get(commitId1)).containsExactly(comment1, comment2);
|
||||
|
||||
// Zombie comment is filtered out of drafts via ChangeNotes.
|
||||
ChangeNotes notes = newNotes(c);
|
||||
assertThat(notes.getDraftComments(otherUserId).get(rev1)).containsExactly(comment1);
|
||||
assertThat(notes.getComments().get(rev1)).containsExactly(comment2);
|
||||
assertThat(notes.getDraftComments(otherUserId).get(commitId1)).containsExactly(comment1);
|
||||
assertThat(notes.getComments().get(commitId1)).containsExactly(comment2);
|
||||
|
||||
update = newUpdate(c, otherUser);
|
||||
update.setPatchSetId(ps1);
|
||||
@@ -2625,7 +2622,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
public void updateCommentsInSequentialUpdates() throws Exception {
|
||||
Change c = newChange();
|
||||
CommentRange range = new CommentRange(1, 1, 2, 1);
|
||||
String rev = "abcd1234abcd1234abcd1234abcd1234abcd1234";
|
||||
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
|
||||
ChangeUpdate update1 = newUpdate(c, otherUser);
|
||||
Comment comment1 =
|
||||
@@ -2640,7 +2637,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
new Timestamp(update1.getWhen().getTime()),
|
||||
"comment 1",
|
||||
(short) 1,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update1.putComment(Status.PUBLISHED, comment1);
|
||||
|
||||
@@ -2657,7 +2654,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
new Timestamp(update2.getWhen().getTime()),
|
||||
"comment 2",
|
||||
(short) 1,
|
||||
rev,
|
||||
commitId,
|
||||
false);
|
||||
update2.putComment(Status.PUBLISHED, comment2);
|
||||
|
||||
@@ -2668,7 +2665,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
}
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
List<Comment> comments = notes.getComments().get(new RevId(rev));
|
||||
List<Comment> comments = notes.getComments().get(commitId);
|
||||
assertThat(comments).hasSize(2);
|
||||
assertThat(comments.get(0).message).isEqualTo("comment 1");
|
||||
assertThat(comments.get(1).message).isEqualTo("comment 2");
|
||||
@@ -2714,7 +2711,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
new Timestamp(update.getWhen().getTime()),
|
||||
"comment",
|
||||
(short) 1,
|
||||
"abcd1234abcd1234abcd1234abcd1234abcd1234",
|
||||
ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"),
|
||||
false);
|
||||
update.putComment(Status.PUBLISHED, comment);
|
||||
update.commit();
|
||||
|
@@ -25,6 +25,7 @@ import java.sql.Timestamp;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -160,7 +161,7 @@ public class CommentTimestampAdapterTest extends GerritBaseTests {
|
||||
"serverId",
|
||||
false);
|
||||
c.lineNbr = 1;
|
||||
c.revId = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
|
||||
c.setCommitId(ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
|
||||
|
||||
String json = gson.toJson(c);
|
||||
assertThat(json).contains("\"writtenOn\": \"" + NON_DST_STR_TRUNC + "\",");
|
||||
|
Reference in New Issue
Block a user