Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

svnkit

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 .

like image 967
Anandhakrishnan Avatar asked Nov 30 '25 04:11

Anandhakrishnan


2 Answers

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()); 
like image 191
juergen d Avatar answered Dec 01 '25 18:12

juergen d


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();
}
like image 45
Dmitry Pavlenko Avatar answered Dec 01 '25 19:12

Dmitry Pavlenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!