Browse Source

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 <spearce@spearce.org>
stable-1.1
Shawn O. Pearce 13 years ago
parent
commit
e0111b18c8
  1. 20
      org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java

20
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(

Loading…
Cancel
Save