From f1f86a2c3851001945ee9be1f55c68a023b920ec Mon Sep 17 00:00:00 2001 From: "Nadya.Zabrodina" Date: Fri, 8 Feb 2013 18:39:50 +0400 Subject: [PATCH] IDEA-100740 Can not execute hg command with long argument list. Fix For merge commit action. *If it's merge commit, so myFiles in HgCommitCommand is Empty. Need to commit all files in changeList,but can't call setFiles() method. see HgCheckinEnviroment->commit() method *Check if filePaths is empty, then try to commit without chunk. *May produce ShellCommand error if there are many merged files. Need to fix this case. --- .../zmlx/hg4idea/command/HgCommitCommand.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java index dfd8797301d3..ffcd31656ba2 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java @@ -18,8 +18,6 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.Function; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBus; import com.intellij.vcsUtil.VcsFileUtil; import org.jetbrains.annotations.NotNull; @@ -33,7 +31,10 @@ import org.zmlx.hg4idea.util.HgUtil; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; import static org.zmlx.hg4idea.HgErrorHandler.ensureSuccess; @@ -62,16 +63,23 @@ public class HgCommitCommand { throw new HgCommandException(HgVcsMessages.message("hg4idea.commit.error.messageEmpty")); } List relativePaths = HgUtil.getRelativePathsByRepository(myFiles).get(myRoot); + //if it's merge commit, so myFiles is Empty. Need to commit all files in changeList, can't call setFiles() method. + // see HgCheckinEnviroment->commit() method if (relativePaths == null) { - return; // relativePaths for root shouldn't be empty; - } - for (List chunk : VcsFileUtil.chunkRelativePaths(relativePaths)) { List parameters = new LinkedList(); parameters.add("--logfile"); parameters.add(saveCommitMessage().getAbsolutePath()); - parameters.addAll(chunk); ensureSuccess(new HgCommandExecutor(myProject).executeInCurrentThread(myRoot, "commit", parameters)); } + else { + for (List chunk : VcsFileUtil.chunkRelativePaths(relativePaths)) { + List parameters = new LinkedList(); + parameters.add("--logfile"); + parameters.add(saveCommitMessage().getAbsolutePath()); + parameters.addAll(chunk); + ensureSuccess(new HgCommandExecutor(myProject).executeInCurrentThread(myRoot, "commit", parameters)); + } + } final MessageBus messageBus = myProject.getMessageBus(); messageBus.syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, null); messageBus.syncPublisher(HgVcs.BRANCH_TOPIC).update(myProject, null);