[Git] if not all conflicts resolved, notify. Relates to IDEA-51187
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Wed, 11 May 2011 16:49:27 +0000 (20:49 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Thu, 12 May 2011 07:39:39 +0000 (11:39 +0400)
plugins/git4idea/src/git4idea/history/browser/CherryPicker.java

index 2146c7ac22c7bac4bccac2c2156058e6461d1293..9ce3a4615a401d3c231fcf5ac008a366c3773360 100644 (file)
@@ -17,13 +17,13 @@ package git4idea.history.browser;
 
 import com.intellij.lifecycle.PeriodicalTasksCloser;
 import com.intellij.openapi.application.ModalityState;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.MessageType;
 import com.intellij.openapi.vcs.AbstractVcsHelper;
 import com.intellij.openapi.vcs.FilePath;
 import com.intellij.openapi.vcs.VcsException;
 import com.intellij.openapi.vcs.changes.*;
 import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
-import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.Consumer;
@@ -31,6 +31,8 @@ import git4idea.GitVcs;
 
 import java.util.*;
 
+import static com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier.showOverChangesView;
+
 public class CherryPicker {
   private final GitVcs myVcs;
   private final List<GitCommit> myCommits;
@@ -41,6 +43,7 @@ public class CherryPicker {
   private final List<FilePath> myDirtyFiles;
   private final List<String> myMessagesInOrder;
   private final Map<String, Collection<FilePath>> myFilesToMove;
+  private boolean myConflictsExist;
 
   public CherryPicker(GitVcs vcs, final List<GitCommit> commits, LowLevelAccess access) {
     myVcs = vcs;
@@ -90,15 +93,19 @@ public class CherryPicker {
   }
 
   private void showResults() {
-    if (myExceptions.isEmpty()) {
-      VcsBalloonProblemNotifier
-        .showOverChangesView(myVcs.getProject(), "Successful cherry-pick into working tree, please commit changes", MessageType.INFO);
+    final Project project = myVcs.getProject();
+    if (myExceptions.isEmpty() && !myConflictsExist) {
+      showOverChangesView(project, "Successful cherry-pick into working tree, please commit changes", MessageType.INFO);
     } else {
-      VcsBalloonProblemNotifier.showOverChangesView(myVcs.getProject(), "Errors in cherry-pick", MessageType.ERROR);
+      if (myExceptions.isEmpty()) {
+        showOverChangesView(project, "Unresolved conflicts while cherry-picking. Resolve conflicts, then commit changes", MessageType.WARNING);
+      } else {
+        showOverChangesView(project, "Errors in cherry-pick", MessageType.ERROR);
+      }
     }
     if ((! myExceptions.isEmpty()) || (! myWarnings.isEmpty())) {
       myExceptions.addAll(myWarnings);
-      AbstractVcsHelper.getInstance(myVcs.getProject()).showErrors(myExceptions, "Cherry-pick problems");
+      AbstractVcsHelper.getInstance(project).showErrors(myExceptions, "Cherry-pick problems");
     }
   }
 
@@ -130,7 +137,9 @@ public class CherryPicker {
   private void cherryPickStep(CheckinEnvironment ce, int i) {
     final GitCommit commit = myCommits.get(i);
     try {
-      myAccess.cherryPick(commit);
+      if (!myAccess.cherryPick(commit)) {
+        myConflictsExist = true;
+      }
     }
     catch (VcsException e) {
       myExceptions.add(e);