comparison mercurial/hook.py @ 38629:38dfd308fe9d

hook: add support for disabling the shell to native command translation I think having it on by default is the right thing to do, but this is an escape hatch if someone has a command that shouldn't be mangled. The inspiration is the priority prefix. The translation does nothing on non Windows platforms, so the default value is selected to avoid printing a useless note by default.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 07 Jul 2018 23:38:06 -0400
parents 539f9708b980
children 2009d84f245a
comparison
equal deleted inserted replaced
38628:539f9708b980 38629:38dfd308fe9d
137 v = v() 137 v = v()
138 if isinstance(v, (dict, list)): 138 if isinstance(v, (dict, list)):
139 v = stringutil.pprint(v) 139 v = stringutil.pprint(v)
140 env['HG_' + k.upper()] = v 140 env['HG_' + k.upper()] = v
141 141
142 cmd = procutil.shelltonative(cmd, env) 142 if ui.configbool('hooks', 'tonative.%s' % name, pycompat.iswindows):
143 ui.note(_('converting hook "%s" to native\n') % name)
144 cmd = procutil.shelltonative(cmd, env)
143 145
144 ui.note(_("running hook %s: %s\n") % (name, cmd)) 146 ui.note(_("running hook %s: %s\n") % (name, cmd))
145 147
146 if repo: 148 if repo:
147 cwd = repo.root 149 cwd = repo.root
179 181
180 def _hookitems(ui, _untrusted=False): 182 def _hookitems(ui, _untrusted=False):
181 """return all hooks items ready to be sorted""" 183 """return all hooks items ready to be sorted"""
182 hooks = {} 184 hooks = {}
183 for name, cmd in ui.configitems('hooks', untrusted=_untrusted): 185 for name, cmd in ui.configitems('hooks', untrusted=_untrusted):
184 if not name.startswith('priority.'): 186 if name.startswith('priority.') or name.startswith('tonative.'):
185 priority = ui.configint('hooks', 'priority.%s' % name, 0) 187 continue
186 hooks[name] = (-priority, len(hooks), name, cmd) 188
189 priority = ui.configint('hooks', 'priority.%s' % name, 0)
190 hooks[name] = (-priority, len(hooks), name, cmd)
187 return hooks 191 return hooks
188 192
189 _redirect = False 193 _redirect = False
190 def redirect(state): 194 def redirect(state):
191 global _redirect 195 global _redirect