DraftCommentNotes: Respect auto-rebuild bit from ChangeNotes

Change-Id: I753ce569aecbf71decd24c771e65c71b43e14426
This commit is contained in:
Dave Borowitz
2016-04-11 14:48:50 -04:00
parent c2c6a0da44
commit 67b9969228
2 changed files with 17 additions and 5 deletions

View File

@@ -491,7 +491,8 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
throws OrmException { throws OrmException {
if (draftCommentNotes == null || if (draftCommentNotes == null ||
!author.equals(draftCommentNotes.getAuthor())) { !author.equals(draftCommentNotes.getAuthor())) {
draftCommentNotes = new DraftCommentNotes(args, change, author); draftCommentNotes =
new DraftCommentNotes(args, change, author, autoRebuild);
draftCommentNotes.load(); draftCommentNotes.load();
} }
} }

View File

@@ -52,6 +52,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
private final Change change; private final Change change;
private final Account.Id author; private final Account.Id author;
private final boolean autoRebuild;
private ImmutableListMultimap<RevId, PatchLineComment> comments; private ImmutableListMultimap<RevId, PatchLineComment> comments;
private RevisionNoteMap revisionNoteMap; private RevisionNoteMap revisionNoteMap;
@@ -61,9 +62,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
Args args, Args args,
@Assisted Change change, @Assisted Change change,
@Assisted Account.Id author) { @Assisted Account.Id author) {
super(args, change.getId()); this(args, change, author, true);
this.change = change;
this.author = author;
} }
@AssistedInject @AssistedInject
@@ -74,6 +73,18 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
super(args, changeId); super(args, changeId);
this.change = null; this.change = null;
this.author = author; this.author = author;
this.autoRebuild = true;
}
DraftCommentNotes(
Args args,
Change change,
Account.Id author,
boolean autoRebuild) {
super(args, change.getId());
this.change = change;
this.author = author;
this.autoRebuild = autoRebuild;
} }
RevisionNoteMap getRevisionNoteMap() { RevisionNoteMap getRevisionNoteMap() {
@@ -138,7 +149,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
@Override @Override
protected LoadHandle openHandle(Repository repo) throws IOException { protected LoadHandle openHandle(Repository repo) throws IOException {
if (change != null) { if (change != null && autoRebuild) {
NoteDbChangeState state = NoteDbChangeState.parse(change); NoteDbChangeState state = NoteDbChangeState.parse(change);
// Only check if this particular user's drafts are up to date, to avoid // Only check if this particular user's drafts are up to date, to avoid
// reading unnecessary refs. // reading unnecessary refs.