org.eclipse.jgit.merge
Class MergeStrategy

java.lang.Object
  extended by org.eclipse.jgit.merge.MergeStrategy
Direct Known Subclasses:
StrategyOneSided, ThreeWayMergeStrategy

public abstract class MergeStrategy
extends Object

A method of combining two or more trees together to form an output tree.

Different strategies may employ different techniques for deciding which paths (and ObjectIds) to carry from the input trees into the final output tree.


Field Summary
static MergeStrategy OURS
          Simple strategy that sets the output tree to the first input tree.
static ThreeWayMergeStrategy RESOLVE
          Simple strategy to merge paths.
static ThreeWayMergeStrategy SIMPLE_TWO_WAY_IN_CORE
          Simple strategy to merge paths, without simultaneous edits.
static MergeStrategy THEIRS
          Simple strategy that sets the output tree to the second input tree.
 
Constructor Summary
MergeStrategy()
           
 
Method Summary
static MergeStrategy[] get()
          Get all registered strategies.
static MergeStrategy get(String name)
          Locate a strategy by name.
abstract  String getName()
           
abstract  Merger newMerger(Repository db)
          Create a new merge instance.
abstract  Merger newMerger(Repository db, boolean inCore)
          Create a new merge instance.
static void register(MergeStrategy imp)
          Register a merge strategy so it can later be obtained by name.
static void register(String name, MergeStrategy imp)
          Register a merge strategy so it can later be obtained by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OURS

public static final MergeStrategy OURS
Simple strategy that sets the output tree to the first input tree.


THEIRS

public static final MergeStrategy THEIRS
Simple strategy that sets the output tree to the second input tree.


SIMPLE_TWO_WAY_IN_CORE

public static final ThreeWayMergeStrategy SIMPLE_TWO_WAY_IN_CORE
Simple strategy to merge paths, without simultaneous edits.


RESOLVE

public static final ThreeWayMergeStrategy RESOLVE
Simple strategy to merge paths. It tries to merge also contents. Multiple merge bases are not supported

Constructor Detail

MergeStrategy

public MergeStrategy()
Method Detail

register

public static void register(MergeStrategy imp)
Register a merge strategy so it can later be obtained by name.

Parameters:
imp - the strategy to register.
Throws:
IllegalArgumentException - a strategy by the same name has already been registered.

register

public static void register(String name,
                            MergeStrategy imp)
Register a merge strategy so it can later be obtained by name.

Parameters:
name - name the strategy can be looked up under.
imp - the strategy to register.
Throws:
IllegalArgumentException - a strategy by the same name has already been registered.

get

public static MergeStrategy get(String name)
Locate a strategy by name.

Parameters:
name - name of the strategy to locate.
Returns:
the strategy instance; null if no strategy matches the name.

get

public static MergeStrategy[] get()
Get all registered strategies.

Returns:
the registered strategy instances. No inherit order is returned; the caller may modify (and/or sort) the returned array if necessary to obtain a reasonable ordering.

getName

public abstract String getName()
Returns:
default name of this strategy implementation.

newMerger

public abstract Merger newMerger(Repository db)
Create a new merge instance.

Parameters:
db - repository database the merger will read from, and eventually write results back to.
Returns:
the new merge instance which implements this strategy.

newMerger

public abstract Merger newMerger(Repository db,
                                 boolean inCore)
Create a new merge instance.

Parameters:
db - repository database the merger will read from, and eventually write results back to.
inCore - 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:
the new merge instance which implements this strategy.


Copyright © 2013. All Rights Reserved.