# HG changeset patch # User Dmitry Neverov # Date 1329297833 -14400 # Node ID 3bc8125671b89680e5b854d744d25630829aaa05 # Parent a4829fde54f52c9bc274e6cfefe0bd8862887069# Parent 55c2c88a2d82c4fee990f1ef71c07c9d0ff9462a Merge branch Eluru-6.5.x diff -r a4829fde54f5 -r 3bc8125671b8 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java --- 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 getPrivateData() { return emptySet(); } - - /** - * Since mercurial 1.7 on Windows the only file inside '/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 /bin and doesn't contain - * 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); - } } diff -r a4829fde54f5 -r 3bc8125671b8 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java --- 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(); + } } diff -r a4829fde54f5 -r 3bc8125671b8 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java --- 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 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 changes = parseChangeSetsXml(res.getStdout()); + List 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); } } diff -r a4829fde54f5 -r 3bc8125671b8 mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CommandFactoryImpl.java --- 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; }