From 61869d4fbf28ce7830cb0178ae968847caefeaba Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Wed, 2 Mar 2016 18:26:14 +0300 Subject: [PATCH] [hg] rename Mq patches commands execute to executeInCurrentThread and move real execution from PooledThread to current --- .../action/mq/HgActionFromMqPatches.java | 4 ++-- .../action/mq/HgQFoldActionFromPatches.java | 4 ++-- .../action/mq/HgQGotoActionFromMqPatches.java | 2 +- .../action/mq/HgQPushActionFromPatches.java | 4 ++-- .../action/mq/HgSingleActionFomMqPatches.java | 6 ++--- .../hg4idea/command/mq/HgQFoldCommand.java | 22 +++++++------------ .../hg4idea/command/mq/HgQPushCommand.java | 22 +++++++------------ 7 files changed, 26 insertions(+), 38 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgActionFromMqPatches.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgActionFromMqPatches.java index acaeb5a88984..4ee0c40c833d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgActionFromMqPatches.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgActionFromMqPatches.java @@ -35,7 +35,7 @@ public abstract class HgActionFromMqPatches extends DumbAwareAction { @Override public void run() { ProgressManager.getInstance().getProgressIndicator().setText(getTitle()); - execute(repository, names); + executeInCurrentThread(repository, names); } }; patchInfo.updatePatchSeriesInBackground(task); @@ -51,7 +51,7 @@ public abstract class HgActionFromMqPatches extends DumbAwareAction { return true; //todo should be improved, param not needed } - protected abstract void execute(@NotNull HgRepository repository, @NotNull List patchNames); + protected abstract void executeInCurrentThread(@NotNull HgRepository repository, @NotNull List patchNames); @NotNull protected abstract String getTitle(); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQFoldActionFromPatches.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQFoldActionFromPatches.java index 889909fcf72b..79eb30e85e29 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQFoldActionFromPatches.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQFoldActionFromPatches.java @@ -24,8 +24,8 @@ import java.util.List; public class HgQFoldActionFromPatches extends HgActionFromMqPatches { @Override - protected void execute(@NotNull HgRepository repository, @NotNull List patchNames) { - new HgQFoldCommand(repository).execute(patchNames); + protected void executeInCurrentThread(@NotNull HgRepository repository, @NotNull List patchNames) { + new HgQFoldCommand(repository).executeInCurrentThread(patchNames); } @NotNull diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQGotoActionFromMqPatches.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQGotoActionFromMqPatches.java index 1ea0cd46b234..fd1afcc07650 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQGotoActionFromMqPatches.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQGotoActionFromMqPatches.java @@ -22,7 +22,7 @@ import org.zmlx.hg4idea.repo.HgRepository; public class HgQGotoActionFromMqPatches extends HgSingleActionFomMqPatches { @Override - protected void execute(@NotNull HgRepository repository, @NotNull String patchName) { + protected void executeInCurrentThread(@NotNull HgRepository repository, @NotNull String patchName) { new HgQGotoCommand(repository).executeInCurrentThread(patchName); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQPushActionFromPatches.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQPushActionFromPatches.java index 294ba141794b..e218676e3340 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQPushActionFromPatches.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgQPushActionFromPatches.java @@ -21,8 +21,8 @@ import org.zmlx.hg4idea.repo.HgRepository; public class HgQPushActionFromPatches extends HgSingleActionFomMqPatches { @Override - protected void execute(@NotNull HgRepository repository, @NotNull String patchName) { - new HgQPushCommand(repository).execute(patchName); + protected void executeInCurrentThread(@NotNull HgRepository repository, @NotNull String patchName) { + new HgQPushCommand(repository).executeInCurrentThread(patchName); } @NotNull diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgSingleActionFomMqPatches.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgSingleActionFomMqPatches.java index dcdb6beadbd5..18ce4e65a018 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgSingleActionFomMqPatches.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/mq/HgSingleActionFomMqPatches.java @@ -24,9 +24,9 @@ import java.util.List; public abstract class HgSingleActionFomMqPatches extends HgActionFromMqPatches { @Override - protected void execute(@NotNull HgRepository repository, @NotNull List patchNames) { + protected void executeInCurrentThread(@NotNull HgRepository repository, @NotNull List patchNames) { assert patchNames.size() == 1; - execute(repository, patchNames.iterator().next()); + executeInCurrentThread(repository, patchNames.iterator().next()); } @Override @@ -35,5 +35,5 @@ public abstract class HgSingleActionFomMqPatches extends HgActionFromMqPatches { e.getPresentation().setEnabled(patchInfo != null && patchInfo.getSelectedRowsCount() == 1); } - protected abstract void execute(@NotNull HgRepository repository, @NotNull String patchName); + protected abstract void executeInCurrentThread(@NotNull HgRepository repository, @NotNull String patchName); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQFoldCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQFoldCommand.java index 813cf019b8b4..45c9347ff91d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQFoldCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQFoldCommand.java @@ -17,11 +17,9 @@ package org.zmlx.hg4idea.command.mq; import com.intellij.openapi.project.Project; 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; @@ -34,18 +32,14 @@ public class HgQFoldCommand { myRepository = repository; } - public void execute(@NotNull final List patchNames) { + public void executeInCurrentThread(@NotNull final List patchNames) { final Project project = myRepository.getProject(); - new HgCommandExecutor(project) - .execute(myRepository.getRoot(), "qfold", patchNames, new HgCommandResultHandler() { - @Override - public void process(@Nullable HgCommandResult result) { - if (HgErrorUtil.hasErrorsInCommandExecution(result)) { - new HgCommandResultNotifier(project) - .notifyError(result, "QFold command failed", "Could not fold patches into the current patch"); - } - myRepository.update(); - } - }); + HgCommandResult result = new HgCommandExecutor(project) + .executeInCurrentThread(myRepository.getRoot(), "qfold", patchNames); + if (HgErrorUtil.hasErrorsInCommandExecution(result)) { + new HgCommandResultNotifier(project) + .notifyError(result, "QFold command failed", "Could not fold patches into the current patch"); + } + myRepository.update(); } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQPushCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQPushCommand.java index b3e4d510429f..f75c96aea4b2 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQPushCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQPushCommand.java @@ -17,11 +17,9 @@ package org.zmlx.hg4idea.command.mq; import com.intellij.openapi.project.Project; 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; @@ -34,18 +32,14 @@ public class HgQPushCommand { myRepository = repository; } - public void execute(@NotNull final String patchName) { + public void executeInCurrentThread(@NotNull final String patchName) { final Project project = myRepository.getProject(); - new HgCommandExecutor(project) - .execute(myRepository.getRoot(), "qpush", Arrays.asList("--move", patchName), new HgCommandResultHandler() { - @Override - public void process(@Nullable HgCommandResult result) { - if (HgErrorUtil.hasErrorsInCommandExecution(result)) { - new HgCommandResultNotifier(project) - .notifyError(result, "QPush command failed", "Could not apply selected patch " + patchName); - } - myRepository.update(); - } - }); + HgCommandResult result = + new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qpush", Arrays.asList("--move", patchName)); + if (HgErrorUtil.hasErrorsInCommandExecution(result)) { + new HgCommandResultNotifier(project) + .notifyError(result, "QPush command failed", "Could not apply selected patch " + patchName); + } + myRepository.update(); } }