2013-02-01 64 views
5

所以我使用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=3535http://subversion.tigris.org/ds/viewMessage.do?dsForumId=463&viewType=browseAll&dsMessageId=2456472

所以,因为所发生遥想当年,不应该这不是一个问题了吗?

+0

您的代码'变种ROOTPATH二线=‘d:\’ ;'不编译(这是你的实际源码?)。再往下看,你引用'this.RootPath',这是一个不同的变量,是你打算做什么? –

+0

是的。那些在运行时填充,我只是显示路径设置为什么。 –

+0

我在SharpSvn找到了这个问题的根本原因。它应该在下一个版本中修复。如果您可以在此处或作为[email protected]发布这个问题,这对我来说会容易得多。 因为异常输出的问题显示workingClient.GetVersion(“C:\\”,out q)更容易诊断那么您的完整示例。 –

回答

1

SharSVN存在根路径问题,因为我们可以在邮件归档中读取。但是我们可以做小黑客你的场合:

  1. 下载完整的包sharpsvn http://sharpsvn.open.collab.net/files/documents/180/5569/SSvnEx-1.7002.1998.zip
  2. 复制svnversion.exe到您的bin目录
  3. 然后,我们需要一个黑客的方法来获得verison

    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); 
        } 
    
  4. 并修改您的假方法full source code

确定它是一个肮脏的工作,但它可能会有所帮助。请小心与svnversion.exe结果GetVersionHack不理想。

+0

这并不理想。暂时将整个svn目录复制到另一个位置,然后获得结果几乎更有意义。 –

+1

@ kelton52如果你可以将它移动到其他位置更好地做到这一点 –

+0

我不能真的,这是一些演出回购......我很抱歉,但这个解决方案太hacky。 –

0

如果它抱怨绝对路径,则尝试定义unc路径。分享你的D:\驱动器,这是你的SVN回购。然后使用

var RootPath="\\<servername>\D$"; 
2

一个杂牌的访问为“..”你的方式,从当前目录的根目录:

[pwd = C:\USERS\franklin\absrel] 
root = ..\..\.. 
+1

如果这种方法有效并且可以欺骗它正确读取它,那么我认为这是正确的答案。 –