Mercurial > hg > mercurial
changeset 140:247273ec5e27
Fix problem with hg.cmd on Windows
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Wed, 22 Dec 2010 17:52:07 +0300 |
parents | 142ff77e52b3 |
children | 43db29903d63 2ab0bce4bf64 |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java mercurial.ipr |
diffstat | 2 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 '<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. + */ + 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()); }
--- 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 @@ <module fileurl="file://$PROJECT_DIR$/mercurial-tests/mercurial-tests.iml" filepath="$PROJECT_DIR$/mercurial-tests/mercurial-tests.iml" /> </modules> </component> + <component name="ProjectResources"> + <default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype> + </component> <component name="ProjectRootConfigurable.UI"> <option name="proportions"> <SplitterProportionsDataImpl />