diff mercurial/hook.py @ 38484:e9e61fbac787

hooks: allow Unix style environment variables on external Windows hooks This will help making common hooks between Windows and non-Windows platforms. Having to build the shellenviron dict here and in procutil.system() is a bit unfortunate, but the only other option is to fix up the command inside procutil.system(). It seems more important that the note about the hook being run reflects what is actually run. The patch from last summer added the hooks on the command line, but it looks like HG_ARGS has since learned about --config args, and the output was just confusing. Therefore, it's now loaded from a file in the histedit test for clarity.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 02 Jul 2017 00:32:09 -0400
parents 242eb5132203
children 72286f9e324f
line wrap: on
line diff
--- a/mercurial/hook.py	Sun Jun 24 01:13:09 2018 -0400
+++ b/mercurial/hook.py	Sun Jul 02 00:32:09 2017 -0400
@@ -120,8 +120,6 @@
     return r, False
 
 def _exthook(ui, repo, htype, name, cmd, args, throw):
-    ui.note(_("running hook %s: %s\n") % (name, cmd))
-
     starttime = util.timer()
     env = {}
 
@@ -141,6 +139,12 @@
             v = stringutil.pprint(v)
         env['HG_' + k.upper()] = v
 
+    if pycompat.iswindows:
+        environ = procutil.shellenviron(env)
+        cmd = util.platform.shelltocmdexe(cmd, environ)
+
+    ui.note(_("running hook %s: %s\n") % (name, cmd))
+
     if repo:
         cwd = repo.root
     else: