From 3bc14332c2c85db1a5920aa51ed6ef1326b07564 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Mon, 22 Apr 2013 15:51:21 +0400 Subject: [PATCH] [hg] Log hg command _before_ executing it. That way we can still see hg commands in the log, even if they didn't complete because of some problem (e.g. hanging password prompt). Split logging to logCommand & logResult. logCommand before executing a command, log result after it. --- .../zmlx/hg4idea/execution/HgCommandExecutor.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java index 25c3ecc097d7..fe7cd45e2cbc 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java @@ -145,6 +145,8 @@ public final class HgCommandExecutor { return null; } + logCommand(operation, arguments); + final List cmdLine = new LinkedList(); cmdLine.add(myVcs.getGlobalSettings().getHgExecutable()); if (repo != null) { @@ -214,13 +216,13 @@ public final class HgCommandExecutor { String warnings = warningReceiver.getWarnings(); result.setWarnings(warnings); - log(operation, arguments, result); + logResult(result); return result; } // logging to the Version Control console (without extensions and configs) @SuppressWarnings("UseOfSystemOutOrSystemErr") - private void log(@NotNull String operation, @Nullable List arguments, @NotNull HgCommandResult result) { + private void logCommand(@NotNull String operation, @Nullable List arguments) { if (myProject.isDisposed()) { return; } @@ -244,10 +246,15 @@ public final class HgCommandExecutor { else { LOG.debug(cmdString); } + } + + @SuppressWarnings("UseOfSystemOutOrSystemErr") + private void logResult(@NotNull HgCommandResult result) { + final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode(); // log output if needed if (!result.getRawOutput().isEmpty()) { - if (isUnitTestMode) { + if (unitTestMode) { System.out.print(result.getRawOutput() + "\n"); } if (!myIsSilent && myShowOutput) { @@ -261,7 +268,7 @@ public final class HgCommandExecutor { // log error if (!result.getRawError().isEmpty()) { - if (isUnitTestMode) { + if (unitTestMode) { System.out.print(result.getRawError() + "\n"); } if (!myIsSilent) {