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

public Class MergeResult<S extends Sequence>

extends Object
implements Iterable<MergeChunk>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Type Parameters
<S>
type of sequence.
Imports
java.util.Iterator, .List, org.eclipse.jgit.diff.Sequence, org.eclipse.jgit.merge.MergeChunk.ConflictState, org.eclipse.jgit.util.IntList

The result of merging a number of org.eclipse.jgit.diff.Sequence objects. These sequences have one common predecessor sequence. The result of a merge is a list of MergeChunks. Each MergeChunk contains either a range (a subsequence) from one of the merged sequences, a range from the common predecessor or a conflicting range from one of the merged sequences. A conflict will be reported as multiple chunks, one for each conflicting range. The first chunk for a conflict is marked specially to distinguish the border between two consecutive conflicts.

This class does not know anything about how to present the merge result to the end-user. MergeFormatters have to be used to construct something human readable.

Field Summary

Modifier and TypeField and Description
pack-priv final IntList
private boolean
private final List<S>
pack-priv static final MergeChunk.ConflictState[]

Constructor Summary

AccessConstructor and Description
public
MergeResult(List<S>
contains the common predecessor sequence at position 0 followed by the merged sequences. This list should not be modified anymore during the lifetime of this org.eclipse.jgit.merge.MergeResult.
sequences
)

Creates a new empty MergeResult

Method Summary

Modifier and TypeMethod and Description
public void
add(int
determines from which sequence this range comes. An index of x specifies the x+1 element in the list of sequences specified to the constructor
srcIdx
,
int
the first element from the specified sequence which should be included in the merge result. Indexes start with 0.
begin
,
int
specifies the end of the range to be added. The element this index points to is the first element which not added to the merge result. All elements between begin (including begin) and this element are added.
end
,
MergeChunk.ConflictState
when set to NO_CONLICT a non-conflicting range is added. This will end implicitly all open conflicts added before.
conflictState
)

Adds a new range from one of the merged sequences or from the common predecessor.

public boolean

Returns:

true if this merge result contains conflicts
containsConflicts
()

Whether this merge result contains conflicts

public List<S>

Returns:

the common predecessor at position 0 followed by the merged sequences.
getSequences
()

Returns the common predecessor sequence and the merged sequence in one list.

public Iterator<MergeChunk>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

protected void
setContainsConflicts(boolean
whether this merge should be seen as containing a conflict or not.
containsConflicts
)

Sets explicitly whether this merge should be seen as containing a conflict or not.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

chunksback to summary
pack-priv final IntList chunks
containsConflictsback to summary
private boolean containsConflicts
sequencesback to summary
private final List<S> sequences
statesback to summary
pack-priv static final MergeChunk.ConflictState[] states

Constructor Detail

MergeResultback to summary
public MergeResult(List<S> sequences)

Creates a new empty MergeResult

Parameters
sequences:List<S>

contains the common predecessor sequence at position 0 followed by the merged sequences. This list should not be modified anymore during the lifetime of this org.eclipse.jgit.merge.MergeResult.

Method Detail

addback to summary
public void add(int srcIdx, int begin, int end, MergeChunk.ConflictState conflictState)

Adds a new range from one of the merged sequences or from the common predecessor. This method can add conflicting and non-conflicting ranges controlled by the conflictState parameter

Parameters
srcIdx:int

determines from which sequence this range comes. An index of x specifies the x+1 element in the list of sequences specified to the constructor

begin:int

the first element from the specified sequence which should be included in the merge result. Indexes start with 0.

end:int

specifies the end of the range to be added. The element this index points to is the first element which not added to the merge result. All elements between begin (including begin) and this element are added.

conflictState:MergeChunk.ConflictState

when set to NO_CONLICT a non-conflicting range is added. This will end implicitly all open conflicts added before.

containsConflictsback to summary
public boolean containsConflicts()

Whether this merge result contains conflicts

Returns:boolean

true if this merge result contains conflicts

getSequencesback to summary
public List<S> getSequences()

Returns the common predecessor sequence and the merged sequence in one list. The common predecessor is the first element in the list

Returns:List<S>

the common predecessor at position 0 followed by the merged sequences.

iteratorback to summary
public Iterator<MergeChunk> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<MergeChunk>

an Iterator.

Annotations
@Override
setContainsConflictsback to summary
protected void setContainsConflicts(boolean containsConflicts)

Sets explicitly whether this merge should be seen as containing a conflict or not. Needed because during RecursiveMerger we want to do content-merges and take the resulting content (even with conflict markers!) as new conflict-free content

Parameters
containsConflicts:boolean

whether this merge should be seen as containing a conflict or not.

Since
3.5