changeset 380:3bc8125671b8

Merge branch Eluru-6.5.x
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Wed, 15 Feb 2012 13:23:53 +0400
parents a4829fde54f5 (current diff) 55c2c88a2d82 (diff)
children 44a16c27bed6
files mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CommandFactoryImpl.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java
diffstat 4 files changed, 19 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java	Tue Feb 14 19:33:41 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java	Wed Feb 15 13:23:53 2012 +0400
@@ -16,7 +16,6 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
 import com.intellij.execution.configurations.GeneralCommandLine;
-import com.intellij.openapi.util.SystemInfo;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
@@ -51,37 +50,11 @@
 
   protected GeneralCommandLine createCL() {
     GeneralCommandLine cl = new MercurialCommandLine(getPrivateData());
-    setupExecutable(cl);
+    cl.setExePath(myHgPath);
     return cl;
   }
 
   protected Set<String> getPrivateData() {
     return emptySet();
   }
-
-  /**
-   * Since mercurial 1.7 on Windows the only file inside '<mercurial_install_dir>/bin' is 'hg.cmd'
-   * which run hg.exe placed in the parent dir. GeneralCommandLine will not find hg.cmd, in the
-   * case when $PATH contains <mercurial_install_dir>/bin and doesn't contain <mercurial_install_dir>
-   * and hg executable is set to 'hg'. To fix it - run hg using windows shell which expand
-   * hg to hg.cmd correctly.
-   * @param cli command line in which to setup hg executable
-   */
-  private void setupExecutable(GeneralCommandLine cli) {
-    if (SystemInfo.isWindows && myHgPath.equals("hg")) {
-      setupCmd(cli);
-    } else {
-      setupHg(cli);
-    }
-  }
-
-  private void setupCmd(GeneralCommandLine cli) {
-    cli.setExePath("cmd");
-    cli.addParameter("/c");
-    cli.addParameter("hg");
-  }
-
-  private void setupHg(GeneralCommandLine cli) {
-    cli.setExePath(myHgPath);
-  }
 }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java	Tue Feb 14 19:33:41 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java	Wed Feb 15 13:23:53 2012 +0400
@@ -161,4 +161,8 @@
       }
     }
   }
+
+  public byte[] getByteOut() {
+    return myDelegate.getByteOut();
+  }
 }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java	Tue Feb 14 19:33:41 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java	Wed Feb 15 13:23:53 2012 +0400
@@ -25,6 +25,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -74,6 +75,7 @@
 
   public List<ChangeSet> execute() throws VcsException {
     GeneralCommandLine cli = createCommandLine();
+    cli.addParameters("--encoding", "UTF-8");
     cli.addParameter("log");
     cli.addParameter("-v");
     cli.addParameter("--style=" + myTemplate.getAbsolutePath());
@@ -95,13 +97,22 @@
     }
 
     CommandResult res = runCommand(cli);
+    String output = getStdout(res);
     try {
-      List<ChangeSet> changes = parseChangeSetsXml(res.getStdout());
+      List<ChangeSet> changes = parseChangeSetsXml(output);
       if (myCalculateParents)
         assignTrivialParents(changes);
       return changes;
     } catch (Exception e) {
-      throw new VcsException("Error while parsing log output:\n" + res.getStdout(), e);
+      throw new VcsException("Error while parsing log output:\n" + output, e);
+    }
+  }
+
+  private String getStdout(CommandResult res) throws VcsException {
+    try {
+      return new String(res.getByteOut(), "UTF-8");
+    } catch (UnsupportedEncodingException e) {
+      throw new VcsException("Error while reading output", e);
     }
   }
 
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CommandFactoryImpl.java	Tue Feb 14 19:33:41 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CommandFactoryImpl.java	Wed Feb 15 13:23:53 2012 +0400
@@ -57,9 +57,7 @@
 
   private File createLogTemplate(@NotNull final File templateFileDir) throws IOException {
     File template = new File(templateFileDir, LOG_TEMPLATE_NAME);
-    if (!template.exists()) {
-      FileUtil.copyResource(CommandFactoryImpl.class, "/buildServerResources/log.template", template);
-    }
+    FileUtil.copyResource(CommandFactoryImpl.class, "/buildServerResources/log.template", template);
     return template;
   }