# HG changeset patch # User Dmitry Neverov # Date 1293029527 -10800 # Node ID 247273ec5e27c8230a00171ecec6c7619834b51a # Parent 142ff77e52b3281c38b0debc8eadb96631762579 Fix problem with hg.cmd on Windows diff -r 142ff77e52b3 -r 247273ec5e27 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java --- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java Wed Dec 22 12:18:12 2010 +0300 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java Wed Dec 22 17:52:07 2010 +0300 @@ -16,6 +16,7 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; import com.intellij.execution.configurations.GeneralCommandLine; +import com.intellij.openapi.util.SystemInfo; import jetbrains.buildServer.ExecResult; import jetbrains.buildServer.util.StringUtil; import jetbrains.buildServer.vcs.VcsException; @@ -50,12 +51,37 @@ protected GeneralCommandLine createCommandLine() { GeneralCommandLine cli = new GeneralCommandLine(); - cli.setExePath(getSettings().getHgCommandPath()); + setupExecutable(cli); cli.setWorkDirectory(myWorkDirectory); cli.setPassParentEnvs(true); return cli; } + /** + * 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. + */ + private void setupExecutable(GeneralCommandLine cli) { + if (SystemInfo.isWindows && getSettings().getHgCommandPath().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(getSettings().getHgCommandPath()); + } + protected ExecResult runCommand(@NotNull GeneralCommandLine cli) throws VcsException { return CommandUtil.runCommand(cli, getPrivateData()); } diff -r 142ff77e52b3 -r 247273ec5e27 mercurial.ipr --- a/mercurial.ipr Wed Dec 22 12:18:12 2010 +0300 +++ b/mercurial.ipr Wed Dec 22 17:52:07 2010 +0300 @@ -297,6 +297,9 @@ + + http://www.w3.org/1999/xhtml +