3

I have a working directory in trunk and would like to switch it to a specified branch. How can I do that?

I'd like to have a method

public static void switchToBranch(File baseDir, String branchUrl){
}

How could I implement that?

1 Answer 1

3

[Update] Better version:

public static void switchToBranch(final String branchUrl,
    final File basedir,
    final ISVNDebugLog log) throws SVNException, IOException{
    final SVNUpdateClient updateClient =
        SVNClientManager
            .newInstance().getUpdateClient();
    if(log != null) updateClient.setDebugLog(log);
    updateClient.doSwitch(basedir,
        SVNURL.parseURIEncoded(branchUrl),
        SVNRevision.HEAD,
        SVNRevision.HEAD,
        SVNDepth.INFINITY,
        false,
        false);
}

Credentials are apparently automatically picked up from the ~/.subversion directory.

(And of course it doesn't have to be a branch, SVN doesn't make a difference between tags, branches or any other path)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.