@ -188,6 +188,8 @@ public class PackWriter {
private boolean ignoreMissingUninteresting = true ;
private boolean ignoreMissingUninteresting = true ;
private boolean pruneCurrentObjectList ;
/ * *
/ * *
* Create writer for specified repository .
* Create writer for specified repository .
* < p >
* < p >
@ -526,16 +528,7 @@ public class PackWriter {
* /
* /
public boolean willInclude ( final AnyObjectId id ) throws IOException {
public boolean willInclude ( final AnyObjectId id ) throws IOException {
ObjectToPack obj = objectsMap . get ( id ) ;
ObjectToPack obj = objectsMap . get ( id ) ;
if ( obj ! = null & & ! obj . isEdge ( ) )
return obj ! = null & & ! obj . isEdge ( ) ;
return true ;
Set < ObjectId > toFind = Collections . singleton ( id . toObjectId ( ) ) ;
for ( CachedPack pack : cachedPacks ) {
if ( pack . hasObject ( toFind ) . contains ( id ) )
return true ;
}
return false ;
}
}
/ * *
/ * *
@ -639,7 +632,10 @@ public class PackWriter {
if ( writeMonitor = = null )
if ( writeMonitor = = null )
writeMonitor = NullProgressMonitor . INSTANCE ;
writeMonitor = NullProgressMonitor . INSTANCE ;
if ( ( reuseDeltas | | config . isReuseObjects ( ) ) & & reuseSupport ! = null )
if ( reuseSupport ! = null & & (
reuseDeltas
| | config . isReuseObjects ( )
| | ! cachedPacks . isEmpty ( ) ) )
searchForReuse ( compressMonitor ) ;
searchForReuse ( compressMonitor ) ;
if ( config . isDeltaCompress ( ) )
if ( config . isDeltaCompress ( ) )
searchForDeltas ( compressMonitor ) ;
searchForDeltas ( compressMonitor ) ;
@ -715,8 +711,12 @@ public class PackWriter {
cnt + = list . size ( ) ;
cnt + = list . size ( ) ;
long start = System . currentTimeMillis ( ) ;
long start = System . currentTimeMillis ( ) ;
monitor . beginTask ( JGitText . get ( ) . searchForReuse , cnt ) ;
monitor . beginTask ( JGitText . get ( ) . searchForReuse , cnt ) ;
for ( List < ObjectToPack > list : objectsLists )
for ( List < ObjectToPack > list : objectsLists ) {
pruneCurrentObjectList = false ;
reuseSupport . selectObjectRepresentation ( this , monitor , list ) ;
reuseSupport . selectObjectRepresentation ( this , monitor , list ) ;
if ( pruneCurrentObjectList )
pruneEdgesFromObjectList ( list ) ;
}
monitor . endTask ( ) ;
monitor . endTask ( ) ;
stats . timeSearchingForReuse = System . currentTimeMillis ( ) - start ;
stats . timeSearchingForReuse = System . currentTimeMillis ( ) - start ;
}
}
@ -1324,7 +1324,6 @@ public class PackWriter {
for ( RevObject obj : haveObjs )
for ( RevObject obj : haveObjs )
walker . markUninteresting ( obj ) ;
walker . markUninteresting ( obj ) ;
int typesToPrune = 0 ;
final int maxBases = config . getDeltaSearchWindowSize ( ) ;
final int maxBases = config . getDeltaSearchWindowSize ( ) ;
Set < RevTree > baseTrees = new HashSet < RevTree > ( ) ;
Set < RevTree > baseTrees = new HashSet < RevTree > ( ) ;
BlockList < RevCommit > commits = new BlockList < RevCommit > ( ) ;
BlockList < RevCommit > commits = new BlockList < RevCommit > ( ) ;
@ -1388,15 +1387,6 @@ public class PackWriter {
}
}
commits = null ;
commits = null ;
for ( CachedPack p : cachedPacks ) {
for ( ObjectId d : p . hasObject ( objectsLists [ Constants . OBJ_COMMIT ] ) ) {
if ( baseTrees . size ( ) < = maxBases )
baseTrees . add ( walker . lookupCommit ( d ) . getTree ( ) ) ;
objectsMap . get ( d ) . setEdge ( ) ;
typesToPrune | = 1 < < Constants . OBJ_COMMIT ;
}
}
BaseSearch bases = new BaseSearch ( countingMonitor , baseTrees , //
BaseSearch bases = new BaseSearch ( countingMonitor , baseTrees , //
objectsMap , edgeObjects , reader ) ;
objectsMap , edgeObjects , reader ) ;
RevObject o ;
RevObject o ;
@ -1413,39 +1403,13 @@ public class PackWriter {
countingMonitor . update ( 1 ) ;
countingMonitor . update ( 1 ) ;
}
}
for ( CachedPack p : cachedPacks ) {
for ( ObjectId d : p . hasObject ( objectsLists [ Constants . OBJ_TREE ] ) ) {
objectsMap . get ( d ) . setEdge ( ) ;
typesToPrune | = 1 < < Constants . OBJ_TREE ;
}
for ( ObjectId d : p . hasObject ( objectsLists [ Constants . OBJ_BLOB ] ) ) {
objectsMap . get ( d ) . setEdge ( ) ;
typesToPrune | = 1 < < Constants . OBJ_BLOB ;
}
for ( ObjectId d : p . hasObject ( objectsLists [ Constants . OBJ_TAG ] ) ) {
objectsMap . get ( d ) . setEdge ( ) ;
typesToPrune | = 1 < < Constants . OBJ_TAG ;
}
}
if ( typesToPrune ! = 0 ) {
pruneObjectList ( typesToPrune , Constants . OBJ_COMMIT ) ;
pruneObjectList ( typesToPrune , Constants . OBJ_TREE ) ;
pruneObjectList ( typesToPrune , Constants . OBJ_BLOB ) ;
pruneObjectList ( typesToPrune , Constants . OBJ_TAG ) ;
}
for ( CachedPack pack : cachedPacks )
for ( CachedPack pack : cachedPacks )
countingMonitor . update ( ( int ) pack . getObjectCount ( ) ) ;
countingMonitor . update ( ( int ) pack . getObjectCount ( ) ) ;
countingMonitor . endTask ( ) ;
countingMonitor . endTask ( ) ;
stats . timeCounting = System . currentTimeMillis ( ) - countingStart ;
stats . timeCounting = System . currentTimeMillis ( ) - countingStart ;
}
}
private void pruneObjectList ( int typesToPrune , int typeCode ) {
private static void pruneEdgesFromObjectList ( List < ObjectToPack > list ) {
if ( ( typesToPrune & ( 1 < < typeCode ) ) = = 0 )
return ;
final List < ObjectToPack > list = objectsLists [ typeCode ] ;
final int size = list . size ( ) ;
final int size = list . size ( ) ;
int src = 0 ;
int src = 0 ;
int dst = 0 ;
int dst = 0 ;
@ -1544,6 +1508,23 @@ public class PackWriter {
* /
* /
public void select ( ObjectToPack otp , StoredObjectRepresentation next ) {
public void select ( ObjectToPack otp , StoredObjectRepresentation next ) {
int nFmt = next . getFormat ( ) ;
int nFmt = next . getFormat ( ) ;
if ( ! cachedPacks . isEmpty ( ) ) {
if ( otp . isEdge ( ) )
return ;
if ( ( nFmt = = PACK_WHOLE ) | ( nFmt = = PACK_DELTA ) ) {
for ( CachedPack pack : cachedPacks ) {
if ( pack . hasObject ( otp , next ) ) {
otp . setEdge ( ) ;
otp . clearDeltaBase ( ) ;
otp . clearReuseAsIs ( ) ;
pruneCurrentObjectList = true ;
return ;
}
}
}
}
int nWeight ;
int nWeight ;
if ( otp . isReuseAsIs ( ) ) {
if ( otp . isReuseAsIs ( ) ) {
// We've already chosen to reuse a packed form, if next
// We've already chosen to reuse a packed form, if next