Only call openMetadataRepository when notedb is enabled

This requires some slight ugliness of passing the NotesMigration down
into every AbstractChangeNotes so we can short-circuit during load().

Change-Id: I96a75fc3a7aa1005006e1b70bfb5506c2a0397f4
This commit is contained in:
Dave Borowitz
2014-09-04 11:05:29 -07:00
parent 523807681d
commit 11b4e50b78
6 changed files with 72 additions and 39 deletions

View File

@@ -48,19 +48,22 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
@Singleton
public static class Factory {
private final GitRepositoryManager repoManager;
private final NotesMigration migration;
private final AllUsersName draftsProject;
@VisibleForTesting
@Inject
public Factory(GitRepositoryManager repoManager,
NotesMigration migration,
AllUsersNameProvider allUsers) {
this.repoManager = repoManager;
this.migration = migration;
this.draftsProject = allUsers.get();
}
public DraftCommentNotes create(Change.Id changeId, Account.Id accountId) {
return new DraftCommentNotes(repoManager, draftsProject, changeId,
accountId);
return new DraftCommentNotes(repoManager, migration, draftsProject,
changeId, accountId);
}
}
@@ -71,9 +74,9 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
private final Table<PatchSet.Id, String, PatchLineComment> draftPsComments;
private NoteMap noteMap;
DraftCommentNotes(GitRepositoryManager repoManager,
DraftCommentNotes(GitRepositoryManager repoManager, NotesMigration migration,
AllUsersName draftsProject, Change.Id changeId, Account.Id author) {
super(repoManager, changeId);
super(repoManager, migration, changeId);
this.draftsProject = draftsProject;
this.author = author;
@@ -149,6 +152,11 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
getClass().getSimpleName() + " is read-only");
}
@Override
protected void loadDefaults() {
// Do nothing; tables are final and initialized in constructor.
}
@Override
protected Project.NameKey getProjectName() {
return draftsProject;