2013-04-30 90 views
3

使用sharpsvn。 特定修訂記錄消息要更改。sharpsvn logmessage編輯sharpsvn?

它的實現就像svn的[show log] - [edit logmessage]一樣。

我的英語很尷尬。 等等,以幫助你理解。 我的代碼已附加。

 public void logEdit() 
    { 
     Collection<SvnLogEventArgs> logitems = new Collection<SvnLogEventArgs>(); 

     SvnRevisionRange range = new SvnRevisionRange(277, 277); 
     SvnLogArgs arg = new SvnLogArgs(range) ; 

     m_svn.GetLog(new System.Uri(m_targetPath), arg, out logitems); 

     SvnLogEventArgs logs; 
     foreach (var logentry in logitems) 
     { 
      string autor = logentry.LogMessage; // only read .. 
      // autor += "AA"; 
     } 

     // m_svn.Log(new System.Uri(m_targetPath), new System.EventHandler<SvnLogEventArgs>()); 

    } 
+0

並不清楚您要問什麼? – 2013-04-30 05:14:20

+0

sharpsvn通過使用c#svn的​​'[edit logmessage]'來完成這個任務。 來自c#使用sharpsvn,像'[編輯logmessage]'svn想使它的工作。 – user2334401 2013-04-30 05:25:41

回答

0

據我所知,SharpSvn(以及一般SVN客戶端)主要提供只讀訪問,並且不會讓你編輯在資源庫中的日誌信息。但是,如果您有管理員權限並需要編輯日誌消息,則可能需要do it yourself

+1

這當然是可以的,稍微看一下我的答案 – 2013-05-14 17:51:03

2

Subversion中的每條日誌消息都存儲爲修訂版本屬性,即與每個版本一起發佈的元數據。請參閱complete list of subversion properties。也可以看看this related answer和Subversion FAQ。相關答案表明你想要做的是一樣的東西:

svn propedit -r 277 --revprop svn:log "new log message" <path or url> 

在一個標準的倉庫,因爲默認行爲是版本屬性不能修改這會導致錯誤。有關如何使用pre-revprop-change存儲庫掛鉤更改日誌消息,請參閱FAQ entry

翻譯成SharpSvn:

public void ChangeLogMessage(Uri repositoryRoot, long revision, string newMessage) 
{ 
    using (SvnClient client = new SvnClient()) 
    { 
     SvnSetRevisionPropertyArgs sa = new SvnSetRevisionPropertyArgs(); 

     // Here we prevent an exception from being thrown when the 
     // repository doesn't have support for changing log messages 
     sa.AddExpectedError(SvnErrorCode.SVN_ERR_REPOS_DISABLED_FEATURE); 

     client.SetRevisionProperty(repositoryRoot, 
      revision, 
      SvnPropertyNames.SvnLog, 
      newMessage, 
      sa); 

     if (sa.LastException != null && 
      sa.LastException.SvnErrorCode == 
       SvnErrorCode.SVN_ERR_REPOS_DISABLED_FEATURE) 
     { 
      MessageBox.Show(
       sa.LastException.Message, 
       "", 
       MessageBoxButtons.OK, 
       MessageBoxIcon.Information); 

     } 
    } 
}