From b9b5f0b5ee015aa3387677f1c22a77974ccea077 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Thu, 3 Mar 2016 17:29:06 +0300 Subject: [PATCH] [hg]: execute QImport in current thread in tests, provide appropriate method --- .../hg4idea/command/mq/HgQImportCommand.java | 28 +++++++++++-------- .../testSrc/hg4idea/test/mq/MqPatchTest.java | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQImportCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQImportCommand.java index 7d6a23b00bd4..c90fed6672de 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQImportCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQImportCommand.java @@ -18,13 +18,12 @@ package org.zmlx.hg4idea.command.mq; import com.intellij.openapi.project.Project; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.action.HgCommandResultNotifier; import org.zmlx.hg4idea.execution.HgCommandExecutor; import org.zmlx.hg4idea.execution.HgCommandResult; -import org.zmlx.hg4idea.execution.HgCommandResultHandler; import org.zmlx.hg4idea.repo.HgRepository; import org.zmlx.hg4idea.util.HgErrorUtil; +import org.zmlx.hg4idea.util.HgUtil; import java.util.List; @@ -37,18 +36,23 @@ public class HgQImportCommand { } public void execute(@NotNull final String startRevisionNumber) { + HgUtil.executeOnPooledThread(new Runnable() { + @Override + public void run() { + executeInCurrentThread(startRevisionNumber); + } + }, myRepository.getProject()); + } + + public void executeInCurrentThread(@NotNull final String startRevisionNumber) { final Project project = myRepository.getProject(); String lastRevisionName = myRepository.getMQAppliedPatches().isEmpty() ? "tip" : "qparent"; List arguments = ContainerUtil.newArrayList("--rev", startRevisionNumber + ":" + lastRevisionName); - new HgCommandExecutor(project).execute(myRepository.getRoot(), "qimport", arguments, new HgCommandResultHandler() { - @Override - public void process(@Nullable HgCommandResult result) { - if (HgErrorUtil.hasErrorsInCommandExecution(result)) { - new HgCommandResultNotifier(project) - .notifyError(result, "Import failed", "Import revision from " + startRevisionNumber + " to qparent failed"); - } - myRepository.update(); - } - }); + HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qimport", arguments); + if (HgErrorUtil.hasErrorsInCommandExecution(result)) { + new HgCommandResultNotifier(project) + .notifyError(result, "Import failed", "Import revision from " + startRevisionNumber + " to qparent failed"); + } + myRepository.update(); } } diff --git a/plugins/hg4idea/testSrc/hg4idea/test/mq/MqPatchTest.java b/plugins/hg4idea/testSrc/hg4idea/test/mq/MqPatchTest.java index 7415bfba698c..ed76d05867f1 100644 --- a/plugins/hg4idea/testSrc/hg4idea/test/mq/MqPatchTest.java +++ b/plugins/hg4idea/testSrc/hg4idea/test/mq/MqPatchTest.java @@ -75,7 +75,7 @@ public class MqPatchTest extends HgPlatformTest { public void testMqPatchInfoAfterQImport() throws Exception { cd(myRepository); HgQImportCommand importCommand = new HgQImportCommand(myHgRepository); - importCommand.execute("tip"); + importCommand.executeInCurrentThread("tip"); MqPatchDetails patchDetails = updateAndGetDetails(); TimedVcsCommit tipCommitDetailsFromLog = getLastRevisionDetails(); assertEqualsCommitInfo(tipCommitDetailsFromLog, patchDetails);