org.eclipse.jgit.diff.Sequence s to create an
org.eclipse.jgit.diff.EditList of changes.
An algorithm's diff method must be callable from concurrent threads
without data collisions. This permits some algorithms to use a singleton
pattern, with concurrent invocations using the same singleton. Other
algorithms may support parameterization, in which case the caller can create
a unique instance per thread.
| Modifier and Type | Class and Description |
|---|---|
| public static enum | DiffAlgorithm.
Supported diff algorithm |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static <S extends Sequence> Edit | |
| public < type of sequence being compared. S extends Sequence> EditList | Returns: a modifiable edit list comparing the two sequences. If empty, the sequences are identical according tocmp's rules. The
result list is never null.the comparator supplying the element equivalence function. cmp, S the first (also known as old or pre-image) sequence. Edits
returned by this algorithm will reference indexes using the
'A' side: a, S org.,
org..the second (also known as new or post-image) sequence. Edits
returned by this algorithm will reference indexes using the
'B' side: b)org.,
org..Compare two sequences and identify a list of edits between them. |
| public abstract < type of sequence being compared. S extends Sequence> EditList | Returns: a modifiable edit list comparing the two sequences.the comparator supplying the element equivalence function. cmp, S the first (also known as old or pre-image) sequence. Edits
returned by this algorithm will reference indexes using the
'A' side: a, S org.,
org..the second (also known as new or post-image) sequence. Edits
returned by this algorithm will reference indexes using the
'B' side: b)org.,
org..Compare two sequences and identify a list of edits between them. |
| public static DiffAlgorithm | Returns: an implementation of the specified diff algorithmthe diff algorithm for which an implementation should be
returned algGet diff algorithm |
| private static < type of sequence being compared. S extends Sequence> EditList | Returns: a modifiable edit list with edit regions shifted to their latest possible location. The result list is never null.the comparator supplying the element equivalence function. cmp, EditList a modifiable edit list comparing the provided sequences. e, S the first (also known as old or pre-image) sequence. a, S the second (also known as new or post-image) sequence. b)Reorganize an |
| DiffAlgorithm | back to summary |
|---|---|
| public DiffAlgorithm() | |
| coverEdit | back to summary |
|---|---|
| private static <S extends Sequence> Edit coverEdit(S a, S b) | |
| diff | back to summary |
|---|---|
| public <S extends Sequence> EditList diff(SequenceComparator<? super S> cmp, S a, S b) Compare two sequences and identify a list of edits between them.
| |
| diffNonCommon | back to summary |
|---|---|
| public abstract <S extends Sequence> EditList diffNonCommon(SequenceComparator<? super S> cmp, S a, S b) Compare two sequences and identify a list of edits between them.
This method should be invoked only after the two sequences have been
proven to have no common starting or ending elements. The expected
elimination of common starting and ending elements is automatically
performed by the
| |
| getAlgorithm | back to summary |
|---|---|
| public static DiffAlgorithm getAlgorithm(DiffAlgorithm. Get diff algorithm
| |
| normalize | back to summary |
|---|---|
| private static <S extends Sequence> EditList normalize(SequenceComparator<? super S> cmp, EditList e, S a, S b) Reorganize an
-a -b -c a b ccan be shifted down by 1, 2 or 3 locations.
To avoid later merge issues, we shift such edits to a
consistent location. This strategy may not always produce an aesthetically pleasing diff. For instance, it works well with
function1 {
...
}
+function2 {
+ ...
+}
+
function3 {
...
}
but less so for
#
# comment1
#
function1() {
}
#
+# comment3
+#
+function3() {
+}
+
+#
# comment2
#
function2() {
}
More
sophisticated strategies are possible, say by calculating a
suitable "aesthetic cost" for each possible position and using
the lowest cost, but normalize just shifts edits
to the end as much as possible.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final DiffAlgorithm. | HISTOGRAM
Histogram diff algorithm |
| public static final DiffAlgorithm. | MYERS
Myers diff algorithm |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static DiffAlgorithm. | |
| public static DiffAlgorithm. |
| HISTOGRAM | back to summary |
|---|---|
| public static final DiffAlgorithm. Histogram diff algorithm | |
| MYERS | back to summary |
|---|---|
| public static final DiffAlgorithm. Myers diff algorithm | |
| SupportedAlgorithm | back to summary |
|---|---|
| private SupportedAlgorithm() | |
| valueOf | back to summary |
|---|---|
| public static DiffAlgorithm. | |
| values | back to summary |
|---|---|
| public static DiffAlgorithm. | |