summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2011-11-22 14:26:08 -0500
committerCode Review <codereview-daemon@eclipse.org>2011-11-22 14:26:08 -0500
commitd8497abe7805152d696d065ec3dbdd40f455cc3f (patch)
treeccbb7b64878f61ba0974e22212ae7420e509fa72
parent1fbe688f51cbc1d951dee5443ae0b9d801904c93 (diff)
parent2d63c481f71ed0c06a62e6eaec9bc2e0a4a230b9 (diff)
downloadjgit-d8497abe7805152d696d065ec3dbdd40f455cc3f.tar.gz
jgit-d8497abe7805152d696d065ec3dbdd40f455cc3f.zip
Merge "Provide merge result when revert command fails"
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java
index 6e27bf2872..3475ed7d64 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java
@@ -46,8 +46,10 @@ import java.io.IOException;
import java.text.MessageFormat;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import org.eclipse.jgit.JGitText;
+import org.eclipse.jgit.api.MergeResult.MergeStatus;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.MultipleParentsNotAllowedException;
import org.eclipse.jgit.api.errors.JGitInternalException;
@@ -62,6 +64,7 @@ import org.eclipse.jgit.lib.Ref.Storage;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.merge.MergeStrategy;
import org.eclipse.jgit.merge.ResolveMerger;
+import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.treewalk.FileTreeIterator;
@@ -81,6 +84,8 @@ public class RevertCommand extends GitCommand<RevCommit> {
private List<Ref> revertedRefs = new LinkedList<Ref>();
+ private MergeResult failingResult;
+
/**
* @param repo
*/
@@ -155,6 +160,15 @@ public class RevertCommand extends GitCommand<RevCommit> {
.setReflogComment("revert: " + shortMessage).call();
revertedRefs.add(src);
} else {
+ Map<String, MergeFailureReason> failingPaths = merger
+ .getFailingPaths();
+ if (failingPaths != null)
+ failingResult = new MergeResult(null,
+ merger.getBaseCommit(0, 1),
+ new ObjectId[] { headCommit.getId(),
+ srcParent.getId() },
+ MergeStatus.FAILED, MergeStrategy.RESOLVE,
+ merger.getMergeResults(), failingPaths, null);
return null;
}
}
@@ -210,4 +224,12 @@ public class RevertCommand extends GitCommand<RevCommit> {
public List<Ref> getRevertedRefs() {
return revertedRefs;
}
+
+ /**
+ * @return the result of the merge failure, <code>null</code> if no merge
+ * failure occurred during the revert
+ */
+ public MergeResult getFailingResult() {
+ return failingResult;
+ }
}