1

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Did I ever tell you that you are my hero!? THANKS A LOT!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.