Source:
protected void copyDiff(Diff target, Monitor monitor, boolean rightToLeft) { if (!shouldMerge(target)) { return; } long start = System.currentTimeMillis(); target.setState(DifferenceState.MERGING); boolean requiresMerging = requiresMerging(target, rightToLeft); final Set<Diff> dependencies = getDirectMergeDependencies(target, rightToLeft); for (Diff dependency : dependencies) { if (dependency.getState() != DifferenceState.MERGING) { mergeDiff(dependency, rightToLeft, monitor); } } if (requiresMerging && target.getState() != DifferenceState.MERGED) { if (rightToLeft && target.getSource() != DifferenceSource.LEFT || !rightToLeft && target.getSource() == DifferenceSource.LEFT) { accept(target, rightToLeft); } else { reject(target, rightToLeft); } } target.setState(DifferenceState.MERGED); Set<Diff> impliedMerges = getImpliedMerges(target, rightToLeft); while (!impliedMerges.isEmpty()) { Diff impliedMerge = impliedMerges.iterator().next(); if (impliedMerge.getState() != DifferenceState.MERGED) { impliedMerge.setState(DifferenceState.MERGED); impliedMerges.addAll(getImpliedMerges(impliedMerge, rightToLeft)); } impliedMerges.remove(impliedMerge); } final Set<Diff> linked = getLogicallyResultingMerges(target, rightToLeft); for (Diff mergeMe : linked) { mergeDiff(mergeMe, rightToLeft, monitor); } if (LOGGER.isDebugEnabled()) { long duration = System.currentTimeMillis() - start; if (rightToLeft) { LOGGER.debug("copyDiff(Diff, Monitor, Boolean) - diff " + target.hashCode() + " merged from right to left in " + duration + "ms"); } else { LOGGER.debug("copyDiff(Diff, Monitor, Boolean) - diff " + target.hashCode() + " merged from left to right in " + duration + "ms"); } } }

Target:
protected void copyDiff(Diff target, Monitor monitor, boolean rightToLeft) { if (isInTerminalState(target)) { return; } long start = System.currentTimeMillis(); target.setState(MERGING); boolean requiresMerging = requiresMerging(target, rightToLeft); final Set<Diff> dependencies = getDirectMergeDependencies(target, rightToLeft); for (Diff dependency : dependencies) { if (dependency.getState() != MERGING) { mergeDiff(dependency, rightToLeft, monitor); } } if (requiresMerging && !isInTerminalState(target)) { if (isAccepting(target, rightToLeft)) { accept(target, rightToLeft); } else { reject(target, rightToLeft); } target.setState(MERGED); } if (isInTerminalState(target)) { Set<Diff> impliedMerges = getImpliedMerges(target, rightToLeft); while (!impliedMerges.isEmpty()) { Diff impliedMerge = impliedMerges.iterator().next(); if (!isInTerminalState(impliedMerge)) { impliedMerge.setState(target.getState()); impliedMerges.addAll(getImpliedMerges(impliedMerge, rightToLeft)); } impliedMerges.remove(impliedMerge); } } final Set<Diff> linked = getLogicallyResultingMerges(target, rightToLeft); for (Diff mergeMe : linked) { mergeDiff(mergeMe, rightToLeft, monitor); } if (!isInTerminalState(target)) { throw new IllegalStateException("Diff must be in terminal state after merge."); } if (LOGGER.isDebugEnabled()) { long duration = System.currentTimeMillis() - start; if (rightToLeft) { LOGGER.debug("copyDiff(Diff, Monitor, Boolean) - diff " + target.hashCode() + " merged from right to left in " + duration + "ms"); } else { LOGGER.debug("copyDiff(Diff, Monitor, Boolean) - diff " + target.hashCode() + " merged from left to right in " + duration + "ms"); } } }