IDEA-101439 Mercurial: when committing a lot of files IDEA creates several commits with the same message.

*supported only for 2.2. or later
This commit is contained in:
Nadya Zabrodina
2013-07-23 15:42:21 +04:00
parent 8d87df5fd0
commit dd698fa376
@@ -29,6 +29,7 @@ import org.zmlx.hg4idea.HgVcsMessages;
import org.zmlx.hg4idea.execution.HgCommandException;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import org.zmlx.hg4idea.util.HgEncodingUtil;
import org.zmlx.hg4idea.util.HgVersionUtil;
import java.io.File;
import java.io.IOException;
@@ -69,7 +70,7 @@ public class HgCommitCommand {
//if it's merge commit, so myFiles is Empty. Need to commit all files in changeList.
// see HgCheckinEnviroment->commit() method
if (myFiles.isEmpty()) {
commitChunkFiles(Collections.<String>emptyList());
commitChunkFiles(Collections.<String>emptyList(), false);
}
else {
List<String> relativePaths = ContainerUtil.map2List(myFiles, new Function<HgFile, String>() {
@@ -78,8 +79,13 @@ public class HgCommitCommand {
return file.getRelativePath();
}
});
for (List<String> chunk : VcsFileUtil.chunkRelativePaths(relativePaths)) {
commitChunkFiles(chunk);
List<List<String>> chunkedCommits = VcsFileUtil.chunkRelativePaths(relativePaths);
int size = chunkedCommits.size();
commitChunkFiles(chunkedCommits.get(0), false);
boolean amendCommit = HgVersionUtil.isAmendSupported();
for (int i = 1; i < size; i++) {
List<String> chunk = chunkedCommits.get(i);
commitChunkFiles(chunk, amendCommit);
}
}
final MessageBus messageBus = myProject.getMessageBus();
@@ -87,11 +93,14 @@ public class HgCommitCommand {
messageBus.syncPublisher(HgVcs.BRANCH_TOPIC).update(myProject, null);
}
private void commitChunkFiles(List<String> chunk) throws VcsException {
private void commitChunkFiles(List<String> chunk, boolean amendCommit) throws VcsException {
List<String> parameters = new LinkedList<String>();
parameters.add("--logfile");
parameters.add(saveCommitMessage().getAbsolutePath());
parameters.addAll(chunk);
if (amendCommit) {
parameters.add("--amend");
}
HgCommandExecutor executor = new HgCommandExecutor(myProject);
executor.setCharset(myCharset);
ensureSuccess(executor.executeInCurrentThread(myRoot, "commit", parameters));