Package org.eclipse.jgit.api
Class MergeResult
- java.lang.Object
-
- org.eclipse.jgit.api.MergeResult
-
public class MergeResult extends java.lang.Object
Encapsulates the result of aMergeCommand
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MergeResult.MergeStatus
The status the merge resulted in.
-
Field Summary
Fields Modifier and Type Field Description private ObjectId
base
private java.util.List<java.lang.String>
checkoutConflicts
private java.util.Map<java.lang.String,int[][]>
conflicts
private java.lang.String
description
private java.util.Map<java.lang.String,ResolveMerger.MergeFailureReason>
failingPaths
private ObjectId[]
mergedCommits
private MergeResult.MergeStatus
mergeStatus
private MergeStrategy
mergeStrategy
private ObjectId
newHead
-
Constructor Summary
Constructors Constructor Description MergeResult(java.util.List<java.lang.String> checkoutConflicts)
Creates a new result that represents a checkout conflict before the operation even started for real.MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, java.util.Map<java.lang.String,MergeResult<?>> lowLevelResults)
Constructor for MergeResult.MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, java.util.Map<java.lang.String,MergeResult<?>> lowLevelResults, java.lang.String description)
Constructor for MergeResult.MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, java.util.Map<java.lang.String,MergeResult<?>> lowLevelResults, java.util.Map<java.lang.String,ResolveMerger.MergeFailureReason> failingPaths, java.lang.String description)
Constructor for MergeResult.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConflict(java.lang.String path, int[][] conflictingRanges)
Add a conflictvoid
addConflict(java.lang.String path, MergeResult<?> lowLevelResult)
Add a conflictObjectId
getBase()
Get the common basejava.util.List<java.lang.String>
getCheckoutConflicts()
Returns a list of paths that cause a checkout conflict.java.util.Map<java.lang.String,int[][]>
getConflicts()
Returns information about the conflicts which occurred during aMergeCommand
.java.util.Map<java.lang.String,ResolveMerger.MergeFailureReason>
getFailingPaths()
Returns a list of paths causing this merge to fail as returned byResolveMerger.getFailingPaths()
ObjectId[]
getMergedCommits()
Get the commits which have been mergedMergeResult.MergeStatus
getMergeStatus()
Get the merge statusObjectId
getNewHead()
Get the object the head points at after the mergevoid
setConflicts(java.util.Map<java.lang.String,int[][]> conflicts)
Set conflictsjava.lang.String
toString()
-
-
-
Field Detail
-
mergedCommits
private ObjectId[] mergedCommits
-
base
private ObjectId base
-
newHead
private ObjectId newHead
-
conflicts
private java.util.Map<java.lang.String,int[][]> conflicts
-
mergeStatus
private MergeResult.MergeStatus mergeStatus
-
description
private java.lang.String description
-
mergeStrategy
private MergeStrategy mergeStrategy
-
failingPaths
private java.util.Map<java.lang.String,ResolveMerger.MergeFailureReason> failingPaths
-
checkoutConflicts
private java.util.List<java.lang.String> checkoutConflicts
-
-
Constructor Detail
-
MergeResult
public MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, java.util.Map<java.lang.String,MergeResult<?>> lowLevelResults)
Constructor for MergeResult.- Parameters:
newHead
- the object the head points at after the mergebase
- the common base which was used to produce a content-merge. May benull
if the merge-result was produced without computing a common basemergedCommits
- all the commits which have been merged togethermergeStatus
- the status the merge resulted inmergeStrategy
- the usedMergeStrategy
lowLevelResults
- merge results as returned byResolveMerger.getMergeResults()
- Since:
- 2.0
-
MergeResult
public MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, java.util.Map<java.lang.String,MergeResult<?>> lowLevelResults, java.lang.String description)
Constructor for MergeResult.- Parameters:
newHead
- the object the head points at after the mergebase
- the common base which was used to produce a content-merge. May benull
if the merge-result was produced without computing a common basemergedCommits
- all the commits which have been merged togethermergeStatus
- the status the merge resulted inmergeStrategy
- the usedMergeStrategy
lowLevelResults
- merge results as returned byResolveMerger.getMergeResults()
description
- a user friendly description of the merge result
-
MergeResult
public MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, java.util.Map<java.lang.String,MergeResult<?>> lowLevelResults, java.util.Map<java.lang.String,ResolveMerger.MergeFailureReason> failingPaths, java.lang.String description)
Constructor for MergeResult.- Parameters:
newHead
- the object the head points at after the mergebase
- the common base which was used to produce a content-merge. May benull
if the merge-result was produced without computing a common basemergedCommits
- all the commits which have been merged togethermergeStatus
- the status the merge resulted inmergeStrategy
- the usedMergeStrategy
lowLevelResults
- merge results as returned byResolveMerger.getMergeResults()
failingPaths
- list of paths causing this merge to fail as returned byResolveMerger.getFailingPaths()
description
- a user friendly description of the merge result
-
MergeResult
public MergeResult(java.util.List<java.lang.String> checkoutConflicts)
Creates a new result that represents a checkout conflict before the operation even started for real.- Parameters:
checkoutConflicts
- the conflicting files
-
-
Method Detail
-
getNewHead
public ObjectId getNewHead()
Get the object the head points at after the merge- Returns:
- the object the head points at after the merge
-
getMergeStatus
public MergeResult.MergeStatus getMergeStatus()
Get the merge status- Returns:
- the status the merge resulted in
-
getMergedCommits
public ObjectId[] getMergedCommits()
Get the commits which have been merged- Returns:
- all the commits which have been merged together
-
getBase
public ObjectId getBase()
Get the common base- Returns:
- base the common base which was used to produce a content-merge.
May be
null
if the merge-result was produced without computing a common base
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setConflicts
public void setConflicts(java.util.Map<java.lang.String,int[][]> conflicts)
Set conflicts- Parameters:
conflicts
- the conflicts to set
-
addConflict
public void addConflict(java.lang.String path, int[][] conflictingRanges)
Add a conflict- Parameters:
path
- path of the file to add a conflict forconflictingRanges
- the conflicts to set
-
addConflict
public void addConflict(java.lang.String path, MergeResult<?> lowLevelResult)
Add a conflict- Parameters:
path
- path of the file to add a conflict forlowLevelResult
- aMergeResult
-
getConflicts
public java.util.Map<java.lang.String,int[][]> getConflicts()
Returns information about the conflicts which occurred during aMergeCommand
. The returned value maps the path of a conflicting file to a two-dimensional int-array of line-numbers telling where in the file conflict markers for which merged commit can be found.If the returned value contains a mapping "path"->[x][y]=z then this means
- the file with path "path" contains conflicts
- if y < "number of merged commits": for conflict number x in this file the chunk which was copied from commit number y starts on line number z. All numberings and line numbers start with 0.
- if y == "number of merged commits": the first non-conflicting line after conflict number x starts at line number z
Example code how to parse this data:
MergeResult m=...; Map<String, int[][]> allConflicts = m.getConflicts(); for (String path : allConflicts.keySet()) { int[][] c = allConflicts.get(path); System.out.println("Conflicts in file " + path); for (int i = 0; i < c.length; ++i) { System.out.println(" Conflict #" + i); for (int j = 0; j < (c[i].length) - 1; ++j) { if (c[i][j] >= 0) System.out.println(" Chunk for " + m.getMergedCommits()[j] + " starts on line #" + c[i][j]); } } }
- Returns:
- the conflicts or
null
if no conflict occurred
-
getFailingPaths
public java.util.Map<java.lang.String,ResolveMerger.MergeFailureReason> getFailingPaths()
Returns a list of paths causing this merge to fail as returned byResolveMerger.getFailingPaths()
- Returns:
- the list of paths causing this merge to fail or
null
if no failure occurred
-
getCheckoutConflicts
public java.util.List<java.lang.String> getCheckoutConflicts()
Returns a list of paths that cause a checkout conflict. These paths prevent the operation from even starting.- Returns:
- the list of files that caused the checkout conflict.
-
-