[Git] cherryPick returns false if not all conflicts were resolved.

This commit is contained in:
Kirill Likhodedov
2011-05-12 11:39:39 +04:00
parent 5304e6f6e3
commit 1c2dfda261
2 changed files with 13 additions and 4 deletions
@@ -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;
@@ -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 {