Use BatchRefUpdate to execute reference changes

Some storage backends for JGit are able to update multiple references
in a single pass efficiently. Take advantage of this by pushing
any normal reference updates (such as direct push or branch create)
into a single BatchRefUpdate object.

Change-Id: Iadd7c5a3271f5ab8eaf31881392c85dd5b0a709d
This commit is contained in:
Shawn O. Pearce
2012-07-26 11:36:58 -07:00
parent c756538f63
commit 1732f75709
2 changed files with 46 additions and 13 deletions

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.git;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,7 +59,7 @@ public class MultiProgressMonitor {
private static final char NO_SPINNER = ' ';
/** Handle for a sub-task. */
public class Task {
public class Task implements ProgressMonitor {
private final String name;
private final int total;
private volatile int count;
@@ -76,6 +77,7 @@ public class MultiProgressMonitor {
*
* @param completed number of work units completed.
*/
@Override
public void update(final int completed) {
count += completed;
if (total != UNKNOWN) {
@@ -97,6 +99,23 @@ public class MultiProgressMonitor {
wakeUp();
}
}
@Override
public void start(int totalTasks) {
}
@Override
public void beginTask(String title, int totalWork) {
}
@Override
public void endTask() {
}
@Override
public boolean isCancelled() {
return false;
}
}
private final OutputStream out;