svnkit: how to get latest revision number from SVN

2019-01-27 06:53发布

I want to get the latest revision number of the SVN database using SVNKIT. I don't want to update the local repository and get the head revision number , i want to directly contact the SVN repository and get the latest revision number. please help me .

标签: java svnkit
3条回答
三岁会撩人
2楼-- · 2019-01-27 07:07
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);
查看更多
淡お忘
3楼-- · 2019-01-27 07:21
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();
}
查看更多
Juvenile、少年°
4楼-- · 2019-01-27 07:25
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()); 
查看更多
登录 后发表回答