Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get latest revision number from SharpSVN?

Tags:

c#

svn

sharpsvn

How to get latest revision number using SharpSVN?

like image 770
Tom Smykowski Avatar asked Mar 26 '09 08:03

Tom Smykowski


3 Answers

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));
}
like image 107
Bert Huijben Avatar answered Oct 16 '22 18:10

Bert Huijben


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.

like image 18
CJBrew Avatar answered Oct 16 '22 18:10

CJBrew


Ok, I figured it by myself:

SvnInfoEventArgs statuses;
client.GetInfo("svn://repo.address", out statuses);
int LastRevision = statuses.LastChangeRevision;
like image 9
Tom Smykowski Avatar answered Oct 16 '22 19:10

Tom Smykowski