public static String getMergedRevisions ( File directory , String ... branches ) throws IOException { // we could also use svn mergeinfo --show-revs merged ^/trunk ^/branches/test CommandLine cmdLine ; cmdLine = new CommandLine ( SVN_CMD ) ; cmdLine . addArgument ( "propget" ) ; addDefaultArguments ( cmdLine , null , null ) ; cmdLine . addArgument ( "svn:mergeinfo" ) ; StringBuilder MERGED_REVISIONS_BUILD = new StringBuilder ( ) ; try ( InputStream ignoreStr = ExecutionHelper . getCommandResult ( cmdLine , directory , 0 , 120000 ) ) { List < String > lines = IOUtils . readLines ( ignoreStr , "UTF-8" ) ; for ( String line : lines ) { for ( String source : branches ) { if ( line . startsWith ( source + ":" ) ) { log . info ( "Found merged revisions for branch: " + source ) ; MERGED_REVISIONS_BUILD . append ( "," ) . append ( line . substring ( source . length ( ) + 1 ) ) ; // + 1 for ":" break ; } } } } String MERGED_REVISIONS = StringUtils . removeStart ( MERGED_REVISIONS_BUILD . toString ( ) , "," ) ; if ( MERGED_REVISIONS . equals ( "" ) ) { throw new IllegalStateException ( "Could not read merged revision with command " + cmdLine + " in directory " + directory ) ; } // expand ranges r1-r2 into separate numbers for easier search in the string later on List < Long > revList = new ArrayList <> ( ) ; String [ ] revs = MERGED_REVISIONS . split ( "," ) ; for ( String rev : revs ) { if ( rev . contains ( "-" ) ) { String [ ] revRange = rev . split ( "-" ) ; if ( revRange . length != 2 ) { throw new IllegalStateException ( "Expected to have start and end of range, but had: " + rev ) ; } for ( long r = Long . parseLong ( revRange [ 0 ] ) ; r <= Long . parseLong ( revRange [ 1 ] ) ; r ++ ) { revList . add ( r ) ; } } else { // non-inheritable merge adds a "*" to the rev, see https://groups.google.com/forum/?fromgroups=#!topic/subversion-svn/ArXTv1rUk5w rev = StringUtils . removeEnd ( rev , "*" ) ; revList . add ( Long . parseLong ( rev ) ) ; } } return revList . toString ( ) ; }
Retrieve a list of all merged revisions .