Browse Source

Report progress while updating references

If a fetch or push needs to apply more than a few references
to the local repository it may take more than 0.25 seconds to
process all of the updates.  This is especially true in the DHT
storage system during an initial push of a project with many tags.
The backend database may need to use a transaction to ensure each
tag reference creation is unique, and there may be large delays
caused by these transactions.

Change-Id: Ib11a077adfbd525253e425d327f2e2c2380804c7
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-1.1
Shawn O. Pearce 14 years ago
parent
commit
1a87a725be
  1. 1
      org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties
  2. 1
      org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java
  3. 9
      org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
  4. 15
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

1
org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties

@ -470,6 +470,7 @@ unsupportedEncryptionVersion=Unsupported encryption version: {0}
unsupportedOperationNotAddAtEnd=Not add-at-end: {0}
unsupportedPackIndexVersion=Unsupported pack index version {0}
unsupportedPackVersion=Unsupported pack version {0}.
updatingReferences=Updating references
updatingRefFailed=Updating the ref {0} to {1} failed. ReturnCode from RefUpdate.update() was {2}
uriNotFound={0} not found
userConfigFileInvalid=User config file {0} invalid {1}

1
org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java

@ -530,6 +530,7 @@ public class JGitText extends TranslationBundle {
/***/ public String unsupportedOperationNotAddAtEnd;
/***/ public String unsupportedPackIndexVersion;
/***/ public String unsupportedPackVersion;
/***/ public String updatingReferences;
/***/ public String updatingRefFailed;
/***/ public String uriNotFound;
/***/ public String userConfigFileInvalid;

9
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java

@ -57,11 +57,13 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.lib.BatchingProgressMonitor;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ProgressMonitor;
@ -183,10 +185,16 @@ class FetchProcess {
final RevWalk walk = new RevWalk(transport.local);
try {
if (monitor instanceof BatchingProgressMonitor) {
((BatchingProgressMonitor) monitor).setDelayStart(
250, TimeUnit.MILLISECONDS);
}
monitor.beginTask(JGitText.get().updatingReferences, localUpdates.size());
if (transport.isRemoveDeletedRefs())
deleteStaleTrackingRefs(result, walk);
for (TrackingRefUpdate u : localUpdates) {
try {
monitor.update(1);
u.update(walk);
result.add(u);
} catch (IOException err) {
@ -195,6 +203,7 @@ class FetchProcess {
u.getLocalName(), err.getMessage()), err);
}
}
monitor.endTask();
} finally {
walk.release();
}

15
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

@ -62,6 +62,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.errors.MissingObjectException;
@ -1026,8 +1027,20 @@ public class ReceivePack {
private void executeCommands() {
preReceive.onPreReceive(this, filterCommands(Result.NOT_ATTEMPTED));
for (final ReceiveCommand cmd : filterCommands(Result.NOT_ATTEMPTED))
List<ReceiveCommand> toApply = filterCommands(Result.NOT_ATTEMPTED);
ProgressMonitor updating = NullProgressMonitor.INSTANCE;
if (sideBand) {
SideBandProgressMonitor pm = new SideBandProgressMonitor(msgOut);
pm.setDelayStart(250, TimeUnit.MILLISECONDS);
updating = pm;
}
updating.beginTask(JGitText.get().updatingReferences, toApply.size());
for (ReceiveCommand cmd : toApply) {
updating.update(1);
execute(cmd);
}
updating.endTask();
}
private void execute(final ReceiveCommand cmd) {

Loading…
Cancel
Save