]> source.dussan.org Git - jgit.git/commitdiff
Report progress while updating references 56/3556/2
authorShawn O. Pearce <spearce@spearce.org>
Fri, 27 May 2011 17:46:02 +0000 (10:46 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 10 Jun 2011 00:29:46 +0000 (17:29 -0700)
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>
org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

index 5a40edd7dc019dd13ae0daecb37f3644fec15d2d..165ad9d401f2d432fd74bf577e875c90b5906574 100644 (file)
@@ -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}
index 02538a2dce26f6c65bcdcb42ea9ca13b70c466aa..c0f7a1479c6613db9a5aee88f3b21b8ec34bd78f 100644 (file)
@@ -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;
index 17c2d5f866ef81950d4c7d06b1faa9e20741486d..5f330308a0c800c43cd416190ef149e7c26854ac 100644 (file)
@@ -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();
                }
index f1f9b0f44d2c8fcfb1d7da46f247d8a88a2ea511..40435b8a29d9847727013e89776aa591c8c27ab0 100644 (file)
@@ -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) {