From 4d55fdde0d0cdb67df877b506e9ebebed019723a Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Sat, 21 Dec 2013 16:14:58 +0400 Subject: [PATCH] OutputSuppressed option added for HgCommandExecutor, style changed, unnecessary parameters removed --- .../zmlx/hg4idea/command/HgCatCommand.java | 1 + .../zmlx/hg4idea/command/HgLogCommand.java | 4 ++- .../hg4idea/execution/HgCommandExecutor.java | 25 ++++++++++++------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCatCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCatCommand.java index daf6ba94aac9..c5666e7481fb 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCatCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCatCommand.java @@ -39,6 +39,7 @@ public class HgCatCommand { final HgCommandExecutor executor = new HgCommandExecutor(myProject); executor.setOptions(Collections.emptyList()); executor.setSilent(true); + executor.setOutputAlwaysSuppressed(true); executor.setCharset(charset); final HgCommandResult result = executor.executeInCurrentThread(hgFile.getRepo(), "cat", arguments); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgLogCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgLogCommand.java index c8c92e8c9595..ed93beecfa7f 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgLogCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgLogCommand.java @@ -236,7 +236,9 @@ public class HgLogCommand { if (myLogFile && hgFile != null) { arguments.add(hgFile.getRelativePath()); } - return new HgCommandExecutor(myProject).executeInCurrentThread(repo, "log", arguments); + HgCommandExecutor commandExecutor = new HgCommandExecutor(myProject); + commandExecutor.setOutputAlwaysSuppressed(true); + return commandExecutor.executeInCurrentThread(repo, "log", arguments); } private static Set parseFileList(String fileListString) { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java index a7116790356e..bcf27470c7cc 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java @@ -65,6 +65,8 @@ public final class HgCommandExecutor { @NotNull private Charset myCharset; private boolean myIsSilent = false; private boolean myShowOutput = false; + + private boolean myOutputAlwaysSuppressed = false; //for command with enormous output, like log or cat private List myOptions = DEFAULT_OPTIONS; @Nullable private ModalityState myState; @@ -102,6 +104,10 @@ public final class HgCommandExecutor { myShowOutput = showOutput; } + public void setOutputAlwaysSuppressed(boolean outputAlwaysSuppressed) { + myOutputAlwaysSuppressed = outputAlwaysSuppressed; + } + public void execute(@Nullable final VirtualFile repo, @NotNull final String operation, @Nullable final List arguments, @Nullable final HgCommandResultHandler handler) { HgUtil.executeOnPooledThreadIfNeeded(new Runnable() { @@ -230,7 +236,7 @@ public final class HgCommandExecutor { } String warnings = warningReceiver.getWarnings(); result.setWarnings(warnings); - logResult(result, operation); + logResult(result); return result; } @@ -263,7 +269,7 @@ public final class HgCommandExecutor { } @SuppressWarnings("UseOfSystemOutOrSystemErr") - private void logResult(@NotNull HgCommandResult result, @NotNull String operationName) { + private void logResult(@NotNull HgCommandResult result) { final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode(); // log output if needed @@ -271,13 +277,14 @@ public final class HgCommandExecutor { if (unitTestMode) { System.out.print(result.getRawOutput() + "\n"); } - else if (!myIsSilent && myShowOutput) { - LOG.info(result.getRawOutput()); - myVcs.showMessageInConsole(result.getRawOutput(), ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes()); - } - else if (!StringUtil.equalsIgnoreCase(operationName, "log")) { - //too big output for log command! - LOG.debug(result.getRawOutput()); + else if (!myOutputAlwaysSuppressed) { + if (!myIsSilent && myShowOutput) { + LOG.info(result.getRawOutput()); + myVcs.showMessageInConsole(result.getRawOutput(), ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes()); + } + else { + LOG.debug(result.getRawOutput()); + } } }