if (toSkip > 0) {
applyBaton.mySourceStream.skip(toSkip);
}
applyBaton.mySourceStream.read(applyBaton.mySourceBuffer, length, applyBaton.mySourceBuffer.length - length);
} catch (IOException e) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage());
SVNErrorManager.error(err, e, SVNLogType.DEFAULT);
}
}
// update offsets in baton.
applyBaton.mySourceViewLength = getSourceViewLength();
applyBaton.mySourceViewOffset = getSourceViewOffset();
// apply instructions.
int tpos = 0;
int npos = myInstructionsLength;
try {
for (Iterator instructions = instructions(true); instructions.hasNext();) {
SVNDiffInstruction instruction = (SVNDiffInstruction) instructions.next();
int iLength = instruction.length < getTargetViewLength() - tpos ? (int) instruction.length : getTargetViewLength() - tpos;
switch (instruction.type) {
case SVNDiffInstruction.COPY_FROM_NEW_DATA:
System.arraycopy(myData, myDataOffset + npos, applyBaton.myTargetBuffer, tpos, iLength);
npos += iLength;
break;
case SVNDiffInstruction.COPY_FROM_TARGET:
int start = instruction.offset;
int end = instruction.offset + iLength;
int tIndex = tpos;
for(int j = start; j < end; j++) {
applyBaton.myTargetBuffer[tIndex] = applyBaton.myTargetBuffer[j];
tIndex++;
}
break;
case SVNDiffInstruction.COPY_FROM_SOURCE:
System.arraycopy(applyBaton.mySourceBuffer, instruction.offset, applyBaton.myTargetBuffer, tpos, iLength);
break;
default:
}
tpos += instruction.length;
if (tpos >= getTargetViewLength()) {
break;
}
}
// save tbuffer.
if (applyBaton.myDigest != null) {
applyBaton.myDigest.update(applyBaton.myTargetBuffer, 0, getTargetViewLength());
}
applyBaton.myTargetStream.write(applyBaton.myTargetBuffer, 0, getTargetViewLength());
} catch (IOException e) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage());
SVNErrorManager.error(err, e, SVNLogType.DEFAULT);
}
}