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



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

我不确定我是否正确理解,
但是对于Java库与SVN一起使用你可以检查SVNKit。

http://svnkit.com/

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

编辑:

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

svn log [存储库 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){
    }
}
}

最新更新