Search code examples
version-controlsharpsvn

How do I tell if my local copy is out of date?


I'm experimenting with SharpSVN, I want to be able to know if my local copy is out of date.

I've created some update code:

public void UpdateSource()
{
  var svn = new SvnClient();
  SvnUpdateResult result;
  var boolValue = svn.Update(@"C:\Dev\EasyHttp\trunk", out result);
}

However I want to do something like this:

public void UpdateSource()
{
  var svn = new SvnClient();
  if(svn.IsOutOfDate(path))
  {
    SvnUpdateResult result;
    var boolValue = svn.Update(path, out result);
  }
}

Where the client checks the repository to see if any files are out of date and if so updates the entire checkout. Is there a way to do this?

I can see that inside SvnUpdateResult there is a Revision property, does this mean I have to store the last revision property or is there some indicator to say whether changes have been made?

For this application it's fine to update and see if there are changes but ideally I'd like to be able to check without updating my local copy.


Solution

  • Knowing how to use the command-line client will come in handy here, because it has a feature to do exactly this.

    With the command-line client, one can run svn status -u against a working copy to interrogate the server about any changes that exist there but have not been updated into the working copy.

    It appears that the equivalent in SharpSVN is to use the GetStatus() method (or possibly Status(), with an SvnStatusArgs parameter containing ContactRepository = true. See http://sharpsvntips.net/post/45301419716/getstatus-and-status for more.