1

I'm trying to write a SVN hook in C# that determines the branches a transaction was commited to. Although it is unlikely and defies common sense to commit into multiple branches, I still want to know all the branches involved. That part works pretty well. The problem I have, is, if I debug my program on my local machine with a local repository, either via TortoiseSVN or VisualSVN Server, It works as expected. Now I moved my hook to the actual server and I get the following exception:

Unable to connect to a repository at URL 'file:///D:/SvnRepos/test'
at SharpSvn.SvnClientArgs.HandleResult(SvnClientContext client, SvnException error, Object targets)
at SharpSvn.SvnClientArgs.HandleResult(SvnClientContext client, svn_error_t* error, Object targets)
at SharpSvn.SvnClient.InternalLog(ICollection`1 targets, Uri logRoot, SvnRevision altPegRev, SvnLogArgs args, EventHandler`1 logHandler)
at SharpSvn.SvnClient.Log(Uri target, SvnLogArgs args, EventHandler`1 logHandler)
...
Unable to open an ra_local session to URL

My code:

HashSet<string> branches = new HashSet<string>();
// connect to SVN server
using (SvnClient client = new SvnClient())
{
    client.Authentication.Clear(); // Clear predefined handlers
    // authentication
    if (Credentials != null)
    {
        client.Authentication.UserNamePasswordHandlers
            += delegate(object obj, SharpSvn.Security.SvnUserNamePasswordEventArgs args)
            {
                args.UserName = Credentials.UserName;
                args.Password = Credentials.Password;
            }; 
        client.Authentication.SslServerTrustHandlers += delegate(object sender, SvnSslServerTrustEventArgs e)
        {
            e.AcceptedFailures = e.Failures;
            e.Save = true; // Save acceptance to authentication store
        };
    }
    client.Log(
        // ... of the specified repository ...
        repository,
        // ... and revision.
        new SvnLogArgs(new SvnRevisionRange(revision, revision)),
        // since only one revision is affected, a single set of log events is called
        (o, e) =>
        {
            if (e.ChangedPaths != null)
            {
                foreach (var p in e.ChangedPaths)
                {
                    ...
                }
            }
            else throw new NoChangedPathsException("List of changed paths could not be retrieved.");
        });
}

return branches.ToArray<string>();

I know there were quite similar questions here, and I tried all of the suggested solutions; none worked. Appreciate the help.

hoekki
  • 228
  • 1
  • 11

0 Answers0