[Git] cherryPick returns false if not all conflicts were resolved.
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Wed, 11 May 2011 16:38:15 +0000 (20:38 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Thu, 12 May 2011 07:39:39 +0000 (11:39 +0400)
plugins/git4idea/src/git4idea/history/browser/LowLevelAccess.java
plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java

index be147979b3ce9aaf34520fd95ef453f8ab25b1cb..39959691cf0a9de0303736584c9d619d5c6c3ac9 100644 (file)
@@ -56,7 +56,14 @@ public interface LowLevelAccess {
 
   void loadAllTags(final Collection<String> sink) throws VcsException;
 
-  void cherryPick(GitCommit hash) throws VcsException;
+  /**
+   * Cherry-picks the specified commit.
+   * Doesn't autocommit - instead puts the changes into a separate changelist.
+   * In the case of merge conflict provides the Conflict Resolver dialog.
+   * @return true if all conflicts were resolved or there were no merge conflicts; false if unresolved files remain.
+   * @throws VcsException
+   */
+  boolean cherryPick(GitCommit hash) throws VcsException;
   void loadHashesWithParents(final @NotNull Collection<String> startingPoints, @NotNull final Collection<ChangesFilter.Filter> filters,
                              final AsynchConsumer<CommitHashPlusParents> consumer, Getter<Boolean> isCanceled, int useMaxCnt) throws VcsException;
   List<GitCommit> getCommitDetails(final Collection<String> commitIds, SymbolicRefs refs) throws VcsException;
index 1b88653e0f5536d3f07f43426e0edff8975475b4..6afd6c8e654bc49628573b05371af0e32922efc8 100644 (file)
@@ -195,7 +195,7 @@ public class LowLevelAccessImpl implements LowLevelAccess {
     GitTag.listAsStrings(myProject, myRoot, sink, null);
   }
 
-  public void cherryPick(GitCommit commit) throws VcsException {
+  public boolean cherryPick(GitCommit commit) throws VcsException {
     final GitLineHandler handler = new GitLineHandler(myProject, myRoot, GitCommand.CHERRY_PICK);
     handler.addParameters("-x", "-n", commit.getHash().getValue());
     handler.endOptions();
@@ -213,14 +213,16 @@ public class LowLevelAccessImpl implements LowLevelAccess {
     handler.runInCurrentThread(null);
 
     if (conflict.get()) {
-      new CherryPickConflictResolver(myProject, commit.getShortHash().getString(), commit.getAuthor(), commit.getSubject()).merge(Collections.singleton(myRoot));
+      boolean allConflictsResolved = new CherryPickConflictResolver(myProject, commit.getShortHash().getString(), commit.getAuthor(), commit.getSubject()).merge(Collections.singleton(myRoot));
+      return allConflictsResolved;
     } else {
       final List<VcsException> errors = handler.errors();
       if (!errors.isEmpty()) {
         throw errors.get(0);
+      } else { // no conflicts, no errors
+        return true;
       }
     }
-
   }
 
   private static class CherryPickConflictResolver extends GitMergeConflictResolver {