编辑Sharpsvn日志信息

本文关键字:信息 日志 Sharpsvn 编辑 | 更新日期: 2023-09-27 18:11:39

使用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> ());
    }

编辑Sharpsvn日志信息

Subversion中的每个日志消息都存储为一个修订属性,即每个修订的元数据。请参阅subversion属性的完整列表。也可以看看这个相关的答案和Subversion FAQ。相关的答案表明,您想要做的事情类似于:

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

在标准存储库上,这会导致错误,因为默认行为是不能修改修订属性。关于如何使用pre-revprop-change存储库钩子更改日志消息,请参阅FAQ条目。

翻译成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);
        }
    }
}

据我所知,SharpSvn(以及SVN客户端)主要提供只读访问,并且不允许您编辑存储库上的日志消息。但是,如果您有管理员权限并且需要编辑日志消息,您可以自己编辑。