简体   繁体   中英

svnkit: how to get latest revision number from SVN DB?

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM