Reputation: 317
I am trying to use SVNKit to do a simple: svn diff url {date1}:{date2}
.
I cannot figure out how to use it on SVNKit. Does anyone know how to do this?
Upvotes: 1
Views: 1109
Reputation: 8968
SVNKit's SVNRevision
class has a static method that constructs it from java.util.Date instance, this is an analog of SVN's {date}.
To run diff
1 . Prepare diff generator that is responsible for formatting the patch (SVN format, Git format and GNU format (with SvnNewGenerator wrapper) are supported). The most interesting setting is base path --- all paths are relative to it, as it is possible (subversion always uses current path --- new File("") --- but you can use any other).
final SvnDiffGenerator diffGenerator = new SvnDiffGenerator();
diffGenerator.setBasePath(new File(""));
2 . Prepare output stream for the resulting patch
final OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
3 . Run diff
final SvnDiff diff = svnOperationFactory.createDiff();
diff.setSource(SvnTarget.fromURL(url), SVNRevision.create(date1), SVNRevision.create(date2));
diff.setDiffGenerator(diffGenerator);
diff.setOutput(byteArrayOutputStream);
diff.run();
You can discover more settings by playing with SvnDiff and SvnDiffGenerator setters.
Upvotes: 2