2

I am trying to set up a hook on a remote repository (using hgweb) on a Windows IIS server. The issue I have is that the repository is specified as a UNC path in hgweb's config, and the hook executes cmd.exe using a UNC path which cmd.exe does not support.

Is it possible to specify a different shell to run instead?

Lee Atkinson
  • 2,171
  • 3
  • 20
  • 32

2 Answers2

2

As far as I know, you can't tell Mercurial to use a different shell on Windows (but I think you can on a Linux host)

Instead, you could have your hook script call out to a different shell and have that shell execute another script or set of commands. It's messy, but unfortunately Windows isn't know for having great scripting support, especially when compared to *nix-based platforms.

cdeszaq
  • 30,869
  • 25
  • 117
  • 173
  • or you could write it as a python hook – jk. Jan 18 '12 at 15:44
  • @jk - Make that a proper answer...it is the correct answer for this question. Mine is just a workaround. – cdeszaq Jan 18 '12 at 15:46
  • ok, but I think an external hook that runs another program/script is perfectly valid too – jk. Jan 18 '12 at 15:55
  • Unfortunately, cmd.exe is run by the hook and if the current path is UNC, it ignores it and uses the Windows path as the current path, resulting in the external hook not knowing on which repository it is working on. – Lee Atkinson Jan 20 '12 at 10:06
2

Mercurial hooks can be defined two ways,

  1. as a shell hook (external hook)
  2. as a python hook (in process hook)

if you change it to be a python hook, then you would obviously have the full power of python available to do stuff. Of course there is no reason why you can't write a program in any language and execute it from your external hook as cdeszaq suggests

jk.
  • 13,817
  • 5
  • 37
  • 50
  • 1
    And an additional benefit to using an in-process python hook is that it is cross-platform, so if you switch to a non-windows platform, you don't have to potentially re-write your hook scripts. – cdeszaq Jan 18 '12 at 16:00
  • The problem seems to be that with external hooks, Mercurial launches those from within cmd.exe - at least when I try to call "hg update" (to get the remote repo to update on an incoming hook) it runs cmd.exe. – Lee Atkinson Jan 20 '12 at 10:04
  • 1
    @LeeAtkinson - Then use a python hook, since it will _not_ be run in an external cmd process and will run in the same internal process as hg itself. – cdeszaq Jan 20 '12 at 13:37
  • @cdeszaq - thanks - I've been looking for an example of a python hook to call "hg update" but I haven't found any - I guess because using the external "hg update" is easy and sufficient in most cases. I will mark your response as the answer (that it probably not possible to set the shell) - and continue my serahc for a python-only "hg update" – Lee Atkinson Jan 23 '12 at 12:42