diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-04-06 14:03:24 +0200 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2013-04-08 05:48:09 -0400 |
commit | 59baf9148e4b16028203d9e881136ab4c005202c (patch) | |
tree | 6068f07e0faa8389a43c40f8b5ff72b7ffd2fbd9 /org.eclipse.jgit.pgm/src | |
parent | 5d446f410d7044fba165ad3deee7ac83864f0e96 (diff) | |
download | jgit-59baf9148e4b16028203d9e881136ab4c005202c.tar.gz jgit-59baf9148e4b16028203d9e881136ab4c005202c.zip |
Detect and handle a checkout conflict during merge nicely
Report the conflicting files nicely and inform the user.
Change-Id: I75d464d4156d10c6cc6c7ce5a321e2c9fb0df375
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java | 2 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java index 64bd18e867..1f14fa272b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java @@ -133,8 +133,10 @@ public class CLIText extends TranslationBundle { /***/ public String jgitVersion; /***/ public String lineFormat; /***/ public String listeningOn; + /***/ public String mergeCheckoutConflict; /***/ public String mergeConflict; /***/ public String mergeFailed; + /***/ public String mergeCheckoutFailed; /***/ public String mergeMadeBy; /***/ public String mergedSquashed; /***/ public String mergeWentWellStoppedBeforeCommitting; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java index 97198259d3..e25ac4f3ef 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java @@ -51,6 +51,7 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.MergeCommand; import org.eclipse.jgit.api.MergeResult; import org.eclipse.jgit.api.MergeCommand.FastForwardMode; +import org.eclipse.jgit.api.errors.CheckoutConflictException; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -119,7 +120,12 @@ class Merge extends TextBuiltin { mergeCmd.include(srcRef); else mergeCmd.include(src); - MergeResult result = mergeCmd.call(); + MergeResult result; + try { + result = mergeCmd.call(); + } catch (CheckoutConflictException e) { + result = new MergeResult(e.getConflictingPaths()); // CHECKOUT_CONFLICT + } switch (result.getMergeStatus()) { case ALREADY_UP_TO_DATE: @@ -134,6 +140,12 @@ class Merge extends TextBuiltin { .name())); outw.println(result.getMergeStatus().toString()); break; + case CHECKOUT_CONFLICT: + outw.println(CLIText.get().mergeCheckoutConflict); + for (String collidingPath : result.getCheckoutConflicts()) + outw.println("\t" + collidingPath); //$NON-NLS-1$ + outw.println(CLIText.get().mergeCheckoutFailed); + break; case CONFLICTING: for (String collidingPath : result.getConflicts().keySet()) outw.println(MessageFormat.format(CLIText.get().mergeConflict, |