[Mercurial] IDEA-56034. Logging to the Version Control console.
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Tue, 13 Jul 2010 06:04:00 +0000 (10:04 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Tue, 13 Jul 2010 06:04:00 +0000 (10:04 +0400)
plugins/hg4idea/hg4idea.iml
plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java
plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommandService.java
plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java

index f7efe10c0e5fbeae7429e4b25f66bd795b7efb5c..1c036a8a3851545f12d389018d1c03e0337e126c 100644 (file)
@@ -16,6 +16,7 @@
     <orderEntry type="module" module-name="platform-api" />
     <orderEntry type="module" module-name="vcs-impl" />
     <orderEntry type="module" module-name="platform-impl" />
+    <orderEntry type="module" module-name="lang-api" />
   </component>
 </module>
 
index 6a06a51af968616345c355c9b00a697ea20be5ed..4b8d677c9267f351c94348be12b889e1dba26b2a 100644 (file)
 package org.zmlx.hg4idea;
 
 import com.intellij.concurrency.JobScheduler;
+import com.intellij.execution.ui.ConsoleViewContentType;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diff.impl.patch.formove.FilePathComparator;
+import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
 import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
 import com.intellij.openapi.fileEditor.FileEditorManagerListener;
@@ -46,6 +48,7 @@ import com.intellij.util.containers.ComparatorDelegate;
 import com.intellij.util.containers.Convertor;
 import com.intellij.util.messages.MessageBusConnection;
 import com.intellij.util.messages.Topic;
+import org.jetbrains.annotations.NotNull;
 import org.zmlx.hg4idea.provider.*;
 import org.zmlx.hg4idea.provider.annotate.HgAnnotationProvider;
 import org.zmlx.hg4idea.provider.commit.HgCheckinEnvironment;
@@ -101,16 +104,19 @@ public class HgVcs extends AbstractVcs<CommittedChangeList> {
   private ScheduledFuture<?> changesUpdaterScheduledFuture;
   private final HgGlobalSettings globalSettings;
   private final HgProjectSettings projectSettings;
+  private final ProjectLevelVcsManager myVcsManager;
 
   private boolean started = false;
   private HgVFSListener myVFSListener;
   private VirtualFileListener myDirStateChangeListener;
 
   public HgVcs(Project project,
-    HgGlobalSettings globalSettings, HgProjectSettings projectSettings) {
+    HgGlobalSettings globalSettings, HgProjectSettings projectSettings,
+    ProjectLevelVcsManager vcsManager) {
     super(project, VCS_NAME);
     this.globalSettings = globalSettings;
     this.projectSettings = projectSettings;
+    myVcsManager = vcsManager;
     configurable = new HgProjectConfigurable(projectSettings);
     changeProvider = new HgChangeProvider(project, getKeyInstanceMethod());
     rollbackEnvironment = new HgRollbackEnvironment(project);
@@ -388,4 +394,10 @@ public class HgVcs extends AbstractVcs<CommittedChangeList> {
   public HgGlobalSettings getGlobalSettings() {
     return globalSettings;
   }
+
+  public void showMessageInConsole(String message, final TextAttributes style) {
+    myVcsManager.addMessageToConsoleWindow(message, style);
+  }
+
+
 }
index 5efd3bba869c202d735d068c5f0cfdf27735485c..aefb8fc54fa2677066ed03ee1b79ba547faee07a 100644 (file)
@@ -12,6 +12,7 @@
 // limitations under the License.
 package org.zmlx.hg4idea.command;
 
+import com.intellij.execution.ui.ConsoleViewContentType;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.components.ServiceManager;
@@ -19,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.vcsUtil.VcsUtil;
+import org.apache.commons.lang.StringUtils;
 import org.jetbrains.annotations.Nullable;
 import org.zmlx.hg4idea.*;
 
@@ -40,7 +42,7 @@ public final class HgCommandService {
 
   static final Logger LOG = Logger.getInstance(HgCommandService.class.getName());
 
-  private static final List<String> DEFAULT_OPTIONS = Arrays.asList(
+  static final List<String> DEFAULT_OPTIONS = Arrays.asList(
     "--config", "ui.merge=internal:merge"
   );
 
@@ -77,6 +79,11 @@ public final class HgCommandService {
   @Nullable
   HgCommandResult execute(VirtualFile repo, List<String> hgOptions,
     String operation, List<String> arguments, Charset charset) {
+    return execute(repo, hgOptions, operation, arguments, charset, false);
+  }
+
+  HgCommandResult execute(VirtualFile repo, List<String> hgOptions,
+    String operation, List<String> arguments, Charset charset, boolean suppressCommandOutput) {
 
     if (!validator.check(mySettings)) {
       return null;
@@ -134,6 +141,17 @@ public final class HgCommandService {
     }
     String warnings = warningReceiver.getWarnings();
     result.setWarnings(warnings);
+
+    // logging to the Version Control console (without extensions and configs)
+    final String cmdString = String.format("%s %s %s", HgVcs.HG_EXECUTABLE_FILE_NAME, operation,
+            StringUtils.join(arguments, " "));
+    final HgVcs hgVcs = HgVcs.getInstance(myProject);
+    hgVcs.showMessageInConsole(cmdString, ConsoleViewContentType.USER_INPUT.getAttributes());
+    if (!suppressCommandOutput) {
+      hgVcs.showMessageInConsole(result.getRawOutput(), ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
+    }
+    hgVcs.showMessageInConsole(result.getRawError(), ConsoleViewContentType.ERROR_OUTPUT.getAttributes());
+
     return result;
 
   }
index 210ac7de88e2c0748d7872dd7471ee4a8b429c64..7c429d2d400e35ec1315b7902167787876cb37cb 100644 (file)
@@ -22,6 +22,7 @@ import org.zmlx.hg4idea.HgFile;
 import org.zmlx.hg4idea.HgRevisionNumber;
 
 import java.io.File;
+import java.nio.charset.Charset;
 import java.util.*;
 
 public class HgStatusCommand {
@@ -135,7 +136,7 @@ public class HgStatusCommand {
       arguments.add(file);
     }
 
-    HgCommandResult result = service.execute(repo, "status", arguments);
+    HgCommandResult result = service.execute(repo, HgCommandService.DEFAULT_OPTIONS, "status", arguments, Charset.defaultCharset(), true);
     Set<HgChange> changes = new HashSet<HgChange>();
     HgChange previous = null;
     if (result == null) {