mercurial/hook.py
changeset 38629 38dfd308fe9d
parent 38628 539f9708b980
child 38722 2009d84f245a
--- a/mercurial/hook.py	Sat Jul 07 23:47:49 2018 -0400
+++ b/mercurial/hook.py	Sat Jul 07 23:38:06 2018 -0400
@@ -139,7 +139,9 @@
             v = stringutil.pprint(v)
         env['HG_' + k.upper()] = v
 
-    cmd = procutil.shelltonative(cmd, env)
+    if ui.configbool('hooks', 'tonative.%s' % name, pycompat.iswindows):
+        ui.note(_('converting hook "%s" to native\n') % name)
+        cmd = procutil.shelltonative(cmd, env)
 
     ui.note(_("running hook %s: %s\n") % (name, cmd))
 
@@ -181,9 +183,11 @@
     """return all hooks items ready to be sorted"""
     hooks = {}
     for name, cmd in ui.configitems('hooks', untrusted=_untrusted):
-        if not name.startswith('priority.'):
-            priority = ui.configint('hooks', 'priority.%s' % name, 0)
-            hooks[name] = (-priority, len(hooks), name, cmd)
+        if name.startswith('priority.') or name.startswith('tonative.'):
+            continue
+
+        priority = ui.configint('hooks', 'priority.%s' % name, 0)
+        hooks[name] = (-priority, len(hooks), name, cmd)
     return hooks
 
 _redirect = False