protected void index ( SVNRepository repository , long from , long to , JobRunListener runListener ) { // Ordering if ( from > to ) { long t = from ; from = to ; to = t ; } // Range long min = from ; long max = to ; // Opens a transaction try ( Transaction ignored = transactionService . start ( ) ) { // SVN URL SVNURL url = SVNUtils . toURL ( repository . getConfiguration ( ) . getUrl ( ) ) ; // Filters the revision range using the repository configuration long startRevision = repository . getConfiguration ( ) . getIndexationStart ( ) ; from = Math . max ( startRevision , from ) ; // Filters the revision range using the SVN repository long repositoryRevision = svnClient . getRepositoryRevision ( repository , url ) ; to = Math . min ( to , repositoryRevision ) ; // Final check of range if ( from > to ) { throw new IllegalArgumentException ( String . format ( "Cannot index range from %d to %d" , from , to ) ) ; } // Log logger . info ( "[svn-indexation] Repository={}, Range: {}-{}" , repository . getId ( ) , from , to ) ; // SVN range SVNRevision fromRevision = SVNRevision . create ( from ) ; SVNRevision toRevision = SVNRevision . create ( to ) ; // Calls the indexer, including merge revisions IndexationHandler handler = new IndexationHandler ( repository , revision -> runListener . message ( "Indexation on %s is running (%d to %d - at %d - %d%%)" , repository . getConfiguration ( ) . getName ( ) , min , max , revision , Math . round ( 100.0 * ( revision - min + 1 ) / ( max - min + 1 ) ) ) ) ; svnClient . log ( repository , url , SVNRevision . HEAD , fromRevision , toRevision , true , true , 0 , false , handler ) ; } }
Indexation of a range in a thread for one repository - since it is called by a single thread executor we can be sure that only one call of this method is running at one time for one given repository .