[hg]: execute QImport in current thread in tests, provide appropriate method

This commit is contained in:
Nadya Zabrodina
2016-03-09 14:29:25 +03:00
parent 31e96dec5d
commit b9b5f0b5ee
2 changed files with 17 additions and 13 deletions
@@ -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<String> 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();
}
}
@@ -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);