Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get list of changed files in SharpSVN (like svn diff --summarize --xml)

Tags:

c#

svn

sharpsvn

I'm trying to get a list of changed files from SharpSVN. I can get the data I need on the command line like this:

svn diff -r <startrev>:HEAD --summarize --xml

Can somebody point me to the right spot in the SharpSVN maze to replicate this? Ideally, I'd be able to get a collection of the changed files out, but I can parse a stream if needs be.

like image 676
Peter Loron Avatar asked Mar 17 '12 00:03

Peter Loron


2 Answers

The SharpSvn equivalent of svn diff --summarize is SvnClient.DiffSummary().

You can use it as

using (var client = new SvnClient())
{
   var location = new Uri("http://my.example/repos/trunk");
   client.DiffSummary(new SvnUriTarget(location, 12), new SvnUriTarget(location, SvnRevision.Head),
                      delegate(object sender, SvnDiffSummaryEventArgs e)
                      {
                        // TODO: Handle result
                      });
}

when you want the results as they come in.

Or you can use .GetDiffSummary() if you want to access the final result as a list.

like image 135
Bert Huijben Avatar answered Sep 18 '22 22:09

Bert Huijben


there is simplest way to do that but here is some different approch :

with sharpsvn use the Status command to retrive the all files status in both WorkingCopy and Repository Status and then compare between them

example :

using (SvnClient cl = new SvnClient())
  cl.Status(YourPath, new SvnStatusArgs {
    Depth = SvnDepth.Infinity, ThrowOnError = true,
    RetrieveRemoteStatus = true, Revision = SvnRevision.Head}, 
    new EventHandler<SvnStatusEventArgs>(
       delegate(object s, SvnStatusEventArgs e) {
          switch (e.LocalContentStatus) {
             case SvnStatus.Normal:break;
             case SvnStatus.None: break;
             case SvnStatus.NotVersioned: break;
             case SvnStatus.Added:break;
             case SvnStatus.Missing: break;
             case SvnStatus.Modified: break;
             case SvnStatus.Conflicted: break;
             default: break;
          }
          switch (e.RemoteContentStatus) {
             case SvnStatus.Normal:break;
             case SvnStatus.None: break;
             case SvnStatus.NotVersioned: break;
             case SvnStatus.Added:break;
             case SvnStatus.Missing: break;
             case SvnStatus.Modified: break;
             case SvnStatus.Conflicted: break;
             default: break;
          }
       }));
like image 28
foxdanni Avatar answered Sep 21 '22 22:09

foxdanni