int toSkip = getSourceViewOffset() - (applyBaton.mySourceViewOffset + applyBaton.mySourceViewLength);
int toSkip = (int) (getSourceViewOffset() - (applyBaton.mySourceViewOffset + applyBaton.mySourceViewLength));
    public void apply(SVNDiffWindowApplyBaton applyBaton) throws SVNException {        // here we have streams and buffer from the previous calls (or nulls).                // 1. buffer for target.        if (applyBaton.myTargetBuffer == null || applyBaton.myTargetViewSize < getTargetViewLength()) {            applyBaton.myTargetBuffer = new byte[getTargetViewLength()];        }        applyBaton.myTargetViewSize = getTargetViewLength();                // 2. buffer for source.        int length = 0;        if (getSourceViewOffset() != applyBaton.mySourceViewOffset || getSourceViewLength() > applyBaton.mySourceViewLength) {            byte[] oldSourceBuffer = applyBaton.mySourceBuffer;            // create a new buffer            applyBaton.mySourceBuffer = new byte[getSourceViewLength()];            // copy from the old buffer.            if (applyBaton.mySourceViewOffset + applyBaton.mySourceViewLength > getSourceViewOffset()) {                // copy overlapping part to the new buffer                int start = (getSourceViewOffset() - applyBaton.mySourceViewOffset);                System.arraycopy(oldSourceBuffer, start, applyBaton.mySourceBuffer, 0, (applyBaton.mySourceViewLength - start));                length = (applyBaton.mySourceViewLength - start);            }                    }        if (length < getSourceViewLength()) {            // fill what remains.            try {                int toSkip = getSourceViewOffset() - (applyBaton.mySourceViewOffset + applyBaton.mySourceViewLength);                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);            }        }        // 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);        }    }