Sharpsvn 日志消息编辑 Sharpsvn?

2023-12-14

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

    }

Subversion 中的每条日志消息都存储为修订属性,即每个修订版本附带的元数据。请参阅颠覆属性的完整列表。还可以看看这个相关答案和颠覆FAQ。相关答案表明您想要做的事情是这样的:

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

在标准存储库上,这会导致错误,因为默认行为是无法修改修订版本属性。请参阅常见问题解答入口关于更改日志消息如何使用pre-revprop-change存储库挂钩。

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

        }
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Sharpsvn 日志消息编辑 Sharpsvn? 的相关文章

随机推荐