Move Change out of AbstractChangeNotes

In order to load all draft PatchLineComments for a given author, we
will need to be able to scan all the refs in their namespace of the
All-Users repository and load the drafts in without access to a Change
object (we will just have the ChangeId from the refname). Therefore, I
removed that field from AbstractChangeNotes and put the Change object
just in ChangeNotes because some callers of ChangeNotes need the
Change object. I put the ChangeId in the AbstractChangeNotes instead,
since both ChangeNotes and DraftCommentNotes need that.

Change-Id: Icd3b72b10dd39a205c3ec420b25a6740b9d376af
This commit is contained in:
Yacob Yonas
2014-07-18 14:55:33 -07:00
parent 1ef3b37c88
commit 1cae3dab65
4 changed files with 21 additions and 19 deletions

View File

@@ -490,6 +490,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
}
}
private final Change change;
private ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals;
private ImmutableSetMultimap<ReviewerState, Account.Id> reviewers;
private ImmutableList<SubmitRecord> submitRecords;
@@ -505,8 +506,13 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
@VisibleForTesting
public ChangeNotes(GitRepositoryManager repoManager,
AllUsersNameProvider allUsersProvider, Change change) {
super(repoManager, change);
super(repoManager, change.getId());
this.allUsers = allUsersProvider.get();
this.change = new Change(change);
}
public Change getChange() {
return change;
}
public ImmutableListMultimap<PatchSet.Id, PatchSetApproval> getApprovals() {
@@ -565,7 +571,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
if (draftCommentNotes == null ||
!author.equals(draftCommentNotes.getAuthor())) {
draftCommentNotes = new DraftCommentNotes(repoManager, allUsers,
getChange(), author);
getChangeId(), author);
draftCommentNotes.load();
}
}