How to get latest revision number using SharpSVN?
Well, a quick google search gave me that, and it works (just point at the /trunk/ URI):
http://sharpsvn.open.collab.net/ds/viewMessage.do?dsForumId=728&dsMessageId=89318
Ok, I figured it by myself:
SvnInfoEventArgs statuses;
client.GetInfo("svn://repo.address", out statuses);
int LastRevision = statuses.LastChangeRevision;
The least expensive way to retrieve the head revision from a repository is the Info command.
using(SvnClient client = new SvnClient())
{
SvnInfoEventArgs info;
Uri repos = new Uri("http://my.server/svn/repos");
client.GetInfo(repos, out info);
Console.WriteLine(string.Format("The last revision of {0} is {1}", repos, info.Revision));
}
i googled also a lot but the only one thing which was working for me to get really the last revision was:
public static long GetRevision(String target)
{
SvnClient client = new SvnClient();
//SvnInfoEventArgs info;
//client.GetInfo(SvnTarget.FromString(target), out info); //Specify the repository root as Uri
//return info.Revision
//return info.LastChangeRevision
Collection<SvnLogEventArgs> info = new Collection<SvnLogEventArgs>();
client.GetLog(target, out info);
return info[0].Revision;
}
the other solutions are commented out. Try by yourself and see the difference . . .
I am checking the latest version of the working copy using SvnWorkingCopyClient:
var workingCopyClient = new SvnWorkingCopyClient();
SvnWorkingCopyVersion version;
workingCopyClient.GetVersion(workingFolder, out version);
The latest version of the local working repository is then available through
long localRev = version.End;
For a remote repository, use
var client = new SvnClient();
SvnInfoEventArgs info;
client.GetInfo(targetUri, out info);
long remoteRev = info.Revision;
instead.
This is similar to using the svnversion tool from the command line. Hope this helps.