InputStream sourceStream = null;
InputStream targetStream = null;
OutputStream tmpStream = null;
SVNDeltaCombiner deltaCombiner = getDeltaCombiner();
SVNDeltaGenerator deltaGenerator = getDeltaGenerator();
try {
if (compareRoot != null && comparePath != null) {
sourceStream = compareRoot.getFileStreamForPath(deltaCombiner, comparePath);
} else {
sourceStream = SVNFileUtil.DUMMY_IN;
}
targetStream = myRoot.getFileStreamForPath(deltaCombiner, canonicalPath);
tmpStream = SVNFileUtil.openFileForWriting(tmpFile);
final CountingStream countingStream = new CountingStream(tmpStream, 0);
ISVNDeltaConsumer consumer = new ISVNDeltaConsumer() {
private boolean isHeaderWritten = false;
public OutputStream textDeltaChunk(String path, SVNDiffWindow diffWindow) throws SVNException {
try {
if (diffWindow != null) {
diffWindow.writeTo(countingStream, !isHeaderWritten, false);
} else {
SVNDiffWindow.EMPTY.writeTo(countingStream, !isHeaderWritten, false);
}
} catch (IOException ioe) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getLocalizedMessage());
SVNErrorManager.error(err, ioe);
}
isHeaderWritten = true;
return SVNFileUtil.DUMMY_OUT;
}
public void applyTextDelta(String path, String baseChecksum) throws SVNException {
}
public void textDeltaEnd(String path) throws SVNException {
}
};
deltaGenerator.sendDelta(null, sourceStream, 0, targetStream, consumer, false);
txtLength = countingStream.getPosition();
} finally {
SVNFileUtil.closeFile(sourceStream);
SVNFileUtil.closeFile(targetStream);
SVNFileUtil.closeFile(tmpStream);