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(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() |
ObjectInserter |
getObjectInserter() |
Repository |
getRepository() |
abstract ObjectId |
getResultTreeId() |
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 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.
|
protected final Repository db
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.public Repository getRepository()
public ObjectInserter getObjectInserter()
getRepository()
.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()
.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 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.