无法读取根
本文关键字:读取 | 更新日期: 2023-09-27 17:57:07
所以我正在使用SharpSVN(SharpSvn.1.7-x86 1.7008.2243),我一直遇到问题。每次我尝试在驱动器根目录下的存储库上使用SvnWorkingCopyClient
时(例如,假设我有D:'
驱动器,它本身就是一个存储库),它都会向我抛出svn_dirent_is_absolute
错误。
事实上,我能找到的唯一不在乎的命令是SvnClient.GetUriFromWorkingCopy(string)
关于如何解决此问题的任何想法(除了移动我的工作副本或在文件系统上链接)?我希望在代码中找到一种方法,或者解决此限制的替代方案(因为SVN 1.7似乎不再有此限制)。
这里有一些代码?
private void fakeFunction(){
var RootPath="d:'";
using (var client = new SharpSvn.SvnClient())
using(var workingClient = new SvnWorkingCopyClient())
{
SvnWorkingCopyVersion workingVersion = null;
// Exception happens here
if (workingClient.GetVersion(this.RootPath, out workingVersion))
{
CurrentRevision = workingVersion.End;
// This will resolve just fine
var targetUri = client.GetUriFromWorkingCopy(RootPath);
var target = SvnTarget.FromUri(targetUri);
SvnInfoEventArgs info = null;
if (client.GetInfo(target, out info))
{
if (workingVersion.End != info.Revision)
{
System.Collections.ObjectModel.Collection<SvnLogEventArgs> logEventArgs = null;
if (client.GetLog(targetUri, out logEventArgs))
{
var oldBack = Console.BackgroundColor;
var oldFor = Console.ForegroundColor;
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Console.ForegroundColor = ConsoleColor.White;
foreach (var l in logEventArgs)
{
Console.WriteLine("[{0}-{1}]-{2}", l.Revision, l.Author, l.LogMessage);
}
Console.BackgroundColor = oldBack;
Console.ForegroundColor = oldFor;
}
System.Console.WriteLine("Repo not up to date.");
}
}
}
}
}
我也偶然发现了这个 http://subversion.tigris.org/issues/show_bug.cgi?id=3535 和 http://subversion.tigris.org/ds/viewMessage.do?dsForumId=463&viewType=browseAll&dsMessageId=2456472
那么,既然这发生在很久以前,这不应该再是一个问题了吗?
一个笨拙是"..",你从当前目录到根目录:
[pwd = C:'USERS'franklin'absrel]
root = ..'..'..
SharSVN 存在根路径问题,因为我们可以在邮件存档中读取。但是,我们可以为您的场合做一些小技巧:
- 下载完整的软件包 sharpsvn http://sharpsvn.open.collab.net/files/documents/180/5569/SSvnEx-1.7002.1998.zip
- 将 svnversion.exe 复制到您的 bin 目录
-
然后我们需要一个黑客方法来获得验证
public static bool GetVersionHack(string appPath,string targetPath,out long version) { // <param name="appPath">Path to svnversion.exe</param> // <param name="path">Target path</param> // <param name="version">Result version</param> Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = appPath; p.StartInfo.Arguments = targetPath + " -n"; p.Start(); //read svnversion.exe result string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); output = output.Replace("M", ""); output = output.Replace("S", ""); output = output.Replace("P", ""); //valid results //4123:4168 mixed revision working copy //4168M modified working copy //4123S switched working copy //4123P partial working copy, from a sparse checkout //4123:4168MS mixed revision, modified, switched working copy return long.TryParse(output, out version); }
-
并修改你的假方法完整源代码
当然,这是一个肮脏的工作,但它可能会有所帮助。请注意svnversion.exe结果GetVersionHack并不理想。
如果它抱怨绝对路径,请尝试定义 unc 路径。分享你的 D:''驱动器,这是您的 SVN 存储库。然后使用
var RootPath="''<servername>'D$";