2013-02-01 92 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

如果這種方法有效並且可以欺騙它正確讀取它,那麼我認爲這是正確的答案。 –