if (getSVNEnvironment().getTargets() != null) {
targets.addAll(getSVNEnvironment().getTargets());
}
targets = getSVNEnvironment().combineTargets(targets, true);
SVNPath oldTarget = null;
SVNPath newTarget = null;
SVNRevision start = getSVNEnvironment().getStartRevision();
SVNRevision end = getSVNEnvironment().getEndRevision();
boolean peggedDiff = false;
if (targets.size() == 2 &&
getSVNEnvironment().getOldTarget() == null &&
getSVNEnvironment().getNewTarget() == null &&
SVNCommandUtil.isURL((String) targets.get(0)) &&
SVNCommandUtil.isURL((String) targets.get(1)) &&
getSVNEnvironment().getStartRevision() == SVNRevision.UNDEFINED &&
getSVNEnvironment().getEndRevision() == SVNRevision.UNDEFINED) {
oldTarget = new SVNPath((String) targets.get(0), true);
newTarget = new SVNPath((String) targets.get(1), true);
start = oldTarget.getPegRevision();
end = newTarget.getPegRevision();
targets.clear();
if (start == SVNRevision.UNDEFINED) {
start = SVNRevision.HEAD;
}
if (end == SVNRevision.UNDEFINED) {
end = SVNRevision.HEAD;
}
} else if (getSVNEnvironment().getOldTarget() != null) {
targets.clear();
targets.add(getSVNEnvironment().getOldTarget());
targets.add(getSVNEnvironment().getNewTarget() != null ? getSVNEnvironment().getNewTarget() : getSVNEnvironment().getOldTarget());
oldTarget = new SVNPath((String) targets.get(0), true);
newTarget = new SVNPath((String) targets.get(1), true);
start = getSVNEnvironment().getStartRevision();
end = getSVNEnvironment().getEndRevision();
if (oldTarget.getPegRevision() != SVNRevision.UNDEFINED) {
start = oldTarget.getPegRevision();
}
if (newTarget.getPegRevision() != SVNRevision.UNDEFINED) {
end = newTarget.getPegRevision();
}
if (start == SVNRevision.UNDEFINED) {
start = oldTarget.isURL() ? SVNRevision.HEAD : SVNRevision.BASE;
}
if (end == SVNRevision.UNDEFINED) {
end = newTarget.isURL() ? SVNRevision.HEAD : SVNRevision.WORKING;
}
targets = getSVNEnvironment().combineTargets(null, true);
} else if (getSVNEnvironment().getNewTarget() != null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR,
"'--new' option only valid with '--old' option");
SVNErrorManager.error(err, SVNLogType.CLIENT);
} else {
if (targets.isEmpty()) {
targets.add("");
}
oldTarget = new SVNPath("");
newTarget = new SVNPath("");
boolean hasURLs = false;
boolean hasWCs = false;
for(int i = 0; i < targets.size(); i++) {
SVNPath target = new SVNPath((String) targets.get(i));
hasURLs |= target.isURL();
hasWCs |= target.isFile();
}
if (hasURLs && hasWCs) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Target lists to diff may not contain both working copy paths and URLs");
SVNErrorManager.error(err, SVNLogType.CLIENT);
}
start = getSVNEnvironment().getStartRevision();
end = getSVNEnvironment().getEndRevision();
if (start == SVNRevision.UNDEFINED && hasWCs) {
start = SVNRevision.BASE;
}
if (end == SVNRevision.UNDEFINED) {
end = hasWCs ? SVNRevision.WORKING : SVNRevision.HEAD;
}
peggedDiff = (start != SVNRevision.BASE && start != SVNRevision.WORKING) || (end != SVNRevision.BASE && end != SVNRevision.WORKING);
}
if (targets.isEmpty()) {
targets.add("");
}
SVNDiffClient client = getSVNEnvironment().getClientManager().getDiffClient();
DefaultSVNDiffGenerator diffGenerator = new DefaultSVNDiffGenerator();
if (getSVNEnvironment().getDiffCommand() != null) {
diffGenerator.setExternalDiffCommand(getSVNEnvironment().getDiffCommand());
diffGenerator.setRawDiffOptions(getSVNEnvironment().getExtensions());
} else {
diffGenerator.setDiffOptions(getSVNEnvironment().getDiffOptions());
}
diffGenerator.setDiffDeleted(!getSVNEnvironment().isNoDiffDeleted());
diffGenerator.setForcedBinaryDiff(getSVNEnvironment().isForce());
diffGenerator.setBasePath(new File("").getAbsoluteFile());
diffGenerator.setFallbackToAbsolutePath(true);
diffGenerator.setOptions(client.getOptions());
client.setDiffGenerator(diffGenerator);
PrintStream ps = getSVNEnvironment().getOut();
Collection changeLists = getSVNEnvironment().getChangelistsCollection();
for(int i = 0; i < targets.size(); i++) {
String targetName = (String) targets.get(i);
if (!peggedDiff) {
SVNPath target1 = new SVNPath(SVNPathUtil.append(oldTarget.getTarget(), targetName));
SVNPath target2 = new SVNPath(SVNPathUtil.append(newTarget.getTarget(), targetName));
if (getSVNEnvironment().isSummarize()) {
if (target1.isURL() && target2.isURL()) {
client.doDiffStatus(target1.getURL(), start, target2.getURL(), end, getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), this);
} else if (target1.isURL()) {
client.doDiffStatus(target1.getURL(), start, target2.getFile(), end, getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), this);
} else if (target2.isURL()) {
client.doDiffStatus(target1.getFile(), start, target2.getURL(), end, getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), this);
} else {
client.doDiffStatus(target1.getFile(), start, target2.getFile(), end, getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), this);
}
} else {
if (target1.isURL() && target2.isURL()) {
client.doDiff(target1.getURL(), start, target2.getURL(), end,
getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), ps);
} else if (target1.isURL()) {
client.doDiff(target1.getURL(), start, target2.getFile(), end,
getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), ps,
changeLists);
} else if (target2.isURL()) {
client.doDiff(target1.getFile(), start, target2.getURL(), end,
getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), ps,
changeLists);
} else {
client.doDiff(target1.getFile(), start, target2.getFile(), end,
getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), ps,
changeLists);
}
}
} else {
SVNPath target = new SVNPath(targetName, true);
SVNRevision pegRevision = target.getPegRevision();
if (pegRevision == SVNRevision.UNDEFINED) {
pegRevision = target.isURL() ? SVNRevision.HEAD : SVNRevision.WORKING;
}
if (getSVNEnvironment().isSummarize()) {
if (target.isURL()) {
client.doDiffStatus(target.getURL(), start, end, pegRevision, getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), this);
} else {
client.doDiffStatus(target.getFile(), start, end, pegRevision, getSVNEnvironment().getDepth(), getSVNEnvironment().isNoticeAncestry(), this);
}
} else {
if (target.isURL()) {
client.doDiff(target.getURL(), pegRevision, start, end, getSVNEnvironment().getDepth(),
getSVNEnvironment().isNoticeAncestry(), ps);
} else {
client.doDiff(target.getFile(), pegRevision, start, end, getSVNEnvironment().getDepth(),
getSVNEnvironment().isNoticeAncestry(), ps, changeLists);
}
}
}
}