1
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?

Sander Rijken
  • 21,376
  • 3
  • 61
  • 85
Iori
  • 19
  • 3
  • What do you mean by: "it should be the path all logs for the revision range"? Do you want to enumerate the committed files? – Sander Rijken Feb 21 '11 at 22:10

3 Answers3

1

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.

User
  • 62,498
  • 72
  • 186
  • 247
1

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));
Sander Rijken
  • 21,376
  • 3
  • 61
  • 85
-1

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

    }

}
Sander Rijken
  • 21,376
  • 3
  • 61
  • 85
Iori
  • 19
  • 3
  • You still haven't explained what you're trying to do, there might be a much better / more simple way. – Sander Rijken Feb 22 '11 at 23:03
  • Make sure to use the "format as code" button, and/or indent your code with 4 spaces to get nicer looking layout. – Sander Rijken Feb 22 '11 at 23:08
  • Hi Sander Rijken, i have tried to use Notify and also out commit result, but i cannot get any commit result from that method you mentioned: SvnCommitResult commitResult; client.Commit(_targetPath, commitArgs, out commitResult); – Iori Feb 25 '11 at 03:01
  • What's the value of commitResult after the Commit then? – Sander Rijken Feb 27 '11 at 09:07
  • the value is null, after committing files, i got null value. – Iori Mar 01 '11 at 04:28
  • the value is null, after committing files, i got null value. – Iori Mar 01 '11 at 04:29