2017-02-06 69 views
0

我正在使用Sharpsvn客戶端類在svn目錄中的文件上設置屬性。我想用一個新的時間戳不斷重置屬性,並且這樣做會在存儲庫歷史記錄中更新包含新日誌消息的新版本。我不想做的事情是對文件進行更改,然後將其提交回目錄。現在,我試圖弄清楚如何連接到目錄上的文件。下面是代碼我目前有:我使用client.SetProperty方法以及試圖如何使用sharpsvn clinet類將屬性設置爲svn目錄中的文件?

System.Uri uri = new System.Uri("url link"); 

using (SvnClient client = new SvnClient()) 
{ 
    try 
    { 
    // Get new timestamp 
    DateTime dt = DateTime.Now; 
    string time = String.Format("{0:G}", dt); 

    // Set property to file in the svn directory 
    client.RemoteSetProperty(uri, "svn:time", time); 
    } 
    catch (Svnexception ex) 
    { 
    MessageBox.show(ex.Message + "Check out error!"); 
    } 
} 

,但是當我試圖在既有本地工作副本就直奔網址沒有工作。幫助會很棒!

回答

0

更改了代碼的某些部分以使其按需要工作。請看看:

   System.Uri uri = new System.Uri("url link"); 

       using (SvnClient client = new SvnClient()) 
       { 
        try 
        { 
         // Get new timestamp 
         DateTime date = DateTime.Now; 
         string time = String.Format("{0:G}", date); 

         // To Get the Latest Revision on the Required SVN Folder 
         SvnInfoEventArgs info; 
         client.GetInfo(uri, out info); 

         // Prepare a PropertyArgs object with latest revision and a commit message; 
         SvnSetPropertyArgs args = new SvnSetPropertyArgs() { BaseRevision = info.Revision, LogMessage = "Sample msg for SVN commit" }; 

         // Set property to file in the svn directory 
         client.RemoteSetProperty(uri, "svn:time", time, args); 
        } 
        catch (Exception ex) 
        { 
         MessageBox.Show(ex.Message + "Check out error!"); 
        } 
       } 

希望這有助於;

相關問題