2013-04-30 51 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); 

     } 
    } 
}