Package org.eclipse.jgit.notes
Class NoteMapMerger
- java.lang.Object
-
- org.eclipse.jgit.notes.NoteMapMerger
-
public class NoteMapMerger extends java.lang.ObjectThree-way note tree merge.Direct implementation of NoteMap merger without using
TreeWalkandAbstractTreeIterator
-
-
Field Summary
Fields Modifier and Type Field Description private Repositorydbprivate static FanoutBucketEMPTY_FANOUTprivate static LeafBucketEMPTY_LEAFprivate ObjectInserterinserterprivate MergeStrategynonNotesMergeStrategyprivate NoteMergernoteMergerprivate MutableObjectIdobjectIdPrefixprivate ObjectReaderreader
-
Constructor Summary
Constructors Constructor Description NoteMapMerger(Repository db)Constructs a NoteMapMerger withDefaultNoteMergeras the merger for notes and theMergeStrategy.RESOLVEas the strategy for resolving conflicts on non-notesNoteMapMerger(Repository db, NoteMerger noteMerger, MergeStrategy nonNotesMergeStrategy)Constructs a NoteMapMerger with customNoteMergerand customMergeStrategy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddIfNotNull(FanoutBucket b, int cell, NoteBucket child)private static InMemoryNoteBucketaddIfNotNull(InMemoryNoteBucket result, Note note)private FanoutBucketasFanout(InMemoryNoteBucket bucket)private static booleanequals(NoteBucket a, NoteBucket b)private static Noteget(LeafBucket b, int i)private InMemoryNoteBucketmerge(int treeDepth, InMemoryNoteBucket base, InMemoryNoteBucket ours, InMemoryNoteBucket theirs)This method is called only when it is known that there is some difference between base, ours and theirs.NoteMapmerge(NoteMap base, NoteMap ours, NoteMap theirs)Performs the merge.private InMemoryNoteBucketmergeFanoutBucket(int treeDepth, FanoutBucket base, FanoutBucket ours, FanoutBucket theirs)private InMemoryNoteBucketmergeLeafBucket(int treeDepth, LeafBucket bb, LeafBucket ob, LeafBucket tb)private NonNoteEntrymergeNonNotes(NonNoteEntry baseList, NonNoteEntry oursList, NonNoteEntry theirsList)private static Notemin(Note b, Note o, Note t)private static NonNoteEntrynonNotes(InMemoryNoteBucket b)private static LeafBucketnotNullOrEmpty(LeafBucket b)private static booleansameContent(Note a, Note b)private static booleansameNote(Note a, Note b)private static NotesameNoteOrNull(Note min, Note other)private ObjectIdwrite(NonNoteEntry list)
-
-
-
Field Detail
-
EMPTY_FANOUT
private static final FanoutBucket EMPTY_FANOUT
-
EMPTY_LEAF
private static final LeafBucket EMPTY_LEAF
-
db
private final Repository db
-
noteMerger
private final NoteMerger noteMerger
-
nonNotesMergeStrategy
private final MergeStrategy nonNotesMergeStrategy
-
reader
private final ObjectReader reader
-
inserter
private final ObjectInserter inserter
-
objectIdPrefix
private final MutableObjectId objectIdPrefix
-
-
Constructor Detail
-
NoteMapMerger
public NoteMapMerger(Repository db, NoteMerger noteMerger, MergeStrategy nonNotesMergeStrategy)
Constructs a NoteMapMerger with customNoteMergerand customMergeStrategy.- Parameters:
db- Git repositorynoteMerger- note merger for merging conflicting changes on a notenonNotesMergeStrategy- merge strategy for merging non-note entries
-
NoteMapMerger
public NoteMapMerger(Repository db)
Constructs a NoteMapMerger withDefaultNoteMergeras the merger for notes and theMergeStrategy.RESOLVEas the strategy for resolving conflicts on non-notes- Parameters:
db- Git repository
-
-
Method Detail
-
merge
public NoteMap merge(NoteMap base, NoteMap ours, NoteMap theirs) throws java.io.IOException
Performs the merge.- Parameters:
base- base version of the note treeours- ours version of the note treetheirs- theirs version of the note tree- Returns:
- merge result as a new NoteMap
- Throws:
java.io.IOException
-
merge
private InMemoryNoteBucket merge(int treeDepth, InMemoryNoteBucket base, InMemoryNoteBucket ours, InMemoryNoteBucket theirs) throws java.io.IOException
This method is called only when it is known that there is some difference between base, ours and theirs.- Parameters:
treeDepth-base-ours-theirs-- Returns:
- merge result as an InMemoryBucket
- Throws:
java.io.IOException
-
asFanout
private FanoutBucket asFanout(InMemoryNoteBucket bucket)
-
nonNotes
private static NonNoteEntry nonNotes(InMemoryNoteBucket b)
-
mergeFanoutBucket
private InMemoryNoteBucket mergeFanoutBucket(int treeDepth, FanoutBucket base, FanoutBucket ours, FanoutBucket theirs) throws java.io.IOException
- Throws:
java.io.IOException
-
equals
private static boolean equals(NoteBucket a, NoteBucket b)
-
addIfNotNull
private void addIfNotNull(FanoutBucket b, int cell, NoteBucket child) throws java.io.IOException
- Throws:
java.io.IOException
-
mergeLeafBucket
private InMemoryNoteBucket mergeLeafBucket(int treeDepth, LeafBucket bb, LeafBucket ob, LeafBucket tb) throws MissingObjectException, java.io.IOException
- Throws:
MissingObjectExceptionjava.io.IOException
-
notNullOrEmpty
private static LeafBucket notNullOrEmpty(LeafBucket b)
-
get
private static Note get(LeafBucket b, int i)
-
addIfNotNull
private static InMemoryNoteBucket addIfNotNull(InMemoryNoteBucket result, Note note)
-
mergeNonNotes
private NonNoteEntry mergeNonNotes(NonNoteEntry baseList, NonNoteEntry oursList, NonNoteEntry theirsList) throws java.io.IOException
- Throws:
java.io.IOException
-
write
private ObjectId write(NonNoteEntry list) throws java.io.IOException
- Throws:
java.io.IOException
-
-