Question

Say you have a begin revision number and end revision number of SVN, Is there any SDK api to get the changed list of them in java ? I am using the TortoiseSVN. thanks.

Était-ce utile?

La solution

I am not sure if I understand correctly,
but for a java library to work with SVN you can check SVNKit.

http://svnkit.com/

Here there is a sample code how to get a repository history: http://wiki.svnkit.com/Printing_Out_Repository_History

EDIT:

I tried the sample code using svnkit 1.7.6 and with svn command line version 1.6.5

svn log [REPOSITORY URL] -r1000000:1000002

both give me back 3 lines of history, i think there is a problem with what you are doing.

here is the java the code:

import java.util.Collection;
import java.util.Iterator;

import org.tmatesoft.svn.core.SVNLogEntry;
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 TestSvnLog {

/**
 * @param args
 */
public static void main(String[] args) {
    DAVRepositoryFactory.setup( );

    String url = "[REPOSITORY URL]";
    String name = "anonymous";
    String password = "anonymous";
    long startRevision = 1000000;
    long endRevision = 1000002; //HEAD (the latest) revision

    SVNRepository repository = null;
    try {
        repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded( url ) );
        ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( name, password );
        repository.setAuthenticationManager( authManager );


        Collection logEntries = null;

        logEntries = repository.log( new String[] { "" } , null , startRevision , endRevision , true , true );

        for ( Iterator entries = logEntries.iterator( ); entries.hasNext( ); ) {
            SVNLogEntry logEntry = ( SVNLogEntry ) entries.next( );
            System.out.println (String.format("revision: %d, date %s", logEntry.getRevision( ), logEntry.getDate()));
        }
    } catch (Exception e){

    }

}

}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top