DfsPackFileMidx: Offer localIterator We need the iterator to use an exiting midx as input to write a new one. Add a localIterator() method to get the iterator over local objects. Change-Id: Ie5037639dbec0abc8af8a6e195aa5c756a6a6964
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidx.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidx.java index 0582737..3c63db2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidx.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidx.java
@@ -20,6 +20,7 @@ import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; import org.eclipse.jgit.internal.storage.file.PackIndex; import org.eclipse.jgit.internal.storage.file.PackReverseIndex; +import org.eclipse.jgit.internal.storage.midx.MultiPackIndex; import org.eclipse.jgit.internal.storage.pack.ObjectToPack; import org.eclipse.jgit.internal.storage.pack.PackOutputStream; import org.eclipse.jgit.lib.AbbreviatedObjectId; @@ -152,6 +153,18 @@ protected int getObjectCount(DfsReader ctx) throws IOException { */ protected abstract byte[] getChecksum(DfsReader ctx) throws IOException; + /** + * Get a midx iterator over the contents of *this* midx, without the base. + * + * @param ctx + * a ready + * @return an iterator over the objects in this midx in sha1 order + * @throws IOException + * an error loading the underlying data + */ + protected abstract MultiPackIndex.MidxIterator localIterator(DfsReader ctx) + throws IOException; + @Override public final PackIndex getPackIndex(DfsReader ctx) { return new MidxPackIndex(this, ctx);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidxNPacks.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidxNPacks.java index bed7a53..7b030cf 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidxNPacks.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidxNPacks.java
@@ -242,6 +242,12 @@ protected int getObjectCount(DfsReader ctx) throws IOException { return midx(ctx).getChecksum(); } + @Override + protected MultiPackIndex.MidxIterator localIterator(DfsReader ctx) + throws IOException { + return midx(ctx).iterator(); + } + /** * Packs indexed by this multipack index (base NOT included) *
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidxSingle.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidxSingle.java index 71ff884..89dbf9d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidxSingle.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFileMidxSingle.java
@@ -25,6 +25,8 @@ import org.eclipse.jgit.internal.storage.file.PackBitmapIndex; import org.eclipse.jgit.internal.storage.file.PackIndex; import org.eclipse.jgit.internal.storage.file.PackReverseIndex; +import org.eclipse.jgit.internal.storage.midx.MidxIterators; +import org.eclipse.jgit.internal.storage.midx.MultiPackIndex; import org.eclipse.jgit.internal.storage.midx.MultiPackIndex.PackOffset; import org.eclipse.jgit.internal.storage.pack.ObjectToPack; import org.eclipse.jgit.internal.storage.pack.PackExt; @@ -149,6 +151,14 @@ protected int getObjectCount(DfsReader ctx) throws IOException { return checksum; } + @Override + protected MultiPackIndex.MidxIterator localIterator(DfsReader ctx) + throws IOException { + String packName = pack.getPackDescription().getPackName(); + PackIndex packIndex = pack.getPackIndex(ctx); + return MidxIterators.fromPackIndexIterator(packName, packIndex); + } + /** * Packs indexed by this multipack index (base NOT included) *