Stop passing ReviewDb, etc. to ChangeData methods

Many methods that are intended for lazy initialization take a
ReviewDb, and some take other helper objects such as
GitRepositoryManager. This achieves the intended lazy-loading behavior
but requires a lot of injection of dependencies into callers, and may
become untenable as lazy loading of ChangeData requires more helpers.

Instead, since after all this is Java, construct ChangeData with a
Factory. This is subtle because it is used from a lot of places that
need control over which ReviewDb handle to pass in, so the factory
methods still need to take a db. ChangeData objects are still intended
(i.e. safe) for use only by one thread, so having a single ReviewDb
instance stored for the lifetime of the ChangeData should be fine. We
just need to be careful about which we pass in, particularly in a
place like ChangeIndexer.

As a side effect, clean up some other injection, particularly in the
predicate class hierarchy.

Change-Id: I52e1eb2a76788c12dd95767e89095ab80df7e1cc
This commit is contained in:
Dave Borowitz
2013-12-20 11:38:13 -08:00
parent 24b40a9592
commit 7547233449
67 changed files with 470 additions and 505 deletions

View File

@@ -454,7 +454,7 @@ public class ChangeUtil {
db.changeMessages().delete(db.changeMessages().byChange(changeId));
db.starredChanges().delete(db.starredChanges().byChange(changeId));
db.changes().delete(Collections.singleton(change));
indexer.delete(change);
indexer.delete(db, change);
}
public void deleteOnlyDraftPatchSet(PatchSet patch, Change change)