0

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.

alroc
  • 27,574
  • 6
  • 51
  • 97
Joe.wang
  • 11,537
  • 25
  • 103
  • 180

1 Answers1

10

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){

    }

}

}
noandrea
  • 384
  • 2
  • 8
  • I'll just add that SvnOperationFactory#createDiffSummarize method of SVNKit will help. – Dmitry Pavlenko Nov 16 '12 at 09:58
  • Is there any bug with org.tmatesoft.svn.core.io.SVNRepository.log method ? Why did I get different logEntries number when I used the `SVN diff` Command ? – Joe.wang Nov 16 '12 at 10:10
  • I did some test , Using `log` api I got a `Collection` which size is 25. But when I use the command line I got more than 100 lines of log, Can anybody tell me why ? Is it bug or I made a mistake? thanks – Joe.wang Nov 16 '12 at 10:13
  • It's easy to understand whether SVNKit has a bug: `jsvn` executable comes together with SVNKit distribution. If it behaves like native SVN, there's no bug. without looking into the command and the code you run I can't tell you if you are doing something wrong. – Dmitry Pavlenko Nov 16 '12 at 11:32
  • Sorry for mistaking something , Now I understood the method `repository.log` can get the all the revision numbers of the range you specified. not the file change log list. thanks. – Joe.wang Nov 21 '12 at 10:16