diff options
author | Shawn Pearce <spearce@spearce.org> | 2015-10-10 12:04:24 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2015-10-10 12:04:25 -0400 |
commit | 7673d84624c98a3e294c64367db0a54ea0a65a03 (patch) | |
tree | 43025ba767bd401ef311a01e5e170ac71ae5741c /org.eclipse.jgit.test | |
parent | a406ebf4018f2912f90aa2473c522556a742d015 (diff) | |
parent | 2524157d3d79ef6f418dc916ac6c0140135d1eec (diff) | |
download | jgit-7673d84624c98a3e294c64367db0a54ea0a65a03.tar.gz jgit-7673d84624c98a3e294c64367db0a54ea0a65a03.zip |
Merge "Limit the range of commits for which bitmaps are created."
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java index bbd41237e2..4f6d249c5f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java @@ -85,6 +85,7 @@ public class GcBasicPackingTest extends GcTestCase { assertEquals(4, stats.numberOfLooseObjects); assertEquals(0, stats.numberOfPackedObjects); assertEquals(0, stats.numberOfPackFiles); + assertEquals(0, stats.numberOfBitmaps); } @Theory @@ -102,6 +103,7 @@ public class GcBasicPackingTest extends GcTestCase { assertEquals(0, stats.numberOfLooseObjects); assertEquals(8, stats.numberOfPackedObjects); assertEquals(1, stats.numberOfPackFiles); + assertEquals(2, stats.numberOfBitmaps); } @Theory @@ -118,6 +120,7 @@ public class GcBasicPackingTest extends GcTestCase { assertEquals(0, stats.numberOfLooseObjects); assertEquals(4, stats.numberOfPackedObjects); assertEquals(1, stats.numberOfPackFiles); + assertEquals(1, stats.numberOfBitmaps); // Do the gc again and check that it hasn't changed anything gc.gc(); @@ -125,6 +128,7 @@ public class GcBasicPackingTest extends GcTestCase { assertEquals(0, stats.numberOfLooseObjects); assertEquals(4, stats.numberOfPackedObjects); assertEquals(1, stats.numberOfPackFiles); + assertEquals(1, stats.numberOfBitmaps); } @Theory @@ -143,6 +147,7 @@ public class GcBasicPackingTest extends GcTestCase { assertEquals(0, stats.numberOfLooseObjects); assertEquals(8, stats.numberOfPackedObjects); assertEquals(2, stats.numberOfPackFiles); + assertEquals(1, stats.numberOfBitmaps); } @Theory @@ -220,6 +225,74 @@ public class GcBasicPackingTest extends GcTestCase { } + @Test + public void testCommitRangeForBitmaps() throws Exception { + BranchBuilder bb1 = tr.branch("refs/heads/master"); + bb1.commit().message("A1").add("A1", "A1").create(); + bb1.commit().message("B1").add("B1", "B1").create(); + bb1.commit().message("C1").add("C1", "C1").create(); + BranchBuilder bb2 = tr.branch("refs/heads/working"); + bb2.commit().message("A2").add("A2", "A2").create(); + bb2.commit().message("B2").add("B2", "B2").create(); + bb2.commit().message("C2").add("C2", "C2").create(); + + // Consider all commits. Since history isn't deep all commits are + // selected. + configureGcRange(gc, -1); + gc.gc(); + assertEquals(6, gc.getStatistics().numberOfBitmaps); + + // Range==0 means don't examine commit history, create bitmaps only for + // branch tips, C1 & C2. + configureGcRange(gc, 0); + gc.gc(); + assertEquals(2, gc.getStatistics().numberOfBitmaps); + + // Consider only the most recent commit (C2, which is also a branch + // tip). + configureGcRange(gc, 1); + gc.gc(); + assertEquals(2, gc.getStatistics().numberOfBitmaps); + + // Consider only the two most recent commits, C2 & B2. C1 gets included + // too since it is a branch tip. + configureGcRange(gc, 2); + gc.gc(); + assertEquals(3, gc.getStatistics().numberOfBitmaps); + + // Consider C2 & B2 & A2. C1 gets included too since it is a branch tip. + configureGcRange(gc, 3); + gc.gc(); + assertEquals(4, gc.getStatistics().numberOfBitmaps); + + // Consider C2 & B2 & A2 & C1. + configureGcRange(gc, 4); + gc.gc(); + assertEquals(4, gc.getStatistics().numberOfBitmaps); + + // Consider C2 & B2 & A2 & C1 & B1. + configureGcRange(gc, 5); + gc.gc(); + assertEquals(5, gc.getStatistics().numberOfBitmaps); + + // Consider all six commits. + configureGcRange(gc, 6); + gc.gc(); + assertEquals(6, gc.getStatistics().numberOfBitmaps); + + // Input is out of range but should be capped to the total number of + // commits. + configureGcRange(gc, 1000); + gc.gc(); + assertEquals(6, gc.getStatistics().numberOfBitmaps); + } + + private void configureGcRange(GC myGc, int range) { + PackConfig pconfig = new PackConfig(repo); + pconfig.setBitmapCommitRange(range); + myGc.setPackConfig(pconfig); + } + private void configureGc(GC myGc, boolean aggressive) { PackConfig pconfig = new PackConfig(repo); if (aggressive) { |