如何在java中获取SVN版本号之间的更改列表

Joe*_*ang 0 svn svnkit

假设您有SVN的开始修订号和结束修订号,是否有任何SDK api可以在java中获取它们的更改列表?我正在使用TortoiseSVN.谢谢.

no.*_*rea 10

我不确定我是否理解正确,
但是对于使用SVN的java库,您可以检查SVNKit.

http://svnkit.com/

这里有一个示例代码如何获取存储库历史记录:http: //wiki.svnkit.com/Printing_Out_Repository_History

编辑:

我使用svnkit 1.7.6和svn命令行版本1.6.5尝试了示例代码

svn log [REPOSITORY URL] -r1000000:1000002

两者都给了我3条历史记录,我认为你正在做的事情有问题.

这是java的代码:

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

    }

}

}
Run Code Online (Sandbox Code Playgroud)