summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2013-03-12 17:56:48 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2013-03-12 17:56:48 -0400
commite175daf123f67e31f85466be595810bbfccc08e1 (patch)
treef1f8c1cc427d07f64399fd7e33d3417ed824a50f
parent7e229c75c168dbff5f2b5470ddfcce86467fe6c5 (diff)
parentea5eef912a66b06dc59320655bd8c31c14507465 (diff)
downloadjgit-e175daf123f67e31f85466be595810bbfccc08e1.tar.gz
jgit-e175daf123f67e31f85466be595810bbfccc08e1.zip
Merge "Cluster UNREACHABLE_GARBAGE packs at the end of the search list"
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java9
2 files changed, 20 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java
index 316395535e..da67221701 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java
@@ -65,7 +65,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
/** Sources for a pack file. */
public static enum PackSource {
/** The pack is created by ObjectInserter due to local activity. */
- INSERT,
+ INSERT(0),
/**
* The pack is created by PackParser due to a network event.
@@ -76,7 +76,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
* storage layout preferred by this version. Received packs are likely
* to be either compacted or garbage collected in the future.
*/
- RECEIVE,
+ RECEIVE(0),
/**
* Pack was created by Git garbage collection by this implementation.
@@ -87,7 +87,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
*
* @see DfsGarbageCollector
*/
- GC,
+ GC(1),
/**
* The pack was created by compacting multiple packs together.
@@ -98,7 +98,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
*
* @see DfsPackCompactor
*/
- COMPACT,
+ COMPACT(1),
/**
* Pack was created by Git garbage collection.
@@ -107,7 +107,13 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
* last GC pass. It is retained in a new pack until it is safe to prune
* these objects from the repository.
*/
- UNREACHABLE_GARBAGE;
+ UNREACHABLE_GARBAGE(2);
+
+ final int category;
+
+ PackSource(int category) {
+ this.category = category;
+ }
}
private final AtomicReference<PackList> packList;
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 2aa81d9a25..746a64aed5 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
@@ -303,6 +303,15 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
* the other pack.
*/
public int compareTo(DfsPackDescription b) {
+ // Cluster by PackSource, pushing UNREACHABLE_GARBAGE to the end.
+ PackSource as = getPackSource();
+ PackSource bs = b.getPackSource();
+ if (as != null && bs != null) {
+ int cmp = as.category - bs.category;
+ if (cmp != 0)
+ return cmp;
+ }
+
// Newer packs should sort first.
int cmp = Long.signum(b.getLastModified() - getLastModified());
if (cmp != 0)