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

public abstract Class Merger

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.merge.StrategyOneSided.OneSide, org.eclipse.jgit.merge.ThreeWayMerger
Imports
java.io.IOException, java.text.MessageFormat, org.eclipse.jgit.annotations.Nullable, org.eclipse.jgit.errors.IncorrectObjectTypeException, .NoMergeBaseException, .NoMergeBaseException.MergeBaseFailureReason, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.AnyObjectId, .NullProgressMonitor, .ObjectId, .ObjectInserter, .ObjectReader, .ProgressMonitor, .Repository, org.eclipse.jgit.revwalk.RevCommit, .RevObject, .RevTree, .RevWalk, org.eclipse.jgit.revwalk.filter.RevFilter, org.eclipse.jgit.treewalk.AbstractTreeIterator, .CanonicalTreeParser

Instance of a specific org.eclipse.jgit.merge.MergeStrategy for a single org.eclipse.jgit.lib.Repository.

Field Summary

Modifier and TypeField and Description
protected final Repository
db

The repository this merger operates on.

private ObjectInserter
protected ProgressMonitor
monitor

A progress monitor.

protected ObjectReader
reader

Reader to support walk and other object loading.

protected RevCommit[]
sourceCommits

If sourceObjects[i] is a commit, this is the commit.

protected RevObject[]
sourceObjects

The original objects supplied in the merge; this can be any tree-ish.

protected RevTree[]
sourceTrees

The trees matching every entry in sourceObjects.

protected RevWalk
walk

A RevWalk for computing merge bases, or listing incoming commits.

Constructor Summary

AccessConstructor and Description
protected
Merger(Repository
the repository this merger will read and write data on.
local
)

Create a new merge instance for a repository.

protected
Merger(ObjectInserter
the inserter to write objects to. Will be closed at the conclusion of merge, unless flush is false.
oi
)

Create a new in-core merge instance from an inserter.

Method Summary

Modifier and TypeMethod and Description
protected RevCommit

Returns:

the merge base of two commits
getBaseCommit
(RevCommit
the first commit in sourceObjects.
a
,
RevCommit
the second commit in sourceObjects.
b
)

Return the merge base of two commits.

public abstract ObjectId

Returns:

the ID of the commit that was used as merge base for merging, or null if no merge base was used or it was set manually
getBaseCommitId
()

Get the ID of the commit that was used as merge base for merging

public ObjectInserter

Returns:

an object writer to create objects, writing objects to getRepository() (if a repository was provided).
getObjectInserter
()

Get an object writer to create objects, writing objects to getRepository()

public Repository

Returns:

the repository this merger operates on.
getRepository
()

Get the repository this merger operates on.

public abstract ObjectId

Returns:

resulting tree, if merge(AnyObjectId[]) returned true.
getResultTreeId
()

Get resulting tree.

public boolean

Returns:

true if the merge was completed without conflicts; false if the merge strategy cannot handle this merge or there were conflicts preventing it from automatically resolving all paths.
merge
(AnyObjectId...
source trees to be combined together. The merge base is not included in this set.
tips
)

Merge together two or more tree-ish objects.

public boolean

Returns:

true if the merge was completed without conflicts; false if the merge strategy cannot handle this merge or there were conflicts preventing it from automatically resolving all paths.
merge
(boolean
whether to flush and close the underlying object inserter when finished to store any content-merged blobs and virtual merged bases; if false, callers are responsible for flushing.
flush
,
AnyObjectId...
source trees to be combined together. The merge base is not included in this set.
tips
)

Merge together two or more tree-ish objects.

protected abstract boolean

Returns:

true if the merge was completed without conflicts; false if the merge strategy cannot handle this merge or there were conflicts preventing it from automatically resolving all paths.
mergeImpl
()

Execute the merge.

protected Repository

Returns:

non-null repository instance
nonNullRepo
()

Get non-null repository instance

protected AbstractTreeIterator

Returns:

an iterator for the tree.
openTree
(AnyObjectId
the tree to scan; must be a tree (not a treeish).
treeId
)

Open an iterator over a tree.

public void
setObjectInserter(ObjectInserter
the inserter instance to use. Must be associated with the repository instance returned by getRepository() (if a repository was provided). Will be closed at the conclusion of merge, unless flush is false.
oi
)

Set the inserter this merger will use to create objects.

public void
setProgressMonitor(ProgressMonitor
Monitor to use, can be null to indicate no progress reporting is desired.
monitor
)

Set a progress monitor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dbback to summary
protected final Repository db

The repository this merger operates on.

Null if and only if the merger was constructed with Merger(ObjectInserter). Callers that want to assume the repo is not null (e.g. because of a previous check that the merger is not in-core) may use nonNullRepo().

Annotations
@Nullable
inserterback to summary
private ObjectInserter inserter
monitorback to summary
protected ProgressMonitor monitor

A progress monitor.

Since
4.2
readerback to summary
protected ObjectReader reader

Reader to support walk and other object loading.

sourceCommitsback to summary
protected RevCommit[] sourceCommits

If sourceObjects[i] is a commit, this is the commit.

sourceObjectsback to summary
protected RevObject[] sourceObjects

The original objects supplied in the merge; this can be any tree-ish.

sourceTreesback to summary
protected RevTree[] sourceTrees

The trees matching every entry in sourceObjects.

walkback to summary
protected RevWalk walk

A RevWalk for computing merge bases, or listing incoming commits.

Constructor Detail

Mergerback to summary
protected Merger(Repository local)

Create a new merge instance for a repository.

Parameters
local:Repository

the repository this merger will read and write data on.

Mergerback to summary
protected Merger(ObjectInserter oi)

Create a new in-core merge instance from an inserter.

Parameters
oi:ObjectInserter

the inserter to write objects to. Will be closed at the conclusion of merge, unless flush is false.

Since
4.8

Method Detail

getBaseCommitback to summary
protected RevCommit getBaseCommit(RevCommit a, RevCommit b) throws IncorrectObjectTypeException, IOException

Return the merge base of two commits.

Parameters
a:RevCommit

the first commit in sourceObjects.

b:RevCommit

the second commit in sourceObjects.

Returns:RevCommit

the merge base of two commits

Exceptions
IncorrectObjectTypeException:
one of the input objects is not a commit.
IOException:
objects are missing or multiple merge bases were found.
Since
3.0
getBaseCommitIdback to summary
public abstract ObjectId getBaseCommitId()

Get the ID of the commit that was used as merge base for merging

Returns:ObjectId

the ID of the commit that was used as merge base for merging, or null if no merge base was used or it was set manually

Since
3.2
getObjectInserterback to summary
public ObjectInserter getObjectInserter()

Get an object writer to create objects, writing objects to getRepository()

Returns:ObjectInserter

an object writer to create objects, writing objects to getRepository() (if a repository was provided).

getRepositoryback to summary
public Repository getRepository()

Get the repository this merger operates on.

Returns:Repository

the repository this merger operates on.

Annotations
@Nullable
getResultTreeIdback to summary
public abstract ObjectId getResultTreeId()

Get resulting tree.

Returns:ObjectId

resulting tree, if merge(AnyObjectId[]) returned true.

mergeback to summary
public boolean merge(AnyObjectId... tips) throws IOException

Merge together two or more tree-ish objects.

Any tree-ish may be supplied as inputs. Commits and/or tags pointing at trees or commits may be passed as input objects.

Parameters
tips:AnyObjectId[]

source trees to be combined together. The merge base is not included in this set.

Returns:boolean

true if the merge was completed without conflicts; false if the merge strategy cannot handle this merge or there were conflicts preventing it from automatically resolving all paths.

Exceptions
IOException:
one or more sources could not be read, or outputs could not be written to the Repository.
IncorrectObjectTypeException:
one of the input objects is not a commit, but the strategy requires it to be a commit.
mergeback to summary
public boolean merge(boolean flush, AnyObjectId... tips) throws IOException

Merge together two or more tree-ish objects.

Any tree-ish may be supplied as inputs. Commits and/or tags pointing at trees or commits may be passed as input objects.

Parameters
flush:boolean

whether to flush and close the underlying object inserter when finished to store any content-merged blobs and virtual merged bases; if false, callers are responsible for flushing.

tips:AnyObjectId[]

source trees to be combined together. The merge base is not included in this set.

Returns:boolean

true if the merge was completed without conflicts; false if the merge strategy cannot handle this merge or there were conflicts preventing it from automatically resolving all paths.

Exceptions
IOException:
one or more sources could not be read, or outputs could not be written to the Repository.
IncorrectObjectTypeException:
one of the input objects is not a commit, but the strategy requires it to be a commit.
Since
3.5
mergeImplback to summary
protected abstract boolean mergeImpl() throws IOException

Execute the merge.

This method is called from merge(AnyObjectId[]) after the sourceObjects, sourceCommits and sourceTrees have been populated.

Returns:boolean

true if the merge was completed without conflicts; false if the merge strategy cannot handle this merge or there were conflicts preventing it from automatically resolving all paths.

Exceptions
IOException:
one or more sources could not be read, or outputs could not be written to the Repository.
IncorrectObjectTypeException:
one of the input objects is not a commit, but the strategy requires it to be a commit.
nonNullRepoback to summary
protected Repository nonNullRepo()

Get non-null repository instance

Returns:Repository

non-null repository instance

Exceptions
NullPointerException:
if the merger was constructed without a repository.
Since
4.8
openTreeback to summary
protected AbstractTreeIterator openTree(AnyObjectId treeId) throws IncorrectObjectTypeException, IOException

Open an iterator over a tree.

Parameters
treeId:AnyObjectId

the tree to scan; must be a tree (not a treeish).

Returns:AbstractTreeIterator

an iterator for the tree.

Exceptions
IncorrectObjectTypeException:
the input object is not a tree.
IOException:
the tree object is not found or cannot be read.
setObjectInserterback to summary
public void setObjectInserter(ObjectInserter oi)

Set the inserter this merger will use to create objects.

If an inserter was already set on this instance (such as by a prior set, or a prior call to getObjectInserter()), the prior inserter as well as the in-progress walk will be released.

Parameters
oi:ObjectInserter

the inserter instance to use. Must be associated with the repository instance returned by getRepository() (if a repository was provided). Will be closed at the conclusion of merge, unless flush is false.

setProgressMonitorback to summary
public void setProgressMonitor(ProgressMonitor monitor)

Set a progress monitor.

Parameters
monitor:ProgressMonitor

Monitor to use, can be null to indicate no progress reporting is desired.

Since
4.2