I want to get the Diffs between two revisions using SvnKit. I have looked at the documentation and found this method in SVNRepository
class but it checks only the diff between a local copy and a remote one.
diff(SVNURL url, long targetRevision, long revision, java.lang.String target, boolean ignoreAncestry, SVNDepth depth, boolean getContents, ISVNReporterBaton reporter, ISVNEditor editor)
is there anyway to get the diff for a certain repository for a range of revisions without downloading the repository ?
There're several APIs in SVNKit and SVNRepository-based API is the most low level, you need to have decent experience in working with Subversion internals to use it.
Instead it's better to use SvnOperationFactory-based API that works very similarly to "svn diff" command.
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
try {
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final SvnDiffGenerator diffGenerator = new SvnDiffGenerator();
diffGenerator.setBasePath(new File(""));
final SvnDiff diff = svnOperationFactory.createDiff();
diff.setSources(SvnTarget.fromURL(url, SVNRevision.create(revision1)), url, SVNRevision.create(revision2)));
diff.setDiffGenerator(diffGenerator);
diff.setOutput(byteArrayOutputStream);
diff.run();
} finally {
svnOperationFactory.dispose();
}
It calls SVNRepository#diff does a lot of work except that. If you need more control on the output, you can implement your own ISvnDiffGenerator and pass it to the operation.