0

I am writing a Java program using the SVNKit API, and I need to use the correct class or call in the API that would allow me to find the diff between files stored in separate locations.

1st file:

https://abc.edc.xyz.corp/svn/di-edc/tags/ab-cde-fgh-axsym-1.0.0/src/site/apt/releaseNotes.apt

2nd file:

https://abc.edc.xyz.corp/svn/di-edc/tags/ab-cde-fgh-axsym-1.1.0/src/site/apt/releaseNotes.apt

I have used the listed API calls to generate the diff output, but I am unsuccessful so far.

DefaultSVNDiffGenerator diffGenerator = new DefaultSVNDiffGenerator();
diffGenerator.displayFileDiff("", file1, file2, "10983", "8971", "text", "text/plain", output);

diffClient.doDiff(svnUrl1, SVNRevision.create(10868), svnUrl2, SVNRevision.create(8971), SVNDepth.IMMEDIATES, false, System.out);

Can anyone provide guidance on the correct way to do this?

Sameer Singh
  • 1,358
  • 1
  • 19
  • 47
Fardu
  • 17
  • 1
  • 4

1 Answers1

2

Your code looks correct. But prefer using the new API:

    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(url1, svnRevision1), SvnTarget.fromURL(url2, svnRevision1));
        diff.setDiffGenerator(diffGenerator);
        diff.setOutput(byteArrayOutputStream);
        diff.run();
    } finally {
        svnOperationFactory.dispose();
    }
Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • SVNKit has some tests you can use them as examples. The code above I've copy-pasted from DiffTest (and removed test-related code). – Dmitry Pavlenko Sep 04 '13 at 16:06