There are two methods to fill the Source(s) for a SvnMerge-Operation:
org.tmatesoft.svn.core.wc2.SvnMerge.setSources
org.tmatesoft.svn.core.wc2.SvnMerge.setSources
The second method fails with a NullPointerException since svnkit 1.10.2
Sample code:
String path = “C:\sample”;
Strign fromUrl = “https://sample/svn/reposXXX/sample”;
Strign toUrl = “https://sample/svn/reposXXX/sample”;
long fromRev = 123456;
SVNClientManager thisClientManager = …
SVNDiffClient client = thisClientManager.getDiffClient();
SvnMerge merge = client.getOperationsFactory().createMerge();
SVNDiffOptions diffOptions = new SVNDiffOptions();
merge.setMergeOptions(diffOptions);
merge.setAllowMixedRevisions(true);
merge.addTarget(SvnTarget.fromFile(path));
merge.setDepth(SVNDepth.INFINITY);
merge.setIgnoreAncestry(true);
merge.setForce(false);
merge.setDryRun(true);
merge.setRecordOnly(false);
merge.setSources(SvnTarget.fromURL(SVNURL.parseURIEncoded(fromUrl), SVNRevision.create(fromRev)), SvnTarget.fromURL(SVNURL.parseURIEncoded(toUrl),SVNRevision.HEAD));
Stack-Trace:
at org.tmatesoft.svn.core.wc2.SvnMerge.getRevisionRanges(SvnMerge.java:207)
at org.tmatesoft.svn.core.internal.wc2.ng.SvnNgMerge.isApplicable(SvnNgMerge.java:37)
at org.tmatesoft.svn.core.internal.wc2.ng.SvnNgMerge.isApplicable(SvnNgMerge.java:30)
at org.tmatesoft.svn.core.wc2.SvnOperationFactory.getImplementation(SvnOperationFactory.java:1365)
at org.tmatesoft.svn.core.wc2.SvnOperationFactory.run(SvnOperationFactory.java:1227)
at org.tmatesoft.svn.core.wc2.SvnOperation.run(SvnOperation.java:294)
Failing code:
public Collection getRevisionRanges() {
if (ranges == null && EMULATE_AUTOMATIC_MERGE) {
SvnTarget source = getSource();
SVNRevision startRevision = SVNRevision.create(1);
SVNRevision endRevision = source.getPegRevision();
if (endRevision == null || endRevision == SVNRevision.UNDEFINED) {
endRevision = source.isURL() ? SVNRevision.HEAD : SVNRevision.WORKING;
}
final List revisionRanges = new ArrayList();
revisionRanges.add(SvnRevisionRange.create(startRevision, endRevision));
return revisionRanges;
}
return ranges;
}
The folling line above causes the NullPointerException
SVNRevision endRevision = source.getPegRevision();
source is null in this case (this is permitted because firstSource and secondSource are set)