Package org.eclipse.jgit.merge
Class RecursiveMerger
- java.lang.Object
-
- org.eclipse.jgit.merge.Merger
-
- org.eclipse.jgit.merge.ThreeWayMerger
-
- org.eclipse.jgit.merge.ResolveMerger
-
- org.eclipse.jgit.merge.RecursiveMerger
-
public class RecursiveMerger extends ResolveMerger
A three-way merger performing a content-merge if necessary across multiple bases using recursion This merger extends the resolve merger and does several things differently: - allow more than one merge base, up to a maximum - uses "Lists" instead of Arrays for chained types - recursively merges the merge bases together to compute a usable base- Since:
- 3.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jgit.merge.ResolveMerger
ResolveMerger.MergeFailureReason
-
-
Field Summary
Fields Modifier and Type Field Description int
MAX_BASES
The maximum number of merge bases.-
Fields inherited from class org.eclipse.jgit.merge.ResolveMerger
builder, commitNames, dircache, enterSubtree, failingPaths, implicitDirCache, inCore, mergeAlgorithm, mergeResults, modifiedFiles, resultTree, T_BASE, T_FILE, T_INDEX, T_OURS, T_THEIRS, toBeCheckedOut, toBeDeleted, tw, unmergedPaths, workingTreeIterator, workingTreeOptions
-
Fields inherited from class org.eclipse.jgit.merge.Merger
db, monitor, reader, sourceCommits, sourceObjects, sourceTrees, walk
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RecursiveMerger(ObjectInserter inserter, Config config)
Normal recursive merge, implies inCore.protected
RecursiveMerger(Repository local)
Normal recursive merge, implies not inCoreprotected
RecursiveMerger(Repository local, boolean inCore)
Normal recursive merge when you want a choice of DirCache placement inCore
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private RevCommit
createCommitForTree(ObjectId tree, java.util.List<RevCommit> parents)
Create a new commit by explicitly specifying the content tree and the parents.protected RevCommit
getBaseCommit(RevCommit a, RevCommit b)
Return the merge base of two commits.protected RevCommit
getBaseCommit(RevCommit a, RevCommit b, int callDepth)
Get a single base commit for two given commits.private static PersonIdent
mockAuthor(java.util.List<RevCommit> parents)
-
Methods inherited from class org.eclipse.jgit.merge.ResolveMerger
addCheckoutMetadata, addDeletion, addToCheckout, cleanUp, failed, getCommitNames, getContentMergeStrategy, getFailingPaths, getMergeResults, getModifiedFiles, getResultTreeId, getToBeCheckedOut, getUnmergedPaths, mergeImpl, mergeTrees, mergeTreeWalk, processEntry, setCommitNames, setContentMergeStrategy, setDirCache, setWorkingTreeIterator
-
Methods inherited from class org.eclipse.jgit.merge.ThreeWayMerger
getBaseCommitId, merge, mergeBase, setBase
-
Methods inherited from class org.eclipse.jgit.merge.Merger
getObjectInserter, getRepository, merge, nonNullRepo, openTree, setObjectInserter, setProgressMonitor
-
-
-
-
Field Detail
-
MAX_BASES
public final int MAX_BASES
The maximum number of merge bases. This merge will stop when the number of merge bases exceeds this value- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RecursiveMerger
protected RecursiveMerger(Repository local, boolean inCore)
Normal recursive merge when you want a choice of DirCache placement inCore- Parameters:
local
- aRepository
object.inCore
- a boolean.
-
RecursiveMerger
protected RecursiveMerger(Repository local)
Normal recursive merge, implies not inCore- Parameters:
local
- aRepository
object.
-
RecursiveMerger
protected RecursiveMerger(ObjectInserter inserter, Config config)
Normal recursive merge, implies inCore.- Parameters:
inserter
- anObjectInserter
object.config
- the repository configuration- Since:
- 4.8
-
-
Method Detail
-
getBaseCommit
protected RevCommit getBaseCommit(RevCommit a, RevCommit b) throws IncorrectObjectTypeException, java.io.IOException
Return the merge base of two commits.Get a single base commit for two given commits. If the two source commits have more than one base commit recursively merge the base commits together until you end up with a single base commit.
- Overrides:
getBaseCommit
in classMerger
- Parameters:
a
- the first commit inMerger.sourceObjects
.b
- the second commit inMerger.sourceObjects
.- Returns:
- the merge base of two commits
- Throws:
IncorrectObjectTypeException
- one of the input objects is not a commit.java.io.IOException
- objects are missing or multiple merge bases were found.
-
getBaseCommit
protected RevCommit getBaseCommit(RevCommit a, RevCommit b, int callDepth) throws java.io.IOException
Get a single base commit for two given commits. If the two source commits have more than one base commit recursively merge the base commits together until a virtual common base commit has been found.- Parameters:
a
- the first commit to be mergedb
- the second commit to be mergedcallDepth
- the callDepth when this method is called recursively- Returns:
- the merge base of two commits. If a criss-cross merge required a synthetic merge base this commit is visible only the merger's RevWalk and will not be in the repository.
- Throws:
java.io.IOException
IncorrectObjectTypeException
- one of the input objects is not a commit.NoMergeBaseException
- too many merge bases are found or the computation of a common merge base failed (e.g. because of a conflict).
-
createCommitForTree
private RevCommit createCommitForTree(ObjectId tree, java.util.List<RevCommit> parents) throws java.io.IOException
Create a new commit by explicitly specifying the content tree and the parents. The commit message is not set and author/committer are set to the current user.- Parameters:
tree
- the tree this commit should captureparents
- the list of parent commits- Returns:
- a new commit visible only within this merger's RevWalk.
- Throws:
java.io.IOException
-
mockAuthor
private static PersonIdent mockAuthor(java.util.List<RevCommit> parents)
-
-