Using SharpSvn to retrieve log entries within a date range
Asked Answered
A

2

12

I'm using SharpSvn to interact with my svn repository via C# code. I am using this code to retrieve svn log entries:

Collection<SvnLogEventArgs> logitems;
var uri = new Uri("http://myserver/svn/foo/bar.txt");
client.GetLog(uri, out logitems);
foreach (var logentry in logitems)
{
    string author = logentry.Author;
    string message = logentry.LogMessage;
    DateTime checkindate = logentry.Time;
}

This works well, but now I want to restrict the returned log entries by revision date. This is something that can be done via the svn command line with something like

svn log "http://myserver/svn/foo/bar.txt" --revision {2008-01-01}:{2008-12-31}

I can't seem to figure out a parallel capability within SharpSvn. Can someone point me in the right direction?

Adjudication answered 12/6, 2009 at 21:2 Comment(0)
D
25

You can try it like this:

DateTime startDateTime = // ...;
DateTime endDateTime = // ...;
SvnRevisionRange range = new SvnRevisionRange(new SvnRevision(startDateTime), new SvnRevision(endDateTime));
client.GetLog(uri, new SvnLogArgs(range), out logitems);
Doubleteam answered 12/6, 2009 at 21:33 Comment(1)
Thanks! I missed the fact that SvnRevision could take a DateTime in its constructor.Adjudication
F
4

I think you might be able to do it using one of the GetLog function that takes a SharpSvn.SvnLogArgs parameter.

public bool GetLog(System.Uri target, SharpSvn.SvnLogArgs args,
        out System.Collections.ObjectModel.Collection logItems)

That class has Start/End that are SharpSvn.SvnRevision objects which look like they can take a "time" parameter.

I've only done a little bit with it, but that would be where you could start looking.

Foran answered 12/6, 2009 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.