aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColby Ranger2012-08-13 18:54:06 (EDT)
committerColby Ranger2012-08-13 18:54:06 (EDT)
commitb777d7797d6fbb36f8bfeb6b018c2d0cbf0477e0 (patch)
treece13198364e39b7244120a5d63d097a9e87df4d4
parentb77ba049762e4ea3aadb756dad1d06c859bb3fe3 (diff)
downloadjgit-b777d7797d6fbb36f8bfeb6b018c2d0cbf0477e0.zip
jgit-b777d7797d6fbb36f8bfeb6b018c2d0cbf0477e0.tar.gz
jgit-b777d7797d6fbb36f8bfeb6b018c2d0cbf0477e0.tar.bz2
Implement wasDeltaAttempted() in DfsObjectRepresentation.refs/changes/13/7213/1
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
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectRepresentation.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java4
3 files changed, 34 insertions, 1 deletions
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 1b8e3a3..2b45ffa 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 1bd5a78..6b90454 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<DfsPackDescription> {
private final String packName;
+ private PackSource packSource;
+
private long lastModified;
private long packSize;
@@ -114,6 +117,21 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
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 270f23f..d1ceae0 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