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