merge: ask on selecting left/right side, discarding local changes
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Tue, 11 Aug 2015 12:41:01 +0000 (15:41 +0300)
committerAleksey Pivovarov <AMPivovarov@gmail.com>
Wed, 12 Aug 2015 16:55:48 +0000 (19:55 +0300)
platform/diff-impl/src/com/intellij/diff/merge/TextMergeTool.java
platform/platform-resources-en/src/messages/DiffBundle.properties

index 5464cdb4b833be845f1b1fe56076644d6e6e8b6c..5e645e3a1556b74de6c12cda5c64d83bda201d4f 100644 (file)
@@ -291,6 +291,12 @@ public class TextMergeTool implements MergeTool {
         return new AbstractAction(caption) {
           @Override
           public void actionPerformed(ActionEvent e) {
+            if ((result == MergeResult.LEFT || result == MergeResult.RIGHT) && myContentModified &&
+                  Messages.showYesNoDialog(myPanel.getRootPane(),
+                                           DiffBundle.message("merge.dialog.resolve.side.with.discard.message", result == MergeResult.LEFT ? 0 : 1),
+                                           DiffBundle.message("merge.dialog.resolve.side.with.discard.title"), Messages.getQuestionIcon()) != Messages.YES) {
+              return;
+            }
             if (result == MergeResult.RESOLVED) {
               if ((getChangesCount() != 0 || getConflictsCount() != 0) &&
                   Messages.showYesNoDialog(myPanel.getRootPane(),
@@ -602,10 +608,6 @@ public class TextMergeTool implements MergeTool {
       // Getters
       //
 
-      public boolean isContentModified() {
-        return myContentModified;
-      }
-
       @NotNull
       public List<TextMergeChange> getAllChanges() {
         return myAllMergeChanges;
index b23a2973ecf39900d7c632721e7ee50322e9bc25..223a0ab515fe487be6bae657be20ae459dc30962 100644 (file)
@@ -74,6 +74,8 @@ merge.dialog.exit.without.applying.changes.confirmation.message=Are you sure you
 cancel.visual.merge.dialog.title=Cancel Visual Merge
 merge.dialog.apply.partially.resolved.changes.confirmation.message=There are {0, choice, 0#|1#one change|2#{0, number} changes}{0, choice, 0#|1#'{1, choice, 0#|1# and }'}{1, choice, 0#|1#one conflict|2#{1, number} conflicts} left unprocessed.\nAre you sure you want to save changes and finish merging?
 apply.partially.resolved.merge.dialog.title=Apply Changes
+merge.dialog.resolve.side.with.discard.title=Accept Changes
+merge.dialog.resolve.side.with.discard.message=Are you sure you want to discard your changes and accept {0, choice, 0#left|1#right} side?
 merge.all.changes.have.processed.save.and.finish.confirmation.text=All changes have been processed.\nWould you like to save changes and finish merging?
 all.changes.processed.dialog.title=All Changes Processed
 merge.save.and.finish.button=Save and &Finish