[英]svnkit: how to get latest revision number from SVN DB?
I want to get the latest revision number of the SVN database using SVNKIT. 我想使用SVNKIT获取SVN数据库的最新修订版本号。 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.
我不想更新本地存储库并获取总修订版号,我想直接联系SVN存储库并获取最新的修订版号。 please help me .
请帮我 。
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());
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();
}
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.