PatchListLoader: Make saving automerged trees optional

In a parallel batch reindexing situation, implementations may want to
avoid high write throughput on the ref database caused by
indiscriminately calling PatchListLoader.automerge()

Change-Id: If87956b5352b266f717376462fe007cffa3b0b59
This commit is contained in:
Dave Borowitz
2013-09-04 11:07:48 -07:00
parent cd4be95d6e
commit 67e8304ae7

View File

@@ -243,6 +243,11 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
public static RevTree automerge(Repository repo, RevWalk rw, RevCommit b)
throws IOException {
return automerge(repo, rw, b, true);
}
public static RevTree automerge(Repository repo, RevWalk rw, RevCommit b,
boolean save) throws IOException {
String hash = b.name();
String refName = GitRepositoryManager.REFS_CACHE_AUTOMERGE
+ hash.substring(0, 2)
@@ -373,10 +378,12 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
ins.release();
}
RefUpdate update = repo.updateRef(refName);
update.setNewObjectId(treeId);
update.disableRefLog();
update.forceUpdate();
if (save) {
RefUpdate update = repo.updateRef(refName);
update.setNewObjectId(treeId);
update.disableRefLog();
update.forceUpdate();
}
return rw.parseTree(treeId);
}