如何获取 svn 日志消息

发布于 2024-10-18 05:50:49 字数 815 浏览 9 评论 0原文

using (SvnClient client = new SvnClient())
{
    client.Commit(_targetPath, commitArgs);

    SvnInfoEventArgs result;
    client.GetInfo(_targetPath, out result);

    SvnLogArgs args = new SvnLogArgs();
    args.Start = new SvnRevision(result.L​astChangeRevision);
    args.End = new SvnRevision(result.Revision);

    Collection<SvnLog​EventArgs> logitems;
    client.GetLog(_targetPath, args, out logitems);

    foreach (SvnLogEventArgs logentry in logitems)
    {
        string author = logentry.Author;
        string message = logentry.LogMessage;
        DateTime checkindate = logentry.Time;
        AddMessage(string.Fo​rmat("Commited successfully by {0} on {1} for message: {2}", author, checkindate, message));
    }
}

这是我的代码,但我只能得到一个日志项,它应该是修订范围内所有日志的路径,有什么问题吗?

using (SvnClient client = new SvnClient())
{
    client.Commit(_targetPath, commitArgs);

    SvnInfoEventArgs result;
    client.GetInfo(_targetPath, out result);

    SvnLogArgs args = new SvnLogArgs();
    args.Start = new SvnRevision(result.L​astChangeRevision);
    args.End = new SvnRevision(result.Revision);

    Collection<SvnLog​EventArgs> logitems;
    client.GetLog(_targetPath, args, out logitems);

    foreach (SvnLogEventArgs logentry in logitems)
    {
        string author = logentry.Author;
        string message = logentry.LogMessage;
        DateTime checkindate = logentry.Time;
        AddMessage(string.Fo​rmat("Commited successfully by {0} on {1} for message: {2}", author, checkindate, message));
    }
}

This is my codes, but I only can get one logentry,it should be the path all logs for the revision range,what's the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

黑白记忆 2024-10-25 05:50:49

我对此 api 一无所知,但看起来您正在调用 GetLog,其范围介于上次更改修订版和当前修订版之间。本能地,我认为根据定义这只是一个日志条目。

所以我的想法是你的修订范围是错误的。为什么不尝试对预期的修订范围进行硬编码并查看结果是否符合您的预期。

I don't know anything about this api but it looks like you are calling GetLog with a range between the last change revision and the current revision. Instinctually, I would think this would only be a single log entry by definition.

So my thought is that your revision range is wrong. Why don't you try hard coding the expected revision range and seeing if the results meets your expectations.

噩梦成真你也成魔 2024-10-25 05:50:49

我认为您想要做的是在提交工作副本时列出已更改的文件,即在提交文件时显示文件通知。有一种比您正在做的更好的方法:

using (SvnClient client = new SvnClient())
{
    // Register the notify event, to get notified of any actions
    client.Notify += (sender, eventArgs) => AddMessage(
        string.Format("Changed path,{0},by action,{1}",
            eventArgs.Path,
            eventArgs.Action));

    client.Commit(_targetPath, commitArgs);
}

请参阅 Notify 事件,以及 SvnNotifyEventArgs 了解更多详情。

此外,您还可以使用 Commit 重载具有 SvnCommitResultout 参数>

SvnCommitResult commitResult;
client.Commit(_targetPath, commitArgs, out commitResult);

Console.WriteLine(string.Format(
    "{0} commited revision {1} at time {2}", 
    commitResult.Author, 
    commitResult.Revision, 
    commitResult.Time));

I think what you're trying to do is list changed files as you're committing a working copy, ie show notifications of files as they're committed. There's a much better way to do this than what you're doing:

using (SvnClient client = new SvnClient())
{
    // Register the notify event, to get notified of any actions
    client.Notify += (sender, eventArgs) => AddMessage(
        string.Format("Changed path,{0},by action,{1}",
            eventArgs.Path,
            eventArgs.Action));

    client.Commit(_targetPath, commitArgs);
}

See the Notify event, and SvnNotifyEventArgs for more details.

In addition, you can also use a Commit overload that has an out parameter of type SvnCommitResult:

SvnCommitResult commitResult;
client.Commit(_targetPath, commitArgs, out commitResult);

Console.WriteLine(string.Format(
    "{0} commited revision {1} at time {2}", 
    commitResult.Author, 
    commitResult.Revision, 
    commitResult.Time));
圈圈圆圆圈圈 2024-10-25 05:50:49

好吧,现在我从下面的代码中得到了我想要的:

using (SvnClient client = new SvnClient())
{
    try
    {
        client.Commit(_targetPath, commitArgs);
        SvnLogArgs args = new SvnLogArgs();

        // get latest changed version
        SvnWorkingCopyClient workingCopyClient = new SvnWorkingCopyClient();
        SvnWorkingCopyVersion version;

        workingCopyClient.GetVersion(_targetPath, out version);
        long localRev = version.End;
        args.Start = new SvnRevision(localRev);
        args.End = new SvnRevision(localRev);

        //get latest log
        Collection<SvnLogEventArgs> logitems;
        client.GetLog(_targetPath, args, out logitems);
        if (logitems.Count > 0)
        {
            foreach (SvnChangeItem path in logitems[0].ChangedPaths)
            {
                AddMessage(string.Format("Changed path,{0},changed on,{1},by action,{2}", path.Path, logitems[0].Time, path.Action));
            }
        }

        WriteLogFile(messageLog.ToString());
    }
    catch (SvnException ex)
    {

    }

}

okay now i've got what i want from below codes:

using (SvnClient client = new SvnClient())
{
    try
    {
        client.Commit(_targetPath, commitArgs);
        SvnLogArgs args = new SvnLogArgs();

        // get latest changed version
        SvnWorkingCopyClient workingCopyClient = new SvnWorkingCopyClient();
        SvnWorkingCopyVersion version;

        workingCopyClient.GetVersion(_targetPath, out version);
        long localRev = version.End;
        args.Start = new SvnRevision(localRev);
        args.End = new SvnRevision(localRev);

        //get latest log
        Collection<SvnLogEventArgs> logitems;
        client.GetLog(_targetPath, args, out logitems);
        if (logitems.Count > 0)
        {
            foreach (SvnChangeItem path in logitems[0].ChangedPaths)
            {
                AddMessage(string.Format("Changed path,{0},changed on,{1},by action,{2}", path.Path, logitems[0].Time, path.Action));
            }
        }

        WriteLogFile(messageLog.ToString());
    }
    catch (SvnException ex)
    {

    }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文