From 8f46ee4870d0a49fcce1d0cb2b8e2aee9aaafee1 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 23 Jun 2010 17:44:13 -0700 Subject: [PATCH] Remove Repository.toFile(ObjectId) Not every type of Repository will be able to map an ObjectId into a local file system path that stores that object's file contents. Heck, its not even true for the FileRepository, as an object can be stored in a pack file and not in its loose format. Remove this from our public API, it was a mistake to publish it. Change-Id: I20d1b8c39104023936e6d46a5b0d7ef39ff118e8 Signed-off-by: Shawn O. Pearce --- .../tst/org/eclipse/jgit/lib/T0003_Basic.java | 6 ++++-- .../src/org/eclipse/jgit/lib/FileRepository.java | 14 -------------- .../src/org/eclipse/jgit/lib/Repository.java | 12 ------------ 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java index 4e87fd624..c770d605d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java @@ -365,8 +365,10 @@ public void test009_CreateCommitOldFormat() throws IOException { assertEquals(cmtid, c.getCommitId()); // Verify the commit we just wrote is in the correct format. - final XInputStream xis = new XInputStream(new FileInputStream(db - .toFile(cmtid))); + ObjectDatabase odb = db.getObjectDatabase(); + assertTrue("is ObjectDirectory", odb instanceof ObjectDirectory); + final XInputStream xis = new XInputStream(new FileInputStream( + ((ObjectDirectory) odb).fileFor(cmtid))); try { assertEquals(0x78, xis.readUInt8()); assertEquals(0x9c, xis.readUInt8()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileRepository.java index 32f516f7d..86ae5fada 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileRepository.java @@ -380,20 +380,6 @@ public FileBasedConfig getConfig() { return repoConfig; } - /** - * Construct a filename where the loose object having a specified SHA-1 - * should be stored. If the object is stored in a shared repository the path - * to the alternative repo will be returned. If the object is not yet store - * a usable path in this repo will be returned. It is assumed that callers - * will look for objects in a pack first. - * - * @param objectId - * @return suggested file name - */ - public File toFile(final AnyObjectId objectId) { - return objectDatabase.fileFor(objectId); - } - /** * Objects known to exist but not expressed by {@link #getAllRefs()}. *

diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index 400cae43d..09411a453 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -173,18 +173,6 @@ public FS getFS() { return fs; } - /** - * Construct a filename where the loose object having a specified SHA-1 - * should be stored. If the object is stored in a shared repository the path - * to the alternative repo will be returned. If the object is not yet store - * a usable path in this repo will be returned. It is assumed that callers - * will look for objects in a pack first. - * - * @param objectId - * @return suggested file name - */ - public abstract File toFile(AnyObjectId objectId); - /** * @param objectId * @return true if the specified object is stored in this repo or any of the