localResult = QSequenceLineMedia.createBlocks(baseData, localData, null); latestResult = QSequenceLineMedia.createBlocks(baseData, latestData, null);
localResult = QSequenceLineMedia.createBlocks(baseData, localData); latestResult = QSequenceLineMedia.createBlocks(baseData, latestData);
	public int merge(QSequenceLineRAData baseData,	                 QSequenceLineRAData localData, QSequenceLineRAData latestData,	                 OutputStream result) throws IOException {//        dump("base", baseData);//        dump("latest", latestData);//        dump("local", localData);		final QSequenceLineResult localResult;		final QSequenceLineResult latestResult;		try {			localResult = QSequenceLineMedia.createBlocks(baseData, localData, null);			latestResult = QSequenceLineMedia.createBlocks(baseData, latestData, null);		}		catch (QSequenceException ex) {			throw new IOException(ex.getMessage());		}		try {			final QSequenceLineCache baseLines = localResult.getLeftCache();			final QSequenceLineCache localLines = localResult.getRightCache();			final QSequenceLineCache latestLines = latestResult.getRightCache();			final FSMergerBySequenceList local = new FSMergerBySequenceList(localResult.getBlocks());			final FSMergerBySequenceList latest = new FSMergerBySequenceList(latestResult.getBlocks());			int baseLineIndex = -1;			boolean conflict = false;			boolean merged = false;			while (local.hasCurrent() || latest.hasCurrent()) {				if (local.hasCurrent() && latest.hasCurrent() && isEqualChange(local.current(), latest.current(), localLines, latestLines)) {					baseLineIndex = appendLines(result, local.current(), localLines, baseLineIndex);					local.forward();					latest.forward();					continue;				}				if (local.hasCurrent() && latest.hasCurrent()) {					final QSequenceDifferenceBlock localStartBlock = local.current();					final QSequenceDifferenceBlock latestStartBlock = latest.current();					if (checkConflict(local, latest, localLines, latestLines, baseLines.getLineCount())) {						baseLineIndex = createConflict(result, localStartBlock, local.current(), latestStartBlock, latest								.current(), baseLines, localLines, latestLines, baseLineIndex);						local.forward();						latest.forward();						conflict = true;						continue;					}				}				if (local.hasCurrent() && isBefore(local.current(), latest.hasCurrent() ? latest.current() : null)) {					baseLineIndex = appendLines(result, local.current(), localLines, baseLineIndex);					local.forward();					merged = true;					continue;				}				if (latest.hasCurrent()) {					baseLineIndex = appendLines(result, latest.current(), latestLines, baseLineIndex);					latest.forward();					merged = true;					continue;				}			}			for (baseLineIndex++; baseLineIndex < baseLines.getLineCount(); baseLineIndex++) {				writeLine(result, baseLines.getLine(baseLineIndex));			}			if (conflict) {				return CONFLICTED;			}			else if (merged) {				return MERGED;			}			else {				return NOT_MODIFIED;			}		}		finally {			latestResult.close();			localResult.close();		}	}