SharpSVN编辑日志信息SharpSVN?

3

使用SharpSVN工具来修改特定版本的提交记录信息。

这个功能类似于svn中的“[显示日志] - [编辑日志信息]”。

由于我的英语有些困难,为了帮助您理解,我在此附上了我的代码。

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

    }

你的问题不太清楚,你想问什么? - Tanuj Wadhwa
我想使用C#和SharpSVN实现类似于SVN的'[edit logmessage]'的功能。 - user2334401
2个回答

2
Subversion中的每个日志消息都被存储为修订属性,即与每个修订一起的元数据。请参阅完整的Subversion属性列表。还要查看此相关答案和SubversionFAQ。相关答案显示您想要执行的操作类似于:
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);

        }
    }
}

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

1
当然可以,稍后请看我的回答。 - Sander Rijken

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接