]> source.dussan.org Git - jgit.git/commitdiff
IndexPack: Fix "Resolving deltas" progress meter 31/3931/2
authorShawn O. Pearce <spearce@spearce.org>
Wed, 27 Jul 2011 18:54:11 +0000 (11:54 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Thu, 28 Jul 2011 17:22:50 +0000 (10:22 -0700)
This progress meter never reached 100% as it did not update while
resolving the external bases in thin packs.

Instead of updating in batches at the top level, update once per delta
that is resolved. The batching progress meter type should smooth out
the frequent updates to an update rate that is more reasonable to send
to the UI, while also ensuring a successful pack parse always reaches
100% deltas resolved.

Change-Id: Ic77dcac542cfa97213a6b0194708f9d3c256d223
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java

index 03370034b265b857b6775efd91e4a00613b7a995..653fd4c403cf2074ee67f90ee69a91158aff93f5 100644 (file)
@@ -478,6 +478,7 @@ public abstract class PackParser {
                        if (!deferredCheckBlobs.isEmpty())
                                doDeferredCheckBlobs();
                        if (deltaCount > 0) {
+                               resolving.beginTask(JGitText.get().resolvingDeltas, deltaCount);
                                resolveDeltas(resolving);
                                if (entryCount < objectCount) {
                                        if (!isAllowThin()) {
@@ -494,6 +495,7 @@ public abstract class PackParser {
                                                                (objectCount - entryCount)));
                                        }
                                }
+                               resolving.endTask();
                        }
 
                        packDigest = null;
@@ -518,20 +520,17 @@ public abstract class PackParser {
 
        private void resolveDeltas(final ProgressMonitor progress)
                        throws IOException {
-               progress.beginTask(JGitText.get().resolvingDeltas, deltaCount);
                final int last = entryCount;
                for (int i = 0; i < last; i++) {
-                       final int before = entryCount;
-                       resolveDeltas(entries[i]);
-                       progress.update(entryCount - before);
+                       resolveDeltas(entries[i], progress);
                        if (progress.isCancelled())
                                throw new IOException(
                                                JGitText.get().downloadCancelledDuringIndexing);
                }
-               progress.endTask();
        }
 
-       private void resolveDeltas(final PackedObjectInfo oe) throws IOException {
+       private void resolveDeltas(final PackedObjectInfo oe,
+                       ProgressMonitor progress) throws IOException {
                UnresolvedDelta children = firstChildOf(oe);
                if (children == null)
                        return;
@@ -559,12 +558,14 @@ public abstract class PackParser {
                                                        .getOffset()));
                }
 
-               resolveDeltas(visit.next(), info.type, info);
+               resolveDeltas(visit.next(), info.type, info, progress);
        }
 
        private void resolveDeltas(DeltaVisit visit, final int type,
-                       ObjectTypeAndSize info) throws IOException {
+                       ObjectTypeAndSize info, ProgressMonitor progress)
+                       throws IOException {
                do {
+                       progress.update(1);
                        info = openDatabase(visit.delta, info);
                        switch (info.type) {
                        case Constants.OBJ_OFS_DELTA:
@@ -749,7 +750,8 @@ public abstract class PackParser {
                                entries[entryCount++] = oe;
 
                        visit.nextChild = firstChildOf(oe);
-                       resolveDeltas(visit.next(), typeCode, new ObjectTypeAndSize());
+                       resolveDeltas(visit.next(), typeCode,
+                                       new ObjectTypeAndSize(), progress);
 
                        if (progress.isCancelled())
                                throw new IOException(