diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-30 10:39:00 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-30 10:39:00 -0700 |
commit | a1d5f5b6b526d086a0963c634a38edb6789a4594 (patch) | |
tree | 62f35a8ae5f7056ddcffc036865205e8bc3b54f1 /org.eclipse.jgit.pgm | |
parent | cb9d8285bacf315e323d41f7bdc42acc8124fe98 (diff) | |
download | jgit-a1d5f5b6b526d086a0963c634a38edb6789a4594.tar.gz jgit-a1d5f5b6b526d086a0963c634a38edb6789a4594.zip |
Move DirCache factory methods to Repository
Instead of creating the DirCache from a static factory method, use
an instance method on Repository, permitting the implementation to
override the method with a completely different type of DirCache
reading and writing. This would better support a repository in the
cloud strategy, or even just an in-memory unit test environment.
Change-Id: I6399894b12d6480c4b3ac84d10775dfd1b8d13e7
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.pgm')
6 files changed, 6 insertions, 7 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java index b0cc5248c9..9f577ff05e 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java @@ -69,7 +69,7 @@ class Rm extends TextBuiltin { protected void run() throws Exception { root = db.getWorkTree(); - final DirCache dirc = DirCache.lock(db); + final DirCache dirc = db.lockDirCache(); final DirCacheBuilder edit = dirc.builder(); final TreeWalk walk = new TreeWalk(db); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java index d772ffe23f..709b45a17b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java @@ -54,7 +54,7 @@ import org.eclipse.jgit.pgm.TextBuiltin; class MakeCacheTree extends TextBuiltin { @Override protected void run() throws Exception { - final DirCache cache = DirCache.read(db); + final DirCache cache = db.readDirCache(); final DirCacheTree tree = cache.getCacheTree(true); show(tree); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java index 2a1079b313..0ca050880e 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java @@ -46,7 +46,6 @@ package org.eclipse.jgit.pgm.debug; import java.text.MessageFormat; -import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; @@ -56,7 +55,7 @@ class ReadDirCache extends TextBuiltin { final int cnt = 100; final long start = System.currentTimeMillis(); for (int i = 0; i < cnt; i++) - DirCache.read(db); + db.readDirCache(); final long end = System.currentTimeMillis(); out.print(" "); out.println(MessageFormat.format(CLIText.get().averageMSPerRead, (end - start) / cnt)); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java index 09796edb30..c49aefbf2f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java @@ -54,7 +54,7 @@ import org.eclipse.jgit.pgm.TextBuiltin; class ShowCacheTree extends TextBuiltin { @Override protected void run() throws Exception { - final DirCache cache = DirCache.read(db); + final DirCache cache = db.readDirCache(); final DirCacheTree tree = cache.getCacheTree(false); if (tree == null) throw die(CLIText.get().noTREESectionInIndex); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java index 854596c97b..a94d37ff87 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java @@ -59,7 +59,7 @@ class ShowDirCache extends TextBuiltin { final SimpleDateFormat fmt; fmt = new SimpleDateFormat("yyyyMMdd,HHmmss.SSS"); - final DirCache cache = DirCache.read(db); + final DirCache cache = db.readDirCache(); for (int i = 0; i < cache.getEntryCount(); i++) { final DirCacheEntry ent = cache.getEntry(i); final FileMode mode = FileMode.fromBits(ent.getRawMode()); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java index cee5966a03..142dbeecc8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java @@ -51,7 +51,7 @@ import org.eclipse.jgit.pgm.TextBuiltin; class WriteDirCache extends TextBuiltin { @Override protected void run() throws Exception { - final DirCache cache = DirCache.read(db); + final DirCache cache = db.readDirCache(); if (!cache.lock()) throw die(CLIText.get().failedToLockIndex); cache.read(); |