public abstract class Merger extends Object
MergeStrategy for a
single Repository.| Modifier and Type | Field and Description |
|---|---|
protected Repository |
db
The repository this merger operates on.
|
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.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Merger(ObjectInserter oi)
Create a new in-core merge instance from an inserter.
|
protected |
Merger(Repository local)
Create a new merge instance for a repository.
|
| Modifier and Type | Method and Description |
|---|---|
protected RevCommit |
getBaseCommit(RevCommit a,
RevCommit b)
Return the merge base of two commits.
|
abstract ObjectId |
getBaseCommitId()
Get the ID of the commit that was used as merge base for merging
|
ObjectInserter |
getObjectInserter()
Get an object writer to create objects, writing objects to
getRepository() |
Repository |
getRepository()
Get the repository this merger operates on.
|
abstract ObjectId |
getResultTreeId()
Get resulting tree.
|
boolean |
merge(AnyObjectId... tips)
Merge together two or more tree-ish objects.
|
boolean |
merge(boolean flush,
AnyObjectId... tips)
Merge together two or more tree-ish objects.
|
protected abstract boolean |
mergeImpl()
Execute the merge.
|
protected Repository |
nonNullRepo()
Get non-null repository instance
|
protected AbstractTreeIterator |
openTree(AnyObjectId treeId)
Open an iterator over a tree.
|
void |
setObjectInserter(ObjectInserter oi)
Set the inserter this merger will use to create objects.
|
void |
setProgressMonitor(ProgressMonitor monitor)
Set a progress monitor.
|
@Nullable protected final Repository db
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().
protected ObjectReader reader
walk and other object loading.protected RevWalk walk
protected RevObject[] sourceObjects
protected RevCommit[] sourceCommits
sourceObjects[i] is a commit, this is the commit.protected RevTree[] sourceTrees
sourceObjects.protected ProgressMonitor monitor
protected Merger(Repository local)
local - the repository this merger will read and write data on.protected Merger(ObjectInserter oi)
oi - the inserter to write objects to. Will be closed at the
conclusion of merge, unless flush is false.@Nullable public Repository getRepository()
protected Repository nonNullRepo()
NullPointerException - if the merger was constructed without a repository.public ObjectInserter getObjectInserter()
getRepository()getRepository() (if a repository was provided).public void setObjectInserter(ObjectInserter oi)
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.
oi - 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.public boolean merge(AnyObjectId... tips) throws IOException
Any tree-ish may be supplied as inputs. Commits and/or tags pointing at trees or commits may be passed as input objects.
tips - source trees to be combined together. The merge base is not
included in this set.IncorrectObjectTypeException - one of the input objects is not a commit, but the strategy
requires it to be a commit.IOException - one or more sources could not be read, or outputs could not
be written to the Repository.public boolean merge(boolean flush,
AnyObjectId... tips)
throws IOException
Any tree-ish may be supplied as inputs. Commits and/or tags pointing at trees or commits may be passed as input objects.
flush - 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 - source trees to be combined together. The merge base is not
included in this set.IncorrectObjectTypeException - one of the input objects is not a commit, but the strategy
requires it to be a commit.IOException - one or more sources could not be read, or outputs could not
be written to the Repository.public abstract ObjectId getBaseCommitId()
protected RevCommit getBaseCommit(RevCommit a, RevCommit b) throws IncorrectObjectTypeException, IOException
a - the first commit in sourceObjects.b - the second commit in sourceObjects.IncorrectObjectTypeException - one of the input objects is not a commit.IOException - objects are missing or multiple merge bases were found.protected AbstractTreeIterator openTree(AnyObjectId treeId) throws IncorrectObjectTypeException, IOException
treeId - the tree to scan; must be a tree (not a treeish).IncorrectObjectTypeException - the input object is not a tree.IOException - the tree object is not found or cannot be read.protected abstract boolean mergeImpl()
throws IOException
This method is called from merge(AnyObjectId[]) after the
sourceObjects, sourceCommits and sourceTrees
have been populated.
IncorrectObjectTypeException - one of the input objects is not a commit, but the strategy
requires it to be a commit.IOException - one or more sources could not be read, or outputs could not
be written to the Repository.public abstract ObjectId getResultTreeId()
merge(AnyObjectId[]) returned true.public void setProgressMonitor(ProgressMonitor monitor)
monitor - Monitor to use, can be null to indicate no progress reporting
is desired.Copyright © 2018 Eclipse JGit Project. All rights reserved.