summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-01-14 14:17:55 -0800
committerChris Aniszczyk <caniszczyk@gmail.com>2011-01-25 16:43:06 -0600
commit1bf0c3cdb1aecac41284e63b2daed2d92b908d3d (patch)
tree043bcf5e081976f2fd20d958eccda60472e98825 /org.eclipse.jgit.pgm
parent51dedfdc319d51aa729f3e2801c4a06491d6ddac (diff)
downloadjgit-1bf0c3cdb1aecac41284e63b2daed2d92b908d3d.tar.gz
jgit-1bf0c3cdb1aecac41284e63b2daed2d92b908d3d.zip
Refactor IndexPack to not require local filesystem
By moving the logic that parses a pack stream from the network (or a bundle) into a type that can be constructed by an ObjectInserter, repository implementations have a chance to inject their own logic for storing object data received into the destination repository. The API isn't completely generic yet, there are still quite a few assumptions that the PackParser subclass is storing the data onto the local filesystem as a single file. But its about the simplest split of IndexPack I can come up with without completely ripping the code apart. Change-Id: I5b167c9cc6d7a7c56d0197c62c0fd0036a83ec6c Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java35
1 files changed, 18 insertions, 17 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
index 640c8ef348..4585650395 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
@@ -45,12 +45,12 @@
package org.eclipse.jgit.pgm;
import java.io.BufferedInputStream;
-import java.io.File;
-import org.kohsuke.args4j.Argument;
-import org.kohsuke.args4j.Option;
-import org.eclipse.jgit.lib.CoreConfig;
+import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.TextProgressMonitor;
+import org.eclipse.jgit.storage.file.ObjectDirectoryPackParser;
+import org.eclipse.jgit.transport.PackParser;
+import org.kohsuke.args4j.Option;
class IndexPack extends TextBuiltin {
@Option(name = "--fix-thin", usage = "usage_fixAThinPackToBeComplete")
@@ -59,20 +59,21 @@ class IndexPack extends TextBuiltin {
@Option(name = "--index-version", usage = "usage_indexFileFormatToCreate")
private int indexVersion = -1;
- @Argument(index = 0, required = true, metaVar = "metaVar_base")
- private File base;
-
@Override
protected void run() throws Exception {
- if (indexVersion == -1)
- indexVersion = db.getConfig().get(CoreConfig.KEY)
- .getPackIndexVersion();
- final BufferedInputStream in;
- final org.eclipse.jgit.transport.IndexPack ip;
- in = new BufferedInputStream(System.in);
- ip = new org.eclipse.jgit.transport.IndexPack(db, in, base);
- ip.setFixThin(fixThin);
- ip.setIndexVersion(indexVersion);
- ip.index(new TextProgressMonitor());
+ BufferedInputStream in = new BufferedInputStream(System.in);
+ ObjectInserter inserter = db.newObjectInserter();
+ try {
+ PackParser p = inserter.newPackParser(in);
+ p.setAllowThin(fixThin);
+ if (indexVersion != -1 && p instanceof ObjectDirectoryPackParser) {
+ ObjectDirectoryPackParser imp = (ObjectDirectoryPackParser) p;
+ imp.setIndexVersion(indexVersion);
+ }
+ p.parse(new TextProgressMonitor());
+ inserter.flush();
+ } finally {
+ inserter.release();
+ }
}
}