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

public Class StrategyOneSided

extends MergeStrategy
Class Inheritance
Imports
java.io.IOException, org.eclipse.jgit.lib.Config, .ObjectId, .ObjectInserter, .Repository

Trivial merge strategy to make the resulting tree exactly match an input.

This strategy can be used to cauterize an entire side branch of history, by setting the output tree to one of the inputs, and ignoring any of the paths of the other inputs.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final String
private final int
Inherited from org.eclipse.jgit.merge.MergeStrategy:
OURSRECURSIVERESOLVESIMPLE_TWO_WAY_IN_CORETHEIRS

Constructor Summary

AccessConstructor and Description
protected
StrategyOneSided(String
name of this strategy.
name
,
int
the position of the input tree to accept as the result.
index
)

Create a new merge strategy to select a specific input tree.

Method Summary

Modifier and TypeMethod and Description
public String
getName()

Implements abstract org.eclipse.jgit.merge.MergeStrategy.getName.

Get default name of this strategy implementation.

public Merger
newMerger(Repository
repository database the merger will read from, and eventually write results back to.
db
)

Implements abstract org.eclipse.jgit.merge.MergeStrategy.newMerger.

Create a new merge instance.

public Merger
newMerger(Repository
repository database the merger will read from, and eventually write results back to.
db
,
boolean
the merge will happen in memory, working folder will not be modified, in case of a non-trivial merge that requires manual resolution, the merger will fail.
inCore
)

Implements abstract org.eclipse.jgit.merge.MergeStrategy.newMerger.

Create a new merge instance.

public Merger
newMerger(ObjectInserter
inserter to write results back to.
inserter
,
Config
repo config for reading diff algorithm settings.
config
)

Implements abstract org.eclipse.jgit.merge.MergeStrategy.newMerger.

Create a new merge instance.

Inherited from org.eclipse.jgit.merge.MergeStrategy:
getgetregisterregister

Field Detail

strategyNameback to summary
private final String strategyName
treeIndexback to summary
private final int treeIndex

Constructor Detail

StrategyOneSidedback to summary
protected StrategyOneSided(String name, int index)

Create a new merge strategy to select a specific input tree.

Parameters
name:String

name of this strategy.

index:int

the position of the input tree to accept as the result.

Method Detail

getNameback to summary
public String getName()

Implements abstract org.eclipse.jgit.merge.MergeStrategy.getName.

Doc from org.eclipse.jgit.merge.MergeStrategy.getName.

Get default name of this strategy implementation.

Returns:String

default name of this strategy implementation.

Annotations
@Override
newMergerback to summary
public Merger newMerger(Repository db)

Implements abstract org.eclipse.jgit.merge.MergeStrategy.newMerger.

Doc from org.eclipse.jgit.merge.MergeStrategy.newMerger.

Create a new merge instance.

Parameters
db:Repository

repository database the merger will read from, and eventually write results back to.

Returns:Merger

the new merge instance which implements this strategy.

Annotations
@Override
newMergerback to summary
public Merger newMerger(Repository db, boolean inCore)

Implements abstract org.eclipse.jgit.merge.MergeStrategy.newMerger.

Doc from org.eclipse.jgit.merge.MergeStrategy.newMerger.

Create a new merge instance.

Parameters
db:Repository

repository database the merger will read from, and eventually write results back to.

inCore:boolean

the merge will happen in memory, working folder will not be modified, in case of a non-trivial merge that requires manual resolution, the merger will fail.

Returns:Merger

the new merge instance which implements this strategy.

Annotations
@Override
newMergerback to summary
public Merger newMerger(ObjectInserter inserter, Config config)

Implements abstract org.eclipse.jgit.merge.MergeStrategy.newMerger.

Doc from org.eclipse.jgit.merge.MergeStrategy.newMerger.

Create a new merge instance.

The merge will happen in memory, working folder will not be modified, in case of a non-trivial merge that requires manual resolution, the merger will fail.

Parameters
inserter:ObjectInserter

inserter to write results back to.

config:Config

repo config for reading diff algorithm settings.

Returns:Merger

the new merge instance which implements this strategy.

Annotations
@Override
org.eclipse.jgit.merge back to summary

pack-priv Class StrategyOneSided.OneSide

extends Merger
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int
Inherited from org.eclipse.jgit.merge.Merger:
dbmonitorreadersourceCommitssourceObjectssourceTreeswalk

Constructor Summary

AccessConstructor and Description
protected
OneSide(Repository local, int index)

protected
OneSide(ObjectInserter inserter, int index)

Method Summary

Modifier and TypeMethod and Description
public ObjectId
getBaseCommitId()

Implements abstract org.eclipse.jgit.merge.Merger.getBaseCommitId.

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

public ObjectId
getResultTreeId()

Implements abstract org.eclipse.jgit.merge.Merger.getResultTreeId.

Get resulting tree.

protected boolean
mergeImpl()

Implements abstract org.eclipse.jgit.merge.Merger.mergeImpl.

Execute the merge.

Inherited from org.eclipse.jgit.merge.Merger:
getBaseCommitgetObjectInsertergetRepositorymergemergenonNullRepoopenTreesetObjectInsertersetProgressMonitor

Field Detail

treeIndexback to summary
private final int treeIndex

Constructor Detail

OneSideback to summary
protected OneSide(Repository local, int index)
OneSideback to summary
protected OneSide(ObjectInserter inserter, int index)

Method Detail

getBaseCommitIdback to summary
public ObjectId getBaseCommitId()

Implements abstract org.eclipse.jgit.merge.Merger.getBaseCommitId.

Doc from org.eclipse.jgit.merge.Merger.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

Annotations
@Override
getResultTreeIdback to summary
public ObjectId getResultTreeId()

Implements abstract org.eclipse.jgit.merge.Merger.getResultTreeId.

Doc from org.eclipse.jgit.merge.Merger.getResultTreeId.

Get resulting tree.

Returns:ObjectId

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

Annotations
@Override
mergeImplback to summary
protected boolean mergeImpl() throws IOException

Implements abstract org.eclipse.jgit.merge.Merger.mergeImpl.

Doc from org.eclipse.jgit.merge.Merger.mergeImpl.

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.

Annotations
@Override
Exceptions
IOException:
one or more sources could not be read, or outputs could not be written to the Repository.