我正在尝试在C#中编写一个SVN挂钩,用于确定事务被提交的分支。虽然不太可能并且违反常识,但我仍然想知道所涉及的所有分支。那部分效果很好。我遇到的问题是,如果我通过TortoiseSVN或VisualSVN Server在我的本地机器上使用本地存储库调试我的程序,它按预期工作。现在我将我的钩子移动到实际的服务器,我得到以下异常:
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
我的代码:
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>();
我知道这里有类似的问题,我尝试了所有建议的解决方案;没人工作。感谢帮助。