Search code examples
javasvnkit

Checking Out Directory / File with SVNKit


I can't see on the wiki where checking out is documented. Ideally, I would like to check out a file "example/folder/file.xml", if not just the folder... and then when the application closes down or otherwise, be able to commit back in changes to this file. How do I do this?


Solution

  • You cannot check out a file in Subversion. You have to check out a folder.

    To check out a folder with one or more files:

    SVNClientManager ourClientManager = SVNClientManager.newInstance(null, 
                repository.getAuthenticationManager());
    SVNUpdateClient updateClient = ourClientManager.getUpdateClient();
    updateClient.setIgnoreExternals(false);
    updateClient.doCheckout(url, destPath, revision, revision,
                isRecursive);
    

    To commit a previously checked out folder:

    SVNClientManager ourClientManager = SVNClientManager.newInstance(null, 
                repository.getAuthenticationManager());
    ourClientManager.getWCClient().doInfo(wcPath, SVNRevision.HEAD);
    ourClientManager.getCommitClient().doCommit
            (new File[] { wcPath }, keepLocks, commitMessage, false, true);