tags:

views:

1266

answers:

3

How do I programmatically get the revision description and author from the SVN server in c#?

+4  A: 

You will need to find a C# SVN API to use. A quick Google search found SharpSVN.

To get message and author for specific revision

SvnClient client = new SvnClient();
SvnUriTarget uri = new SvnUriTarget("url", REV_NUM);

string message, author;
client.GetRevisionProperty(uri, "svn:log", out message);
client.GetRevisionProperty(uri, "svn:author", out author);
Samuel
I know there are some libraries with SVN in its name, but what I would like to know how to do this from someone who did it before.
tomaszs
+2  A: 

I've done something similar to this a while back, we needed notification of certain repository commits.

I ended up using SubversionNotify to do this. You could take a look at the code there and see what you can use.

I do believe SubversionNotify is grabbing output from svnlook. Svnlook has quite a few arguments that can get what you're looking for.

If you know the revision number and repository:

svnlook info -r [rev#] /path/to/repo

Will net you the User, Timestamp, Log message length, and the log message itself:

bob
2009-03-25 11:10:49 -0600 (Wed, 25 Mar 2009)
19
Did stuff with things.
Slipfish
+5  A: 

Using SharpSvn:

using(SvnClient client = new SvnClient())
{
    Collection<SvnLogEventArgs> list;

    // When not using cached credentials
    // c.Authentication.DefaultCredentials = new NetworkCredential("user", "pass")l

    SvnLogArgs la = new SvnLogArgs { Start=128; End=132; };
    client.GetLog(new Uri("http://my/repository"), la, out list);

    foreach(SvnLogEventArgs a in list)
    {
       Console.WriteLine(string.Format("=== r{0} : {1} ====", a.Revision, a.Author));
       Console.WriteLine(a.LogMessage)
    }
}
Bert Huijben
Hello, and how to get numer of last revision?
tomaszs