Browse Source

Merge changes I58110f17,I440baa64,Ic77dcac5

* changes:
  PackWriter: Skip progress messages on fast operations
  IndexPack: Defer the "Resolving deltas" progress meter
  IndexPack: Fix "Resolving deltas" progress meter
stable-1.1
Shawn O. Pearce 14 years ago committed by Code Review
parent
commit
86ecf141b6
  1. 16
      org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
  2. 27
      org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java

16
org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java

@ -80,6 +80,7 @@ import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException;
import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.AsyncObjectSizeQueue; import org.eclipse.jgit.lib.AsyncObjectSizeQueue;
import org.eclipse.jgit.lib.BatchingProgressMonitor;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
@ -640,10 +641,21 @@ public class PackWriter {
if (writeMonitor == null) if (writeMonitor == null)
writeMonitor = NullProgressMonitor.INSTANCE; writeMonitor = NullProgressMonitor.INSTANCE;
if (reuseSupport != null && ( boolean needSearchForReuse = reuseSupport != null && (
reuseDeltas reuseDeltas
|| config.isReuseObjects() || config.isReuseObjects()
|| !cachedPacks.isEmpty())) || !cachedPacks.isEmpty());
if (compressMonitor instanceof BatchingProgressMonitor) {
long delay = 1000;
if (needSearchForReuse && config.isDeltaCompress())
delay = 500;
((BatchingProgressMonitor) compressMonitor).setDelayStart(
delay,
TimeUnit.MILLISECONDS);
}
if (needSearchForReuse)
searchForReuse(compressMonitor); searchForReuse(compressMonitor);
if (config.isDeltaCompress()) if (config.isDeltaCompress())
searchForDeltas(compressMonitor); searchForDeltas(compressMonitor);

27
org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java

@ -54,6 +54,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.zip.DataFormatException; import java.util.zip.DataFormatException;
import java.util.zip.Inflater; import java.util.zip.Inflater;
@ -61,6 +62,7 @@ import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.BatchingProgressMonitor;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.InflaterCache; import org.eclipse.jgit.lib.InflaterCache;
import org.eclipse.jgit.lib.MutableObjectId; import org.eclipse.jgit.lib.MutableObjectId;
@ -478,6 +480,12 @@ public abstract class PackParser {
if (!deferredCheckBlobs.isEmpty()) if (!deferredCheckBlobs.isEmpty())
doDeferredCheckBlobs(); doDeferredCheckBlobs();
if (deltaCount > 0) { if (deltaCount > 0) {
if (resolving instanceof BatchingProgressMonitor) {
((BatchingProgressMonitor) resolving).setDelayStart(
1000,
TimeUnit.MILLISECONDS);
}
resolving.beginTask(JGitText.get().resolvingDeltas, deltaCount);
resolveDeltas(resolving); resolveDeltas(resolving);
if (entryCount < objectCount) { if (entryCount < objectCount) {
if (!isAllowThin()) { if (!isAllowThin()) {
@ -494,6 +502,7 @@ public abstract class PackParser {
(objectCount - entryCount))); (objectCount - entryCount)));
} }
} }
resolving.endTask();
} }
packDigest = null; packDigest = null;
@ -518,20 +527,17 @@ public abstract class PackParser {
private void resolveDeltas(final ProgressMonitor progress) private void resolveDeltas(final ProgressMonitor progress)
throws IOException { throws IOException {
progress.beginTask(JGitText.get().resolvingDeltas, deltaCount);
final int last = entryCount; final int last = entryCount;
for (int i = 0; i < last; i++) { for (int i = 0; i < last; i++) {
final int before = entryCount; resolveDeltas(entries[i], progress);
resolveDeltas(entries[i]);
progress.update(entryCount - before);
if (progress.isCancelled()) if (progress.isCancelled())
throw new IOException( throw new IOException(
JGitText.get().downloadCancelledDuringIndexing); 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); UnresolvedDelta children = firstChildOf(oe);
if (children == null) if (children == null)
return; return;
@ -559,12 +565,14 @@ public abstract class PackParser {
.getOffset())); .getOffset()));
} }
resolveDeltas(visit.next(), info.type, info); resolveDeltas(visit.next(), info.type, info, progress);
} }
private void resolveDeltas(DeltaVisit visit, final int type, private void resolveDeltas(DeltaVisit visit, final int type,
ObjectTypeAndSize info) throws IOException { ObjectTypeAndSize info, ProgressMonitor progress)
throws IOException {
do { do {
progress.update(1);
info = openDatabase(visit.delta, info); info = openDatabase(visit.delta, info);
switch (info.type) { switch (info.type) {
case Constants.OBJ_OFS_DELTA: case Constants.OBJ_OFS_DELTA:
@ -749,7 +757,8 @@ public abstract class PackParser {
entries[entryCount++] = oe; entries[entryCount++] = oe;
visit.nextChild = firstChildOf(oe); visit.nextChild = firstChildOf(oe);
resolveDeltas(visit.next(), typeCode, new ObjectTypeAndSize()); resolveDeltas(visit.next(), typeCode,
new ObjectTypeAndSize(), progress);
if (progress.isCancelled()) if (progress.isCancelled())
throw new IOException( throw new IOException(

Loading…
Cancel
Save