2013-10-02 177 views
2

繼這裏找到代碼: How to check if file is under source control in SharpSvn?SharpSVN不遍歷所有子目錄和文件

我試圖做一個小的實用程序,將遍歷一個指定的文件夾,並打印出所有的文件的狀態。

private void btnCheckSVN_Click(object sender, EventArgs e) 
    { 
     ParseSVNResults(CheckSVN()); 
    } 

    private Collection<SvnStatusEventArgs> CheckSVN() 
    { 
     string path = @"C:\AMG\trunk\AMC"; 
     if (!Directory.Exists(path)) 
      return null; 

     DevExpress.Utils.WaitDialogForm wait = new DevExpress.Utils.WaitDialogForm(); 
     wait.Caption = "Please wait, loading SVN file statuses. This may take a moment."; 
     wait.Caption += Environment.NewLine + path; 
     wait.Show(); 

     SvnClient client = new SvnClient(); 
     SvnStatusArgs sa = new SvnStatusArgs(); 
     sa.Depth = SvnDepth.Infinity; 
     Collection<SvnStatusEventArgs> statuses; 

     client.GetStatus(path, sa, out statuses); 

     wait.Close(); 
     return statuses; 
    } 

    private void ParseSVNResults(Collection<SvnStatusEventArgs> results) 
    { 
     if (results == null) 
      return; 

     int modified = 0; 
     int unversioned = 0; 
     foreach (SvnStatusEventArgs item in results) 
     { 
      memoEditSVNFiles.Text += item.LocalContentStatus.ToString() + " -- " + item.Path + Environment.NewLine; 

      if (item.LocalContentStatus.ToString() == "Modified") 
       modified++; 
      else if (item.LocalContentStatus.ToString() == "NotVersioned") 
       unversioned++; 
     } 

     memoEditSVNFiles.Text += Environment.NewLine + "Modified: " + modified + Environment.NewLine; 
     memoEditSVNFiles.Text += "Not Versioned: " + unversioned + Environment.NewLine; 
     memoEditSVNFiles.Text += "Total: " + results.Count; 
    } 

當代碼執行,我一共拿到147個文件夾&。實際的文件夾有幾千個文件。是否有可能我在太多文件和SharpSVN只是在一段時間後退出?

編輯;我只是嘗試創建約100個文本文件並將30個文件夾放入3個文件夾中,然後「嵌套」它們。所以我有;

C:具有\ AMG \樹幹\測試〜30個文件 C:\ AMG \樹幹\測試\ Folder1中,其具有〜30個文件 C:\ AMG \樹幹\測試\ Folder1中\子,其具有另外的30當我在C:\ AMG \ trunk \ test上運行上面的代碼而不是我的代碼片段中的給定路徑時,輸出顯示1個文件總數。

回答

2

所以事實證明SvnStatusArgs類有一個「RetrieveAllEntries」布爾值標誌,默認爲false。顧名思義,如果設置爲true,則返回每個文件,無論是修改/未版本化還是最新版本。

在CheckSVN()方法1條額外線在原來的職位:

 SvnClient client = new SvnClient(); 
     SvnStatusArgs sa = new SvnStatusArgs(); 
     sa.Depth = SvnDepth.Infinity; 
     sa.RetrieveAllEntries = true; //the new line 
     Collection<SvnStatusEventArgs> statuses; 

     client.GetStatus(path, sa, out statuses); 
相關問題