Browse Source

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
stable-2.1
Colby Ranger 12 years ago
parent
commit
b777d7797d
  1. 13
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectRepresentation.java
  2. 18
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java
  3. 4
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java

13
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;
}
}

18
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;

4
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

Loading…
Cancel
Save