Package org.eclipse.jgit.notes
Class NoteMapMerger
- java.lang.Object
-
- org.eclipse.jgit.notes.NoteMapMerger
-
public class NoteMapMerger extends java.lang.Object
Three-way note tree merge.Direct implementation of NoteMap merger without using
TreeWalk
andAbstractTreeIterator
-
-
Field Summary
Fields Modifier and Type Field Description private Repository
db
private static FanoutBucket
EMPTY_FANOUT
private static LeafBucket
EMPTY_LEAF
private ObjectInserter
inserter
private MergeStrategy
nonNotesMergeStrategy
private NoteMerger
noteMerger
private MutableObjectId
objectIdPrefix
private ObjectReader
reader
-
Constructor Summary
Constructors Constructor Description NoteMapMerger(Repository db)
Constructs a NoteMapMerger withDefaultNoteMerger
as the merger for notes and theMergeStrategy.RESOLVE
as the strategy for resolving conflicts on non-notesNoteMapMerger(Repository db, NoteMerger noteMerger, MergeStrategy nonNotesMergeStrategy)
Constructs a NoteMapMerger with customNoteMerger
and customMergeStrategy
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addIfNotNull(FanoutBucket b, int cell, NoteBucket child)
private static InMemoryNoteBucket
addIfNotNull(InMemoryNoteBucket result, Note note)
private FanoutBucket
asFanout(InMemoryNoteBucket bucket)
private static boolean
equals(NoteBucket a, NoteBucket b)
private static Note
get(LeafBucket b, int i)
private InMemoryNoteBucket
merge(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.NoteMap
merge(NoteMap base, NoteMap ours, NoteMap theirs)
Performs the merge.private InMemoryNoteBucket
mergeFanoutBucket(int treeDepth, FanoutBucket base, FanoutBucket ours, FanoutBucket theirs)
private InMemoryNoteBucket
mergeLeafBucket(int treeDepth, LeafBucket bb, LeafBucket ob, LeafBucket tb)
private NonNoteEntry
mergeNonNotes(NonNoteEntry baseList, NonNoteEntry oursList, NonNoteEntry theirsList)
private static Note
min(Note b, Note o, Note t)
private static NonNoteEntry
nonNotes(InMemoryNoteBucket b)
private static LeafBucket
notNullOrEmpty(LeafBucket b)
private static boolean
sameContent(Note a, Note b)
private static boolean
sameNote(Note a, Note b)
private static Note
sameNoteOrNull(Note min, Note other)
private ObjectId
write(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 customNoteMerger
and 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 withDefaultNoteMerger
as the merger for notes and theMergeStrategy.RESOLVE
as 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:
MissingObjectException
java.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
-
-