From 31e96dec5d62642e6a47fdcb85f652a08225926d Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Thu, 3 Mar 2016 17:15:34 +0300 Subject: [PATCH] [hg]: execute Qnew in current thread and rename hg commit type command execution methods --- .../src/org/zmlx/hg4idea/HgTaskHandler.java | 2 +- .../hg4idea/command/HgCommitTypeCommand.java | 2 +- .../hg4idea/command/mq/HgQNewCommand.java | 20 ++++++++----------- .../provider/commit/HgCheckinEnvironment.java | 2 +- .../provider/update/HgRegularUpdater.java | 2 +- .../testSrc/hg4idea/test/HgEncodingTest.java | 4 ++-- .../hg4idea/test/commit/HgCommitTest.java | 2 +- .../testSrc/hg4idea/test/mq/MqPatchTest.java | 2 +- 8 files changed, 16 insertions(+), 20 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgTaskHandler.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgTaskHandler.java index 843c14cc3c6b..88d389bd870f 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgTaskHandler.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgTaskHandler.java @@ -87,7 +87,7 @@ public class HgTaskHandler extends DvcsTaskHandler { Project project = repository.getProject(); VirtualFile repositoryRoot = repository.getRoot(); try { - new HgCommitCommand(project, repository, "Automated merge with " + branch).execute(); + new HgCommitCommand(project, repository, "Automated merge with " + branch).executeInCurrentThread(); new HgBookmarkCommand(project, repositoryRoot, branch).deleteBookmark(); } catch (HgCommandException e) { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitTypeCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitTypeCommand.java index ad5078e3492b..adca817b3a88 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitTypeCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitTypeCommand.java @@ -76,7 +76,7 @@ public abstract class HgCommitTypeCommand { } - public void execute() throws HgCommandException, VcsException { + public void executeInCurrentThread() throws HgCommandException, VcsException { if (StringUtil.isEmptyOrSpaces(myMessage)) { throw new HgCommandException(HgVcsMessages.message("hg4idea.commit.error.messageEmpty")); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQNewCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQNewCommand.java index 22d6bbf39935..ca0b7286a9b6 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQNewCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/mq/HgQNewCommand.java @@ -47,13 +47,13 @@ public class HgQNewCommand extends HgCommitTypeCommand { @Override protected void executeChunked(@NotNull List> chunkedCommits) throws HgCommandException, VcsException { if (chunkedCommits.isEmpty()) { - executeQNew(ContainerUtil.emptyList()); + executeQNewInCurrentThread(ContainerUtil.emptyList()); } else { int size = chunkedCommits.size(); int i = 0; if (!myAmend) { - executeQNew(chunkedCommits.get(0)); + executeQNewInCurrentThread(chunkedCommits.get(0)); i = 1; } for (; i < size; i++) { @@ -82,7 +82,7 @@ public class HgQNewCommand extends HgCommitTypeCommand { }); } - private void executeQNew(@NotNull List chunkFiles) throws VcsException { + private void executeQNewInCurrentThread(@NotNull List chunkFiles) throws VcsException { List args = ContainerUtil.newArrayList(); args.add("-l"); args.add(saveCommitMessage().getAbsolutePath()); @@ -91,14 +91,10 @@ public class HgQNewCommand extends HgCommitTypeCommand { args.add(patchName); args.addAll(chunkFiles); HgCommandExecutor executor = new HgCommandExecutor(myProject); - executor.execute(myRepository.getRoot(), "qnew", args, new HgCommandResultHandler() { - @Override - public void process(@Nullable HgCommandResult result) { - if (HgErrorUtil.hasErrorsInCommandExecution(result)) { - new HgCommandResultNotifier(myProject) - .notifyError(result, "Qnew Failed", "Could not create mq patch for selected changes"); - } - } - }); + HgCommandResult result = executor.executeInCurrentThread(myRepository.getRoot(), "qnew", args); + if (HgErrorUtil.hasErrorsInCommandExecution(result)) { + new HgCommandResultNotifier(myProject) + .notifyError(result, "Qnew Failed", "Could not create mq patch for selected changes"); + } } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java index 846b435a62eb..a582759e48e1 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java @@ -144,7 +144,7 @@ public class HgCheckinEnvironment implements CheckinEnvironment { command.setFiles(selectedFiles); } try { - command.execute(); + command.executeInCurrentThread(); } catch (HgCommandException e) { exceptions.add(new VcsException(e)); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java index 88d8fdf6baac..80109b41f6f1 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java @@ -192,7 +192,7 @@ public class HgRegularUpdater implements HgUpdater { LOG.warn("Couldn't find repository info for " + repoRoot.getName()); return; } - new HgCommitCommand(project, hgRepository, "Automated merge").execute(); + new HgCommitCommand(project, hgRepository, "Automated merge").executeInCurrentThread(); } catch (HgCommandException e) { throw new VcsException(e); diff --git a/plugins/hg4idea/testSrc/hg4idea/test/HgEncodingTest.java b/plugins/hg4idea/testSrc/hg4idea/test/HgEncodingTest.java index cfc649cd6913..c6116e134011 100644 --- a/plugins/hg4idea/testSrc/hg4idea/test/HgEncodingTest.java +++ b/plugins/hg4idea/testSrc/hg4idea/test/HgEncodingTest.java @@ -43,7 +43,7 @@ public class HgEncodingTest extends HgPlatformTest { echo("file.txt", "lalala"); HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject); HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, "сообщение"); - commitCommand.execute(); + commitCommand.executeInCurrentThread(); } //test SpecialCharacters in commit message for default EncodingProject settings @@ -55,7 +55,7 @@ public class HgEncodingTest extends HgPlatformTest { String comment = "öäüß"; HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject); HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, comment); - commitCommand.execute(); + commitCommand.executeInCurrentThread(); HgLogCommand logCommand = new HgLogCommand(myProject); myRepository.refresh(false, true); VirtualFile file = myRepository.findChild(fileName); diff --git a/plugins/hg4idea/testSrc/hg4idea/test/commit/HgCommitTest.java b/plugins/hg4idea/testSrc/hg4idea/test/commit/HgCommitTest.java index 36fe33f8d9b6..1002028c7bbf 100644 --- a/plugins/hg4idea/testSrc/hg4idea/test/commit/HgCommitTest.java +++ b/plugins/hg4idea/testSrc/hg4idea/test/commit/HgCommitTest.java @@ -55,7 +55,7 @@ public class HgCommitTest extends HgPlatformTest { List revisions = logCommand.execute(hgFile, -1, false); HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject); HgCommitCommand commit = new HgCommitCommand(myProject, hgRepo, changedCommit, true); - commit.execute(); + commit.executeInCurrentThread(); List revisionsAfterAmendCommit = logCommand.execute(hgFile, -1, false); assertTrue(revisions.size() == revisionsAfterAmendCommit.size()); assertEquals(revisionsAfterAmendCommit.get(0).getCommitMessage(), changedCommit); diff --git a/plugins/hg4idea/testSrc/hg4idea/test/mq/MqPatchTest.java b/plugins/hg4idea/testSrc/hg4idea/test/mq/MqPatchTest.java index 93645bcd28bb..7415bfba698c 100644 --- a/plugins/hg4idea/testSrc/hg4idea/test/mq/MqPatchTest.java +++ b/plugins/hg4idea/testSrc/hg4idea/test/mq/MqPatchTest.java @@ -85,7 +85,7 @@ public class MqPatchTest extends HgPlatformTest { cd(myRepository); append(FILENAME, "modify"); myRepository.refresh(false,true); - new HgQNewCommand(myProject, myHgRepository, MESSAGE, false).execute(); + new HgQNewCommand(myProject, myHgRepository, MESSAGE, false).executeInCurrentThread(); myRepository.refresh(false,true); MqPatchDetails patchDetails = updateAndGetDetails(); assertEqualsCommitInfo(null, patchDetails);