svnkit:如何从SVN DB获取最新版本号?

时间:2012-06-27 09:53:56

标签: java svnkit

我想使用SVNKIT获取SVN数据库的最新版本号。我不想更新本地存储库并获取头版本号,我想直接联系SVN存储库并获取最新的版本号。请帮我 。

3 个答案:

答案 0 :(得分:8)

DAVRepositoryFactory.setup();
String url = "(directory in svn url)";
String name = "(login name)";
String password = "(login password)";
SVNRepository repository = null;
repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
ISVNAuthenticationManager authManager =
                   SVNWCUtil.createDefaultAuthenticationManager(name, password);
repository.setAuthenticationManager(authManager);
SVNDirEntry entry = repository.info(".", -1);
System.out.println("Latest Rev: " + entry.getRevision()); 

答案 1 :(得分:2)

FSRepositoryFactory.setup();
File pathToRepository = new File("/path/to/repository");
SVNRepository svnRepository = SVNRepositoryFactory.create(SVNURL.fromFile(pathToRepository));
try {
    final long latestRevision = svnRepository.getLatestRevision();
    System.out.println("latestRevision = " + latestRevision);
} finally {
    svnRepository.closeSession();
}

答案 2 :(得分:0)

DAVRepositoryFactory.setup();

final SVNURL url = SVNURL.parseURIDecoded("http://svn.apache.org/repos/asf");
final SVNRepository repository = SVNRepositoryFactory.create(url);
final long latestRevision = repository.getLatestRevision();
System.out.println(latestRevision);