import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Set; import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.wc.SVNWCUtil; public class Main { static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); public static void main(String[] args) { SVNRepository osivia_portal = initRepo("http://www.osivia.org/repos/osivia-portal"); getHistory(osivia_portal, "/branches/4.6-maintenance", 100); SVNRepository toutatice = initRepo("http://projet.toutatice.fr/repos"); getHistory(toutatice, "/toutatice-portail/cms/branches/4.6-maintenance" , 2000); SVNRepository osivia_services = initRepo("http://www.osivia.org/repos/osivia-services"); getHistory(osivia_services, "/directory/branches/4.6-maintenance", 300); getHistory(osivia_services, "/collaboration/branches/4.6-maintenance", 300); getHistory(osivia_services, "/procedure/branches/4.6-maintenance", 300); getHistory(osivia_services, "/tasks/trunk", 300); getHistory(osivia_services, "/cgu/trunk", 300); getHistory(toutatice, "/toutatice-ecm/opentoutatice/branches/4.6-maintenance", 2000); List opentoutaticeModules = getOpentoutaticeModules(toutatice, "/toutatice-ecm/opentoutatice-addons"); for(String module : opentoutaticeModules) { getHistory(toutatice, "/toutatice-ecm/opentoutatice-addons/" + module + "/branches/4.6-maintenance", 2000); } } private static List getOpentoutaticeModules(SVNRepository repository, String path) { List modules = new ArrayList(); try { Collection entries = repository.getDir( path, -1 , null , (Collection) null ); Iterator iterator = entries.iterator( ); while ( iterator.hasNext( ) ) { SVNDirEntry entry = ( SVNDirEntry ) iterator.next( ); if ( entry.getKind() == SVNNodeKind.DIR ) { modules.add(entry.getName()); } } } catch(SVNException e) { System.out.println("### Branche inacessible."); } return modules; } private static SVNRepository initRepo(String repoUrl) { SVNRepository repository = null; try { repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded( repoUrl ) ); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( "", "" ); repository.setAuthenticationManager( authManager ); } catch(SVNException e) { e.printStackTrace(); } return repository; } public static void getHistory(SVNRepository repository, String path, long delta) { //String url = "http://www.osivia.org/repos/osivia-mobile"; String name = ""; String password = ""; System.out.println(""); System.out.println("### "); System.out.println("### History : "+repository.getLocation().toString() + path); System.out.println("### "); try { long startRevision = repository.getLatestRevision() - delta; long endRevision = -1; //HEAD (the latest) revision Collection logEntries = null; logEntries = repository.log( new String[] { path } , null , startRevision , endRevision , true , true ); for ( Iterator entries = logEntries.iterator( ); entries.hasNext( ); ) { SVNLogEntry logEntry = ( SVNLogEntry ) entries.next( ); if(!logEntry.getMessage().contains("release")) { //System.out.println( "---------------------------------------------" ); System.out.print (logEntry.getRevision() +";"); System.out.print( logEntry.getAuthor( ) +";" ); System.out.print( sdf.format(logEntry.getDate()) +";" ); System.out.println( "\""+ logEntry.getMessage( ) +"\";" ); // if ( logEntry.getChangedPaths( ).size( ) > 0 ) { // System.out.println( ); // System.out.println( "changed paths:" ); // Set changedPathsSet = logEntry.getChangedPaths( ).keySet( ); // // for ( Iterator changedPaths = changedPathsSet.iterator( ); changedPaths.hasNext( ); ) { // SVNLogEntryPath entryPath = ( SVNLogEntryPath ) logEntry.getChangedPaths( ).get( changedPaths.next( ) ); // System.out.println( " " // + entryPath.getType( ) // + " " // + entryPath.getPath( ) // + ( ( entryPath.getCopyPath( ) != null ) ? " (from " // + entryPath.getCopyPath( ) + " revision " // + entryPath.getCopyRevision( ) + ")" : "" ) ); // } // } } else { System.out.println( "###" +logEntry.getMessage( ) +";" ); } } } catch(SVNException e) { System.out.println("### Branche inacessible."); } } }