org.eclipse.jgit.api
Class MergeResult

java.lang.Object
  extended by org.eclipse.jgit.api.MergeResult

public class MergeResult
extends Object

Encapsulates the result of a MergeCommand.


Nested Class Summary
static class MergeResult.MergeStatus
          The status the merge resulted in.
 
Constructor Summary
MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, Map<String,MergeResult<?>> lowLevelResults)
           
MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, Map<String,MergeResult<?>> lowLevelResults, Map<String,ResolveMerger.MergeFailureReason> failingPaths, String description)
           
MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, Map<String,MergeResult<?>> lowLevelResults, String description)
           
 
Method Summary
 void addConflict(String path, int[][] conflictingRanges)
           
 void addConflict(String path, MergeResult<?> lowLevelResult)
           
 ObjectId getBase()
           
 Map<String,int[][]> getConflicts()
          Returns information about the conflicts which occurred during a MergeCommand.
 Map<String,ResolveMerger.MergeFailureReason> getFailingPaths()
          Returns a list of paths causing this merge to fail as returned by ResolveMerger.getFailingPaths()
 ObjectId[] getMergedCommits()
           
 MergeResult.MergeStatus getMergeStatus()
           
 ObjectId getNewHead()
           
 void setConflicts(Map<String,int[][]> conflicts)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MergeResult

public MergeResult(ObjectId newHead,
                   ObjectId base,
                   ObjectId[] mergedCommits,
                   MergeResult.MergeStatus mergeStatus,
                   MergeStrategy mergeStrategy,
                   Map<String,MergeResult<?>> lowLevelResults)
Parameters:
newHead - the object the head points at after the merge
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
mergedCommits - all the commits which have been merged together
mergeStatus - the status the merge resulted in
mergeStrategy - the used MergeStrategy
lowLevelResults - merge results as returned by ResolveMerger.getMergeResults()
Since:
2.0

MergeResult

public MergeResult(ObjectId newHead,
                   ObjectId base,
                   ObjectId[] mergedCommits,
                   MergeResult.MergeStatus mergeStatus,
                   MergeStrategy mergeStrategy,
                   Map<String,MergeResult<?>> lowLevelResults,
                   String description)
Parameters:
newHead - the object the head points at after the merge
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
mergedCommits - all the commits which have been merged together
mergeStatus - the status the merge resulted in
mergeStrategy - the used MergeStrategy
lowLevelResults - merge results as returned by ResolveMerger.getMergeResults()
description - a user friendly description of the merge result

MergeResult

public MergeResult(ObjectId newHead,
                   ObjectId base,
                   ObjectId[] mergedCommits,
                   MergeResult.MergeStatus mergeStatus,
                   MergeStrategy mergeStrategy,
                   Map<String,MergeResult<?>> lowLevelResults,
                   Map<String,ResolveMerger.MergeFailureReason> failingPaths,
                   String description)
Parameters:
newHead - the object the head points at after the merge
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
mergedCommits - all the commits which have been merged together
mergeStatus - the status the merge resulted in
mergeStrategy - the used MergeStrategy
lowLevelResults - merge results as returned by ResolveMerger.getMergeResults()
failingPaths - list of paths causing this merge to fail as returned by ResolveMerger.getFailingPaths()
description - a user friendly description of the merge result
Method Detail

getNewHead

public ObjectId getNewHead()
Returns:
the object the head points at after the merge

getMergeStatus

public MergeResult.MergeStatus getMergeStatus()
Returns:
the status the merge resulted in

getMergedCommits

public ObjectId[] getMergedCommits()
Returns:
all the commits which have been merged together

getBase

public ObjectId getBase()
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 String toString()
Overrides:
toString in class Object

setConflicts

public void setConflicts(Map<String,int[][]> conflicts)
Parameters:
conflicts - the conflicts to set

addConflict

public void addConflict(String path,
                        int[][] conflictingRanges)
Parameters:
path -
conflictingRanges - the conflicts to set

addConflict

public void addConflict(String path,
                        MergeResult<?> lowLevelResult)
Parameters:
path -
lowLevelResult -

getConflicts

public Map<String,int[][]> getConflicts()
Returns information about the conflicts which occurred during a MergeCommand. 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

Example code how to parse this data:

 MergeResult m=...;
 Map 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 Map<String,ResolveMerger.MergeFailureReason> getFailingPaths()
Returns a list of paths causing this merge to fail as returned by ResolveMerger.getFailingPaths()

Returns:
the list of paths causing this merge to fail or null if no failure occurred


Copyright © 2012. All Rights Reserved.