0

I would like to use SVNDiffClient to get wc local changes, equivalent of 'svn diff -rBASE', which is exactly what this example is suposed to do.

However, running the code from example throws 'org.tmatesoft.svn.core.SVNException: svn: At least one revision must be non-local for a pegged diff', which is exactly what documentation says it would.

I would like to be able to compare WORKING to BASE without hitting the server, to see if there were any changes. Can this be accomplished using SVNKit?

mkvcvc
  • 1,515
  • 1
  • 18
  • 41

2 Answers2

1

You may use new API:

    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    final SvnDiff diff = svnOperationFactory.createDiff();
    diff.setSources(SvnTarget.fromFile(workingCopyDirectory, SVNRevision.BASE), SvnTarget.fromFile(workingCopyDirectory, SVNRevision.WORKING));
    diff.setOutput(byteArrayOutputStream);
    diff.run();
Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
1

You may also use old API:

final SVNClientManager clientManager = SVNClientManager.newInstance();
try {
    final SVNDiffClient diffClient = clientManager.getDiffClient();

    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    diffClient.doDiff(workingCopyDirectory, SVNRevision.BASE, workingCopyDirectory, SVNRevision.WORKING, SVNDepth.INFINITY, false, outputStream, null);

    System.out.println(outputStream);
} finally {
    clientManager.dispose();
}
Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38