]> source.dussan.org Git - jgit.git/commitdiff
Implement wasDeltaAttempted() in DfsObjectRepresentation. 13/7213/1
authorColby Ranger <cranger@google.com>
Mon, 13 Aug 2012 22:54:06 +0000 (15:54 -0700)
committerColby Ranger <cranger@google.com>
Mon, 13 Aug 2012 22:54:06 +0000 (15:54 -0700)
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

org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectRepresentation.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java

index 1b8e3a3d42b739cf0b13b3165575915a6a864caf..2b45ffa20dae94d2bf33d66cf9503fb2bc6e6223 100644 (file)
 
 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;
+       }
 }
index 1bd5a7827153b8c751effd67d74283c093d5e604..6b90454b971a76c9c8c988a2c8473e11c9916144 100644 (file)
@@ -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;
index 270f23faec4d03c69b93d531eddbd30694976d0b..d1ceae00c9587b94d7946183b427aad439c779ef 100644 (file)
@@ -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