Move getCommentPsId from notedb to common location
Change-Id: I683bf59ade30304bed104fae95204e344a95506d
This commit is contained in:
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.getCommentPsId;
|
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
@@ -64,6 +62,10 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PatchLineCommentsUtil {
|
public class PatchLineCommentsUtil {
|
||||||
|
public static PatchSet.Id getCommentPsId(PatchLineComment plc) {
|
||||||
|
return plc.getKey().getParentKey().getParentKey();
|
||||||
|
}
|
||||||
|
|
||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
private final AllUsersName allUsers;
|
private final AllUsersName allUsers;
|
||||||
private final DraftCommentNotes.Factory draftFactory;
|
private final DraftCommentNotes.Factory draftFactory;
|
||||||
|
@@ -16,8 +16,8 @@ package com.google.gerrit.server.notedb;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static com.google.gerrit.server.PatchLineCommentsUtil.getCommentPsId;
|
||||||
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.addCommentToMap;
|
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.addCommentToMap;
|
||||||
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.getCommentPsId;
|
|
||||||
|
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.server.notedb;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.server.PatchLineCommentsUtil.setCommentRevId;
|
import static com.google.gerrit.server.PatchLineCommentsUtil.setCommentRevId;
|
||||||
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.getCommentPsId;
|
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
@@ -33,6 +32,7 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
|
import com.google.gerrit.server.PatchLineCommentsUtil;
|
||||||
import com.google.gerrit.server.git.VersionedMetaData.BatchMetaDataUpdate;
|
import com.google.gerrit.server.git.VersionedMetaData.BatchMetaDataUpdate;
|
||||||
import com.google.gerrit.server.patch.PatchListCache;
|
import com.google.gerrit.server.patch.PatchListCache;
|
||||||
import com.google.gerrit.server.project.ChangeControl;
|
import com.google.gerrit.server.project.ChangeControl;
|
||||||
@@ -306,7 +306,7 @@ public class ChangeRebuilder {
|
|||||||
|
|
||||||
PatchLineCommentEvent(PatchLineComment c, Change change, PatchSet ps,
|
PatchLineCommentEvent(PatchLineComment c, Change change, PatchSet ps,
|
||||||
PatchListCache cache) {
|
PatchListCache cache) {
|
||||||
super(getCommentPsId(c), c.getAuthor(), c.getWrittenOn());
|
super(PatchLineCommentsUtil.getCommentPsId(c), c.getAuthor(), c.getWrittenOn());
|
||||||
this.c = c;
|
this.c = c;
|
||||||
this.change = change;
|
this.change = change;
|
||||||
this.ps = ps;
|
this.ps = ps;
|
||||||
|
@@ -15,13 +15,13 @@
|
|||||||
package com.google.gerrit.server.notedb;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.gerrit.server.PatchLineCommentsUtil.getCommentPsId;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_HASHTAGS;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_HASHTAGS;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_LABEL;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_LABEL;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PATCH_SET;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PATCH_SET;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_STATUS;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_STATUS;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBMITTED_WITH;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBMITTED_WITH;
|
||||||
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.addCommentToMap;
|
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.addCommentToMap;
|
||||||
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.getCommentPsId;
|
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
@@ -33,6 +33,7 @@ import com.google.gerrit.reviewdb.client.PatchLineComment.Status;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.RevId;
|
import com.google.gerrit.reviewdb.client.RevId;
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
|
import com.google.gerrit.server.PatchLineCommentsUtil;
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -147,10 +148,6 @@ public class CommentsInNotesUtil {
|
|||||||
return dateFormatter.formatDate(newIdent);
|
return dateFormatter.formatDate(newIdent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PatchSet.Id getCommentPsId(PatchLineComment plc) {
|
|
||||||
return plc.getKey().getParentKey().getParentKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PatchLineComment parseComment(byte[] note, MutableInteger curr,
|
private static PatchLineComment parseComment(byte[] note, MutableInteger curr,
|
||||||
String currentFileName, PatchSet.Id psId, RevId revId, boolean isForBase,
|
String currentFileName, PatchSet.Id psId, RevId revId, boolean isForBase,
|
||||||
Charset enc, Status status)
|
Charset enc, Status status)
|
||||||
@@ -444,7 +441,7 @@ public class CommentsInNotesUtil {
|
|||||||
PatchLineComment first = comments.get(0);
|
PatchLineComment first = comments.get(0);
|
||||||
|
|
||||||
short side = first.getSide();
|
short side = first.getSide();
|
||||||
PatchSet.Id psId = getCommentPsId(first);
|
PatchSet.Id psId = PatchLineCommentsUtil.getCommentPsId(first);
|
||||||
appendHeaderField(writer, side == 0
|
appendHeaderField(writer, side == 0
|
||||||
? BASE_PATCH_SET
|
? BASE_PATCH_SET
|
||||||
: PATCH_SET,
|
: PATCH_SET,
|
||||||
@@ -454,7 +451,7 @@ public class CommentsInNotesUtil {
|
|||||||
String currentFilename = null;
|
String currentFilename = null;
|
||||||
|
|
||||||
for (PatchLineComment c : comments) {
|
for (PatchLineComment c : comments) {
|
||||||
PatchSet.Id currentPsId = getCommentPsId(c);
|
PatchSet.Id currentPsId = PatchLineCommentsUtil.getCommentPsId(c);
|
||||||
checkArgument(psId.equals(currentPsId),
|
checkArgument(psId.equals(currentPsId),
|
||||||
"All comments being added must all have the same PatchSet.Id. The"
|
"All comments being added must all have the same PatchSet.Id. The"
|
||||||
+ "comment below does not have the same PatchSet.Id as the others "
|
+ "comment below does not have the same PatchSet.Id as the others "
|
||||||
|
Reference in New Issue
Block a user