From b777d7797d6fbb36f8bfeb6b018c2d0cbf0477e0 Mon Sep 17 00:00:00 2001 From: Colby Ranger Date: Mon, 13 Aug 2012 15:54:06 -0700 Subject: [PATCH] Implement wasDeltaAttempted() in DfsObjectRepresentation. In DFS, everything is stored in a pack but only objects in a pack with source GC or UNREACHABLE_GARBAGE have had delta compression attempted. Expose the PackSource setter and getter on DfsPackDescription in order to implement wasDeltaAttempted. Change-Id: Ie949f321147ad870f1c3f23b552343bbbda32152 --- .../storage/dfs/DfsObjectRepresentation.java | 13 +++++++++++++ .../jgit/storage/dfs/DfsPackDescription.java | 18 ++++++++++++++++++ .../jgit/storage/dfs/InMemoryRepository.java | 4 +++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectRepresentation.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectRepresentation.java index 1b8e3a3d4..2b45ffa20 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectRepresentation.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectRepresentation.java @@ -43,7 +43,11 @@ package org.eclipse.jgit.storage.dfs; +import static org.eclipse.jgit.storage.dfs.DfsObjDatabase.PackSource.GC; +import static org.eclipse.jgit.storage.dfs.DfsObjDatabase.PackSource.UNREACHABLE_GARBAGE; + import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.storage.dfs.DfsObjDatabase.PackSource; import org.eclipse.jgit.storage.pack.ObjectToPack; import org.eclipse.jgit.storage.pack.StoredObjectRepresentation; @@ -87,4 +91,13 @@ class DfsObjectRepresentation extends StoredObjectRepresentation { public ObjectId getDeltaBase() { return baseId; } + + @Override + public boolean wasDeltaAttempted() { + if (pack != null) { + PackSource source = pack.getPackDescription().getPackSource(); + return source == GC || source == UNREACHABLE_GARBAGE; + } + return false; + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java index 1bd5a7827..6b90454b9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.storage.dfs; import java.util.Set; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.storage.dfs.DfsObjDatabase.PackSource; import org.eclipse.jgit.storage.pack.PackWriter; /** @@ -61,6 +62,8 @@ public class DfsPackDescription implements Comparable { private final String packName; + private PackSource packSource; + private long lastModified; private long packSize; @@ -114,6 +117,21 @@ public class DfsPackDescription implements Comparable { return name.substring(0, dot) + ".idx"; } + /** @return the source of the pack. */ + public PackSource getPackSource() { + return packSource; + } + + /** + * @param source + * the source of the pack. + * @return {@code this} + */ + public DfsPackDescription setPackSource(PackSource source) { + packSource = source; + return this; + } + /** @return time the pack was created, in milliseconds. */ public long getLastModified() { return lastModified; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java index 270f23fae..d1ceae00c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java @@ -76,8 +76,10 @@ public class InMemoryRepository extends DfsRepository { @Override protected DfsPackDescription newPack(PackSource source) { int id = packId.incrementAndGet(); - return new MemPack("pack-" + id + "-" + source.name(), + DfsPackDescription desc = new MemPack( + "pack-" + id + "-" + source.name(), getRepository().getDescription()); + return desc.setPackSource(source); } @Override