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
tags/v2.1.0.201209190230-r
Colby Ranger 11 years ago
parent
commit
b777d7797d

+ 13
- 0
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectRepresentation.java View File

@@ -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
- 0
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java View 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;

+ 3
- 1
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java View 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

Loading…
Cancel
Save