From e0111b18c8386d86eac2671b8cf639b63ec53560 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 27 Jul 2011 11:54:11 -0700 Subject: [PATCH] IndexPack: Fix "Resolving deltas" progress meter 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 --- .../eclipse/jgit/transport/PackParser.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java index 03370034b2..653fd4c403 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java @@ -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( -- 2.39.5