开发者

How can i get the svn log message

开发者 https://www.devze.com 2023-02-12 01:52 出处:网络
using (SvnClient client = new SvnClient()) { client.Commit(_targetPath, commitArgs); SvnInfoEventArgs result;
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;
 开发者_Go百科       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?


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.


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


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)
    {

    }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消