[PATCH JGit 02/19] Create abstract method on ObjectDatabase for accessing the list of local pack files.
- From
mr.gaffo@gmail.com <mr.gaffo@gmail.com>
- Date
- Sep 13, 2009, 18:44 UTC
- Message-ID
- <1252867475-858-3-git-send-email-mr.gaffo@gmail.com>
- In-Reply-To
- <1252867475-858-2-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
Implemented the method for AlternateRepository database as a passthrough
Implemented the method for ObjectDirectory as a toList of the current cached private PackList.
Hopefully this will allow easier reference to the list of packs for others like the server side of fetch. --- .../jgit/lib/AlternateRepositoryDatabase.java | 6 ++++++ .../src/org/spearce/jgit/lib/ObjectDatabase.java | 11 ++++++++++- .../src/org/spearce/jgit/lib/ObjectDirectory.java | 5 +++++ 3 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java index ee4c4cf..68ad488 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.List; /** * An ObjectDatabase of another {@link Repository}. @@ -124,4 +125,9 @@ void openObjectInAllPacks1(final Collection<PackedObjectLoader> out, protected void closeAlternates(final ObjectDatabase[] alt) { // Do nothing; these belong to odb to close, not us. } + + @Override + public List<PackFile> listLocalPacks() { + return odb.listLocalPacks(); + } } diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java index a547052..722c802 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.List; import java.util.concurrent.atomic.AtomicReference; /** @@ -64,7 +65,15 @@ protected ObjectDatabase() { alternates = new AtomicReference<ObjectDatabase[]>(); } - + + /** + * The list of Packs THIS repo contains + * + * @return List<PackFile> of package names contained in this repo. + * Should be an empty list if there are none. + */ + public abstract List<PackFile> listLocalPacks(); + /** * Does this database exist yet? * diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java index 859824d..fe219c6 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java @@ -508,4 +508,9 @@ boolean tryAgain(final long currLastModified) { return true; } } + + @Override + public List<PackFile> listLocalPacks() { + return new ArrayList<PackFile>(Arrays.asList(packList.get().packs)); + } }
-- 1.6.4.2