@ -3,6 +3,7 @@
* Copyright ( C ) 2008 - 2009 , Google Inc .
* Copyright ( C ) 2008 - 2009 , Google Inc .
* Copyright ( C ) 2009 , Matthias Sohn < matthias . sohn @sap.com >
* Copyright ( C ) 2009 , Matthias Sohn < matthias . sohn @sap.com >
* Copyright ( C ) 2008 , Robin Rosenberg < robin . rosenberg @dewire.com >
* Copyright ( C ) 2008 , Robin Rosenberg < robin . rosenberg @dewire.com >
* Copyright ( C ) 2009 , Sasa Zivkov < sasa . zivkov @sap.com >
* Copyright ( C ) 2008 , Shawn O . Pearce < spearce @spearce.org >
* Copyright ( C ) 2008 , Shawn O . Pearce < spearce @spearce.org >
* and other copyright owners as documented in the project ' s IP log .
* and other copyright owners as documented in the project ' s IP log .
*
*
@ -53,9 +54,10 @@ import java.io.InputStream;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.Collection ;
import java.util.Collection ;
import java.util.Collections ;
import java.util.Collections ;
import java.util.HashSet ;
import java.util.HashMap ;
import java.util.LinkedHashMap ;
import java.util.LinkedHashMap ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.Set ;
import java.util.Set ;
import org.eclipse.jgit.errors.MissingBundlePrerequisiteException ;
import org.eclipse.jgit.errors.MissingBundlePrerequisiteException ;
@ -84,7 +86,7 @@ class BundleFetchConnection extends BaseFetchConnection {
InputStream bin ;
InputStream bin ;
final Set < ObjectId > prereqs = new HashSet < ObjectId > ( ) ;
final Map < ObjectId , String > prereqs = new HashMap < ObjectId , String > ( ) ;
private String lockMessage ;
private String lockMessage ;
@ -129,7 +131,11 @@ class BundleFetchConnection extends BaseFetchConnection {
break ;
break ;
if ( line . charAt ( 0 ) = = '-' ) {
if ( line . charAt ( 0 ) = = '-' ) {
prereqs . add ( ObjectId . fromString ( line . substring ( 1 , 41 ) ) ) ;
ObjectId id = ObjectId . fromString ( line . substring ( 1 , 41 ) ) ;
String shortDesc = null ;
if ( line . length ( ) > 42 )
shortDesc = line . substring ( 42 ) ;
prereqs . put ( id , shortDesc ) ;
continue ;
continue ;
}
}
@ -208,9 +214,10 @@ class BundleFetchConnection extends BaseFetchConnection {
final RevFlag PREREQ = rw . newFlag ( "PREREQ" ) ;
final RevFlag PREREQ = rw . newFlag ( "PREREQ" ) ;
final RevFlag SEEN = rw . newFlag ( "SEEN" ) ;
final RevFlag SEEN = rw . newFlag ( "SEEN" ) ;
final List < ObjectId > missing = new ArrayList < ObjectId > ( ) ;
final Map < ObjectId , String > missing = new HashMap < ObjectId , String > ( ) ;
final List < RevObject > commits = new ArrayList < RevObject > ( ) ;
final List < RevObject > commits = new ArrayList < RevObject > ( ) ;
for ( final ObjectId p : prereqs ) {
for ( final Map . Entry < ObjectId , String > e : prereqs . entrySet ( ) ) {
ObjectId p = e . getKey ( ) ;
try {
try {
final RevCommit c = rw . parseCommit ( p ) ;
final RevCommit c = rw . parseCommit ( p ) ;
if ( ! c . has ( PREREQ ) ) {
if ( ! c . has ( PREREQ ) ) {
@ -218,7 +225,7 @@ class BundleFetchConnection extends BaseFetchConnection {
commits . add ( c ) ;
commits . add ( c ) ;
}
}
} catch ( MissingObjectException notFound ) {
} catch ( MissingObjectException notFound ) {
missing . add ( p ) ;
missing . put ( p , e . getValue ( ) ) ;
} catch ( IOException err ) {
} catch ( IOException err ) {
throw new TransportException ( transport . uri , "Cannot read commit "
throw new TransportException ( transport . uri , "Cannot read commit "
+ p . name ( ) , err ) ;
+ p . name ( ) , err ) ;
@ -252,7 +259,7 @@ class BundleFetchConnection extends BaseFetchConnection {
if ( remaining > 0 ) {
if ( remaining > 0 ) {
for ( final RevObject o : commits ) {
for ( final RevObject o : commits ) {
if ( ! o . has ( SEEN ) )
if ( ! o . has ( SEEN ) )
missing . add ( o ) ;
missing . put ( o , prereqs . get ( o ) ) ;
}
}
throw new MissingBundlePrerequisiteException ( transport . uri , missing ) ;
throw new MissingBundlePrerequisiteException ( transport . uri , missing ) ;
}
}