Search code examples
svnkit

SVNKit: How to get the revision number from a working directory


I would like to implement a method that can get the svn revision number from the path where a SVN repository has been checked out. The method declaration would look something like this:

long getRevisionNumber(String localPath) { ... }

I'm trying to use SVNKit for this, but it seems to require an SVN URL to start with. Is there any way to start with a local path?


Solution

  • public static long getRevisionNumber(String localPath) throws SVNException {
        final SVNStatus status = SVNClientManager.newInstance().getStatusClient().doStatus(new File(localPath), false);
        return status != null ? status.getRevision().getNumber() : -1;
    }