Search code examples
.netsvnsharpsvn

How to create a Branch in SharpSvn


I try to use the SharpSvn library in my VB.Net project to access my SVN repository.

I want to create a branch programmatically. This is my approach:

Dim trunkUrl As String = "file://sourcecontrol.server/repo/trunk/test-folder"
Dim branchUrl As String = "file://sourcecontrol.server/repo/branches/mybranches/test-folder"

Using client As SvnClient = New SvnClient()

    Dim copyArgs = New SvnCopyArgs
    copyArgs.CreateParents = True
    copyArgs.LogMessage = "New Branch"

    Dim target As SvnUriTarget = New SvnUriTarget(New Uri(trunkUrl))

    client.Copy(target, branchUrl)

End Using

I get the error: "System.ArgumentException: 'This argument is not a valid path. A Uri was specified Parametername: toPath'"

How do I need to pass in the trunk and branch URL?

Or is svnClient.Copy() not the right method for branching?

And I cannot find an accessible documentation with examples. The project page under https://sharpsvn.open.collab.net/servlets/ProjectProcess?pageID=3794 has a link to the documentation, but it seems it's not working anymore.


Solution

  • A simple fix. Change this line:

    client.Copy(target, branchUrl)

    to

    client.RemoteCopy(target, new Uri(branchUrl), copyArgs)