StalenessChecker: Expose some more public methods
Used by our custom index backend implementation, and may be useful for others as well (e.g. to write an offline staleness checker). Change-Id: Icb48993da89fae60c62663347dbdbb48667e0a94
This commit is contained in:
@@ -84,7 +84,7 @@ public class StalenessChecker {
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
boolean isStale(Change.Id id) throws IOException, OrmException {
|
||||
public boolean isStale(Change.Id id) throws IOException, OrmException {
|
||||
ChangeIndex i = indexes.getSearchIndex();
|
||||
if (i == null) {
|
||||
return false; // No index; caller couldn't do anything if it is stale.
|
||||
@@ -100,17 +100,24 @@ public class StalenessChecker {
|
||||
return true; // Not in index, but caller wants it to be.
|
||||
}
|
||||
ChangeData cd = result.get();
|
||||
if (reviewDbChangeIsStale(
|
||||
cd.change(),
|
||||
ChangeNotes.readOneReviewDbChange(db.get(), cd.getId()))) {
|
||||
return true;
|
||||
}
|
||||
return isStale(repoManager, id, cd.change(),
|
||||
ChangeNotes.readOneReviewDbChange(db.get(), id),
|
||||
parseStates(cd), parsePatterns(cd));
|
||||
}
|
||||
|
||||
return isStale(repoManager, id, parseStates(cd), parsePatterns(cd));
|
||||
public static boolean isStale(
|
||||
GitRepositoryManager repoManager,
|
||||
Change.Id id,
|
||||
Change indexChange,
|
||||
@Nullable Change reviewDbChange,
|
||||
SetMultimap<Project.NameKey, RefState> states,
|
||||
Multimap<Project.NameKey, RefStatePattern> patterns) {
|
||||
return reviewDbChangeIsStale(indexChange, reviewDbChange)
|
||||
|| refsAreStale(repoManager, id, states, patterns);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static boolean isStale(GitRepositoryManager repoManager,
|
||||
static boolean refsAreStale(GitRepositoryManager repoManager,
|
||||
Change.Id id,
|
||||
SetMultimap<Project.NameKey, RefState> states,
|
||||
Multimap<Project.NameKey, RefStatePattern> patterns) {
|
||||
@@ -118,7 +125,7 @@ public class StalenessChecker {
|
||||
Sets.union(states.keySet(), patterns.keySet());
|
||||
|
||||
for (Project.NameKey p : projects) {
|
||||
if (isStale(repoManager, id, p, states, patterns)) {
|
||||
if (refsAreStale(repoManager, id, p, states, patterns)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -145,8 +152,7 @@ public class StalenessChecker {
|
||||
return parseStates(cd.getRefStates());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static SetMultimap<Project.NameKey, RefState> parseStates(
|
||||
public static SetMultimap<Project.NameKey, RefState> parseStates(
|
||||
Iterable<byte[]> states) {
|
||||
RefState.check(states != null, null);
|
||||
SetMultimap<Project.NameKey, RefState> result = HashMultimap.create();
|
||||
@@ -188,7 +194,7 @@ public class StalenessChecker {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean isStale(GitRepositoryManager repoManager,
|
||||
private static boolean refsAreStale(GitRepositoryManager repoManager,
|
||||
Change.Id id, Project.NameKey project,
|
||||
SetMultimap<Project.NameKey, RefState> allStates,
|
||||
Multimap<Project.NameKey, RefStatePattern> allPatterns) {
|
||||
|
||||
Reference in New Issue
Block a user