@ -468,14 +468,13 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
@Test
public void testDeltaStatistics ( ) throws Exception {
config . setDeltaCompress ( true ) ;
// TestRepository will close repo
FileRepository repo = createBareRepository ( ) ;
ArrayList < RevObject > blobs = new ArrayList < > ( ) ;
try ( TestRepository < FileRepository > testRepo = new TestRepository < > (
repo ) ) {
blobs . add ( testRepo . blob ( genDeltableData ( 1000 ) ) ) ;
blobs . add ( testRepo . blob ( genDeltableData ( 1005 ) ) ) ;
}
try ( PackWriter pw = new PackWriter ( repo ) ) {
NullProgressMonitor m = NullProgressMonitor . INSTANCE ;
pw . preparePack ( blobs . iterator ( ) ) ;
@ -486,6 +485,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
stats . byObjectType ( OBJ_BLOB ) . getDeltaBytes ( ) > 0 ) ;
}
}
}
// Generate consistent junk data for building files that delta well
private String genDeltableData ( int length ) {
@ -535,6 +535,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
@Test
public void testExclude ( ) throws Exception {
// TestRepository closes repo
FileRepository repo = createBareRepository ( ) ;
try ( TestRepository < FileRepository > testRepo = new TestRepository < > (
@ -568,8 +569,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
@Test
public void testShallowIsMinimalDepth1 ( ) throws Exception {
FileRepository repo = setupRepoForShallowFetch ( ) ;
try ( FileRepository repo = setupRepoForShallowFetch ( ) ) {
PackIndex idx = writeShallowPack ( repo , 1 , wants ( c2 ) , NONE , NONE ) ;
assertContent ( idx , Arrays . asList ( c2 . getId ( ) , c2 . getTree ( ) . getId ( ) ,
contentA . getId ( ) , contentB . getId ( ) ) ) ;
@ -579,11 +579,11 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
assertContent ( idx , Arrays . asList ( c5 . getId ( ) , c5 . getTree ( ) . getId ( ) ,
contentC . getId ( ) , contentD . getId ( ) , contentE . getId ( ) ) ) ;
}
}
@Test
public void testShallowIsMinimalDepth2 ( ) throws Exception {
FileRepository repo = setupRepoForShallowFetch ( ) ;
try ( FileRepository repo = setupRepoForShallowFetch ( ) ) {
PackIndex idx = writeShallowPack ( repo , 2 , wants ( c2 ) , NONE , NONE ) ;
assertContent ( idx ,
Arrays . asList ( c1 . getId ( ) , c2 . getId ( ) , c1 . getTree ( ) . getId ( ) ,
@ -591,75 +591,80 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
contentB . getId ( ) ) ) ;
// Client already has blobs A and B, verify those are not packed.
idx = writeShallowPack ( repo , 2 , wants ( c5 ) , haves ( c1 , c2 ) , shallows ( c1 ) ) ;
idx = writeShallowPack ( repo , 2 , wants ( c5 ) , haves ( c1 , c2 ) ,
shallows ( c1 ) ) ;
assertContent ( idx ,
Arrays . asList ( c4 . getId ( ) , c5 . getId ( ) , c4 . getTree ( ) . getId ( ) ,
c5 . getTree ( ) . getId ( ) , contentC . getId ( ) ,
contentD . getId ( ) , contentE . getId ( ) ) ) ;
}
}
@Test
public void testShallowFetchShallowParentDepth1 ( ) throws Exception {
FileRepository repo = setupRepoForShallowFetch ( ) ;
try ( FileRepository repo = setupRepoForShallowFetch ( ) ) {
PackIndex idx = writeShallowPack ( repo , 1 , wants ( c5 ) , NONE , NONE ) ;
assertContent ( idx ,
Arrays . asList ( c5 . getId ( ) , c5 . getTree ( ) . getId ( ) ,
assertContent ( idx , Arrays . asList ( c5 . getId ( ) , c5 . getTree ( ) . getId ( ) ,
contentA . getId ( ) , contentB . getId ( ) , contentC . getId ( ) ,
contentD . getId ( ) , contentE . getId ( ) ) ) ;
idx = writeShallowPack ( repo , 1 , wants ( c4 ) , haves ( c5 ) , shallows ( c5 ) ) ;
assertContent ( idx , Arrays . asList ( c4 . getId ( ) , c4 . getTree ( ) . getId ( ) ) ) ;
}
}
@Test
public void testShallowFetchShallowParentDepth2 ( ) throws Exception {
FileRepository repo = setupRepoForShallowFetch ( ) ;
try ( FileRepository repo = setupRepoForShallowFetch ( ) ) {
PackIndex idx = writeShallowPack ( repo , 2 , wants ( c5 ) , NONE , NONE ) ;
assertContent ( idx ,
Arrays . asList ( c4 . getId ( ) , c5 . getId ( ) , c4 . getTree ( ) . getId ( ) ,
c5 . getTree ( ) . getId ( ) , contentA . getId ( ) ,
contentB . getId ( ) , contentC . getId ( ) , contentD . getId ( ) ,
contentE . getId ( ) ) ) ;
contentB . getId ( ) , contentC . getId ( ) ,
contentD . getId ( ) , contentE . getId ( ) ) ) ;
idx = writeShallowPack ( repo , 2 , wants ( c3 ) , haves ( c4 , c5 ) , shallows ( c4 ) ) ;
idx = writeShallowPack ( repo , 2 , wants ( c3 ) , haves ( c4 , c5 ) ,
shallows ( c4 ) ) ;
assertContent ( idx , Arrays . asList ( c2 . getId ( ) , c3 . getId ( ) ,
c2 . getTree ( ) . getId ( ) , c3 . getTree ( ) . getId ( ) ) ) ;
}
}
@Test
public void testShallowFetchShallowAncestorDepth1 ( ) throws Exception {
FileRepository repo = setupRepoForShallowFetch ( ) ;
try ( FileRepository repo = setupRepoForShallowFetch ( ) ) {
PackIndex idx = writeShallowPack ( repo , 1 , wants ( c5 ) , NONE , NONE ) ;
assertContent ( idx ,
Arrays . asList ( c5 . getId ( ) , c5 . getTree ( ) . getId ( ) ,
assertContent ( idx , Arrays . asList ( c5 . getId ( ) , c5 . getTree ( ) . getId ( ) ,
contentA . getId ( ) , contentB . getId ( ) , contentC . getId ( ) ,
contentD . getId ( ) , contentE . getId ( ) ) ) ;
idx = writeShallowPack ( repo , 1 , wants ( c3 ) , haves ( c5 ) , shallows ( c5 ) ) ;
assertContent ( idx , Arrays . asList ( c3 . getId ( ) , c3 . getTree ( ) . getId ( ) ) ) ;
}
}
@Test
public void testShallowFetchShallowAncestorDepth2 ( ) throws Exception {
FileRepository repo = setupRepoForShallowFetch ( ) ;
try ( FileRepository repo = setupRepoForShallowFetch ( ) ) {
PackIndex idx = writeShallowPack ( repo , 2 , wants ( c5 ) , NONE , NONE ) ;
assertContent ( idx ,
Arrays . asList ( c4 . getId ( ) , c5 . getId ( ) , c4 . getTree ( ) . getId ( ) ,
c5 . getTree ( ) . getId ( ) , contentA . getId ( ) ,
contentB . getId ( ) , contentC . getId ( ) , contentD . getId ( ) ,
contentE . getId ( ) ) ) ;
contentB . getId ( ) , contentC . getId ( ) ,
contentD . getId ( ) , contentE . getId ( ) ) ) ;
idx = writeShallowPack ( repo , 2 , wants ( c2 ) , haves ( c4 , c5 ) , shallows ( c4 ) ) ;
idx = writeShallowPack ( repo , 2 , wants ( c2 ) , haves ( c4 , c5 ) ,
shallows ( c4 ) ) ;
assertContent ( idx , Arrays . asList ( c1 . getId ( ) , c2 . getId ( ) ,
c1 . getTree ( ) . getId ( ) , c2 . getTree ( ) . getId ( ) ) ) ;
}
}
private FileRepository setupRepoForShallowFetch ( ) throws Exception {
FileRepository repo = createBareRepository ( ) ;
// TestRepository will close the repo, but we need to return an open
// one!
repo . incrementOpen ( ) ;
try ( TestRepository < Repository > r = new TestRepository < > ( repo ) ) {
BranchBuilder bb = r . branch ( "refs/heads/master" ) ;
contentA = r . blob ( "A" ) ;