diff options
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java index 2c8386b8c2..a2a0ee6abd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java @@ -51,6 +51,7 @@ import org.eclipse.jgit.diff.Edit; import org.eclipse.jgit.diff.EditList; import org.eclipse.jgit.diff.MyersDiff; import org.eclipse.jgit.diff.Sequence; +import org.eclipse.jgit.diff.SequenceComparator; import org.eclipse.jgit.merge.MergeChunk.ConflictState; /** @@ -74,21 +75,24 @@ public final class MergeAlgorithm { /** * Does the three way merge between a common base and two sequences. * + * @param <S> + * type of sequence. + * @param cmp comparison method for this execution. * @param base the common base sequence * @param ours the first sequence to be merged * @param theirs the second sequence to be merged * @return the resulting content */ - public static MergeResult merge(Sequence base, Sequence ours, - Sequence theirs) { - List<Sequence> sequences = new ArrayList<Sequence>(3); + public static <S extends Sequence> MergeResult<S> merge( + SequenceComparator<S> cmp, S base, S ours, S theirs) { + List<S> sequences = new ArrayList<S>(3); sequences.add(base); sequences.add(ours); sequences.add(theirs); - MergeResult result = new MergeResult(sequences); - EditList oursEdits = new MyersDiff(base, ours).getEdits(); + MergeResult result = new MergeResult<S>(sequences); + EditList oursEdits = new MyersDiff<S>(cmp, base, ours).getEdits(); Iterator<Edit> baseToOurs = oursEdits.iterator(); - EditList theirsEdits = new MyersDiff(base, theirs).getEdits(); + EditList theirsEdits = new MyersDiff<S>(cmp, base, theirs).getEdits(); Iterator<Edit> baseToTheirs = theirsEdits.iterator(); int current = 0; // points to the next line (first line is 0) of base // which was not handled yet @@ -201,13 +205,13 @@ public final class MergeAlgorithm { - theirsBeginB); int commonPrefix = 0; while (commonPrefix < conflictLen - && ours.equals(oursBeginB + commonPrefix, theirs, + && cmp.equals(ours, oursBeginB + commonPrefix, theirs, theirsBeginB + commonPrefix)) commonPrefix++; conflictLen -= commonPrefix; int commonSuffix = 0; while (commonSuffix < conflictLen - && ours.equals(oursEndB - commonSuffix - 1, theirs, + && cmp.equals(ours, oursEndB - commonSuffix - 1, theirs, theirsEndB - commonSuffix - 1)) commonSuffix++; conflictLen -= commonSuffix; |