diff --git a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccess.java b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccess.java index be147979b3ce..39959691cf0a 100644 --- a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccess.java +++ b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccess.java @@ -56,7 +56,14 @@ public interface LowLevelAccess { void loadAllTags(final Collection 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 startingPoints, @NotNull final Collection filters, final AsynchConsumer consumer, Getter isCanceled, int useMaxCnt) throws VcsException; List getCommitDetails(final Collection commitIds, SymbolicRefs refs) throws VcsException; diff --git a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java index 1b88653e0f55..6afd6c8e654b 100644 --- a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java +++ b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java @@ -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 errors = handler.errors(); if (!errors.isEmpty()) { throw errors.get(0); + } else { // no conflicts, no errors + return true; } } - } private static class CherryPickConflictResolver extends GitMergeConflictResolver {