@ -233,7 +233,9 @@ public class PackWriter implements AutoCloseable {
private List < CachedPack > cachedPacks = new ArrayList < > ( 2 ) ;
private List < CachedPack > cachedPacks = new ArrayList < > ( 2 ) ;
private Set < ObjectId > tagTargets = Collections . emptySet ( ) ;
private Set < ObjectId > tagTargets = NONE ;
private Set < ? extends ObjectId > excludeFromBitmapSelection = NONE ;
private ObjectIdSet [ ] excludeInPacks ;
private ObjectIdSet [ ] excludeInPacks ;
@ -712,8 +714,7 @@ public class PackWriter implements AutoCloseable {
public void preparePack ( ProgressMonitor countingMonitor ,
public void preparePack ( ProgressMonitor countingMonitor ,
@NonNull Set < ? extends ObjectId > want ,
@NonNull Set < ? extends ObjectId > want ,
@NonNull Set < ? extends ObjectId > have ) throws IOException {
@NonNull Set < ? extends ObjectId > have ) throws IOException {
preparePack ( countingMonitor ,
preparePack ( countingMonitor , want , have , NONE , NONE ) ;
want , have , Collections . < ObjectId > emptySet ( ) ) ;
}
}
/ * *
/ * *
@ -721,9 +722,9 @@ public class PackWriter implements AutoCloseable {
* < p >
* < p >
* Like { @link # preparePack ( ProgressMonitor , Set , Set ) } but also allows
* Like { @link # preparePack ( ProgressMonitor , Set , Set ) } but also allows
* specifying commits that should not be walked past ( "shallow" commits ) .
* specifying commits that should not be walked past ( "shallow" commits ) .
* The caller is responsible for filtering out commits that should not
* The caller is responsible for filtering out commits that should not be
* be shallow any more ( "unshallow" commits as in { @link # setShallowPack } )
* shallow any more ( "unshallow" commits as in { @link # setShallowPack } ) from
* from the shallow set .
* the shallow set .
*
*
* @param countingMonitor
* @param countingMonitor
* progress during object enumeration .
* progress during object enumeration .
@ -731,27 +732,67 @@ public class PackWriter implements AutoCloseable {
* objects of interest , ancestors of which will be included in
* objects of interest , ancestors of which will be included in
* the pack . Must not be { @code null } .
* the pack . Must not be { @code null } .
* @param have
* @param have
* objects whose ancestors ( up to and including
* objects whose ancestors ( up to and including { @code shallow }
* { @code shallow } commits ) do not need to be included in the
* commits ) do not need to be included in the pack because they
* pack because they are already available from elsewhere .
* are already available from elsewhere . Must not be
* Must not be { @code null } .
* { @code null } .
* @param shallow
* @param shallow
* commits indicating the boundary of the history marked with
* commits indicating the boundary of the history marked with
* { @code have } . Shallow commits have parents but those
* { @code have } . Shallow commits have parents but those parents
* parents are considered not to be already available .
* are considered not to be already available . Parents of
* Parents of { @code shallow } commits and earlier generations
* { @code shallow } commits and earlier generations will be
* will be included in the pack if requested by { @code want } .
* included in the pack if requested by { @code want } . Must not be
* Must not be { @code null } .
* { @code null } .
* @throws IOException
* @throws IOException
* an I / O problem occured while reading objects .
* an I / O problem occur red while reading objects .
* /
* /
public void preparePack ( ProgressMonitor countingMonitor ,
public void preparePack ( ProgressMonitor countingMonitor ,
@NonNull Set < ? extends ObjectId > want ,
@NonNull Set < ? extends ObjectId > want ,
@NonNull Set < ? extends ObjectId > have ,
@NonNull Set < ? extends ObjectId > have ,
@NonNull Set < ? extends ObjectId > shallow ) throws IOException {
@NonNull Set < ? extends ObjectId > shallow ) throws IOException {
preparePack ( countingMonitor , want , have , shallow , NONE ) ;
}
/ * *
* Prepare the list of objects to be written to the pack stream .
* < p >
* Like { @link # preparePack ( ProgressMonitor , Set , Set ) } but also allows
* specifying commits that should not be walked past ( "shallow" commits ) .
* The caller is responsible for filtering out commits that should not be
* shallow any more ( "unshallow" commits as in { @link # setShallowPack } ) from
* the shallow set .
*
* @param countingMonitor
* progress during object enumeration .
* @param want
* objects of interest , ancestors of which will be included in
* the pack . Must not be { @code null } .
* @param have
* objects whose ancestors ( up to and including { @code shallow }
* commits ) do not need to be included in the pack because they
* are already available from elsewhere . Must not be
* { @code null } .
* @param shallow
* commits indicating the boundary of the history marked with
* { @code have } . Shallow commits have parents but those parents
* are considered not to be already available . Parents of
* { @code shallow } commits and earlier generations will be
* included in the pack if requested by { @code want } . Must not be
* { @code null } .
* @param noBitmaps
* collection of objects to be excluded from bitmap commit
* selection .
* @throws IOException
* an I / O problem occurred while reading objects .
* /
public void preparePack ( ProgressMonitor countingMonitor ,
@NonNull Set < ? extends ObjectId > want ,
@NonNull Set < ? extends ObjectId > have ,
@NonNull Set < ? extends ObjectId > shallow ,
@NonNull Set < ? extends ObjectId > noBitmaps ) throws IOException {
try ( ObjectWalk ow = getObjectWalk ( ) ) {
try ( ObjectWalk ow = getObjectWalk ( ) ) {
ow . assumeShallow ( shallow ) ;
ow . assumeShallow ( shallow ) ;
preparePack ( countingMonitor , ow , want , have ) ;
preparePack ( countingMonitor , ow , want , have , noBitmaps ) ;
}
}
}
}
@ -784,13 +825,17 @@ public class PackWriter implements AutoCloseable {
* points of graph traversal ) . Pass { @link # NONE } if all objects
* points of graph traversal ) . Pass { @link # NONE } if all objects
* reachable from { @code want } are desired , such as when serving
* reachable from { @code want } are desired , such as when serving
* a clone .
* a clone .
* @param noBitmaps
* collection of objects to be excluded from bitmap commit
* selection .
* @throws IOException
* @throws IOException
* when some I / O problem occur during reading objects .
* when some I / O problem occur during reading objects .
* /
* /
public void preparePack ( ProgressMonitor countingMonitor ,
public void preparePack ( ProgressMonitor countingMonitor ,
@NonNull ObjectWalk walk ,
@NonNull ObjectWalk walk ,
@NonNull Set < ? extends ObjectId > interestingObjects ,
@NonNull Set < ? extends ObjectId > interestingObjects ,
@NonNull Set < ? extends ObjectId > uninterestingObjects )
@NonNull Set < ? extends ObjectId > uninterestingObjects ,
@NonNull Set < ? extends ObjectId > noBitmaps )
throws IOException {
throws IOException {
if ( countingMonitor = = null )
if ( countingMonitor = = null )
countingMonitor = NullProgressMonitor . INSTANCE ;
countingMonitor = NullProgressMonitor . INSTANCE ;
@ -798,7 +843,7 @@ public class PackWriter implements AutoCloseable {
throw new IllegalArgumentException (
throw new IllegalArgumentException (
JGitText . get ( ) . shallowPacksRequireDepthWalk ) ;
JGitText . get ( ) . shallowPacksRequireDepthWalk ) ;
findObjectsToPack ( countingMonitor , walk , interestingObjects ,
findObjectsToPack ( countingMonitor , walk , interestingObjects ,
uninterestingObjects ) ;
uninterestingObjects , noBitmaps ) ;
}
}
/ * *
/ * *
@ -965,8 +1010,9 @@ public class PackWriter implements AutoCloseable {
/ * *
/ * *
* Write the prepared pack to the supplied stream .
* Write the prepared pack to the supplied stream .
* < p >
* < p >
* Called after { @link # preparePack ( ProgressMonitor , ObjectWalk , Set , Set ) }
* Called after
* or { @link # preparePack ( ProgressMonitor , Set , Set ) } .
* { @link # preparePack ( ProgressMonitor , ObjectWalk , Set , Set , Set ) } or
* { @link # preparePack ( ProgressMonitor , Set , Set ) } .
* < p >
* < p >
* Performs delta search if enabled and writes the pack stream .
* Performs delta search if enabled and writes the pack stream .
* < p >
* < p >
@ -1652,12 +1698,14 @@ public class PackWriter implements AutoCloseable {
private void findObjectsToPack ( @NonNull ProgressMonitor countingMonitor ,
private void findObjectsToPack ( @NonNull ProgressMonitor countingMonitor ,
@NonNull ObjectWalk walker , @NonNull Set < ? extends ObjectId > want ,
@NonNull ObjectWalk walker , @NonNull Set < ? extends ObjectId > want ,
@NonNull Set < ? extends ObjectId > have ) throws IOException {
@NonNull Set < ? extends ObjectId > have ,
@NonNull Set < ? extends ObjectId > noBitmaps ) throws IOException {
final long countingStart = System . currentTimeMillis ( ) ;
final long countingStart = System . currentTimeMillis ( ) ;
beginPhase ( PackingPhase . COUNTING , countingMonitor , ProgressMonitor . UNKNOWN ) ;
beginPhase ( PackingPhase . COUNTING , countingMonitor , ProgressMonitor . UNKNOWN ) ;
stats . interestingObjects = Collections . unmodifiableSet ( new HashSet < ObjectId > ( want ) ) ;
stats . interestingObjects = Collections . unmodifiableSet ( new HashSet < ObjectId > ( want ) ) ;
stats . uninterestingObjects = Collections . unmodifiableSet ( new HashSet < ObjectId > ( have ) ) ;
stats . uninterestingObjects = Collections . unmodifiableSet ( new HashSet < ObjectId > ( have ) ) ;
excludeFromBitmapSelection = noBitmaps ;
canBuildBitmaps = config . isBuildBitmaps ( )
canBuildBitmaps = config . isBuildBitmaps ( )
& & ! shallowPack
& & ! shallowPack
@ -2070,8 +2118,8 @@ public class PackWriter implements AutoCloseable {
PackWriterBitmapPreparer bitmapPreparer = new PackWriterBitmapPreparer (
PackWriterBitmapPreparer bitmapPreparer = new PackWriterBitmapPreparer (
reader , writeBitmaps , pm , stats . interestingObjects , config ) ;
reader , writeBitmaps , pm , stats . interestingObjects , config ) ;
Collection < PackWriterBitmapPreparer . BitmapCommit > selectedCommits =
Collection < PackWriterBitmapPreparer . BitmapCommit > selectedCommits = bitmapPreparer
bitmapPreparer . selectCommits ( numCommits ) ;
. selectCommits ( numCommits , excludeFromBitmapSelection ) ;
beginPhase ( PackingPhase . BUILDING_BITMAPS , pm , selectedCommits . size ( ) ) ;
beginPhase ( PackingPhase . BUILDING_BITMAPS , pm , selectedCommits . size ( ) ) ;