Top Description Fields Constructors Methods
org.eclipse.jgit.merge

public final Class MergeAlgorithm

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Iterator, .List, org.eclipse.jgit.annotations.NonNull, org.eclipse.jgit.diff.DiffAlgorithm, .Edit, .EditList, .HistogramDiff, .Sequence, .SequenceComparator, org.eclipse.jgit.merge.MergeChunk.ConflictState

Provides the merge algorithm which does a three-way merge on content provided as RawText. By default org.eclipse.jgit.diff.HistogramDiff is used as diff algorithm.

Field Summary

Modifier and TypeField and Description
private final DiffAlgorithm
private static final Edit
private ContentMergeStrategy

Constructor Summary

AccessConstructor and Description
public
MergeAlgorithm()

Creates a new MergeAlgorithm which uses org.eclipse.jgit.diff.HistogramDiff as diff algorithm

public
MergeAlgorithm(DiffAlgorithm
the diff algorithm used by this merge
diff
)

Creates a new MergeAlgorithm

Method Summary

Modifier and TypeMethod and Description
public ContentMergeStrategy
private static boolean
public <
type of the sequences
S extends Sequence
>
MergeResult<S>

Returns:

the resulting content
merge
(SequenceComparator<S>
comparison method for this execution.
cmp
,
S
the common base sequence
base
,
S
the first sequence to be merged
ours
,
S
the second sequence to be merged
theirs
)

Does the three way merge between a common base and two sequences.

private static Edit

Returns:

the next edit from the iterator or END_EDIT if there no more edits
nextEdit
(Iterator<Edit>
the iterator for which the next edit should be returned
it
)

Helper method which returns the next Edit for an Iterator over Edits.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

diffAlgback to summary
private final DiffAlgorithm diffAlg
END_EDITback to summary
private static final Edit END_EDIT
strategyback to summary
private ContentMergeStrategy strategy
Annotations
@NonNull

Constructor Detail

MergeAlgorithmback to summary
public MergeAlgorithm()

Creates a new MergeAlgorithm which uses org.eclipse.jgit.diff.HistogramDiff as diff algorithm

MergeAlgorithmback to summary
public MergeAlgorithm(DiffAlgorithm diff)

Creates a new MergeAlgorithm

Parameters
diff:DiffAlgorithm

the diff algorithm used by this merge

Method Detail

getContentMergeStrategyback to summary
public ContentMergeStrategy getContentMergeStrategy()

Retrieves the ContentMergeStrategy.

Returns:ContentMergeStrategy

the ContentMergeStrategy in effect

Annotations
@NonNull
Since
5.12
isEndEditback to summary
private static boolean isEndEdit(Edit edit)
Annotations
@SuppressWarnings:ReferenceEquality
mergeback to summary
public <S extends Sequence> MergeResult<S> merge(SequenceComparator<S> cmp, S base, S ours, S theirs)

Does the three way merge between a common base and two sequences.

Parameters
<S>
type of the sequences
cmp:SequenceComparator<S>

comparison method for this execution.

base:S

the common base sequence

ours:S

the first sequence to be merged

theirs:S

the second sequence to be merged

Returns:MergeResult<S>

the resulting content

nextEditback to summary
private static Edit nextEdit(Iterator<Edit> it)

Helper method which returns the next Edit for an Iterator over Edits. When there are no more edits left this method will return the constant END_EDIT.

Parameters
it:Iterator<Edit>

the iterator for which the next edit should be returned

Returns:Edit

the next edit from the iterator or END_EDIT if there no more edits

setContentMergeStrategyback to summary
public void setContentMergeStrategy(ContentMergeStrategy strategy)

Sets the ContentMergeStrategy.

Parameters
strategy:ContentMergeStrategy

ContentMergeStrategy to set; if null, set ContentMergeStrategy#CONFLICT

Since
5.12