Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hook.py @ 31749:5678496659e9
hook: use 'htype' in 'runhooks'
Same rational as for '_pythonhook', 'htype' is more accurate and less error
prone. We just fixed an error from the 'name'/'hname' confusion and this should
prevent them in the future.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Fri, 31 Mar 2017 11:03:23 +0200 |
parents | f610c3220eec |
children | 33504b54863e |
comparison
equal
deleted
inserted
replaced
31748:f610c3220eec | 31749:5678496659e9 |
---|---|
199 r = False | 199 r = False |
200 for hname, cmd in hooks: | 200 for hname, cmd in hooks: |
201 r = res[hname][0] or r | 201 r = res[hname][0] or r |
202 return r | 202 return r |
203 | 203 |
204 def runhooks(ui, repo, name, hooks, throw=False, **args): | 204 def runhooks(ui, repo, htype, hooks, throw=False, **args): |
205 res = {} | 205 res = {} |
206 oldstdout = -1 | 206 oldstdout = -1 |
207 | 207 |
208 try: | 208 try: |
209 for hname, cmd in hooks: | 209 for hname, cmd in hooks: |
227 hint = _("see 'hg help config.trusted'")) | 227 hint = _("see 'hg help config.trusted'")) |
228 ui.warn(_('warning: untrusted hook %s not executed\n') % hname) | 228 ui.warn(_('warning: untrusted hook %s not executed\n') % hname) |
229 r = 1 | 229 r = 1 |
230 raised = False | 230 raised = False |
231 elif callable(cmd): | 231 elif callable(cmd): |
232 r, raised = _pythonhook(ui, repo, name, hname, cmd, args, throw) | 232 r, raised = _pythonhook(ui, repo, htype, hname, cmd, args, |
233 throw) | |
233 elif cmd.startswith('python:'): | 234 elif cmd.startswith('python:'): |
234 if cmd.count(':') >= 2: | 235 if cmd.count(':') >= 2: |
235 path, cmd = cmd[7:].rsplit(':', 1) | 236 path, cmd = cmd[7:].rsplit(':', 1) |
236 path = util.expandpath(path) | 237 path = util.expandpath(path) |
237 if repo: | 238 if repo: |
242 ui.write(_("loading %s hook failed:\n") % hname) | 243 ui.write(_("loading %s hook failed:\n") % hname) |
243 raise | 244 raise |
244 hookfn = getattr(mod, cmd) | 245 hookfn = getattr(mod, cmd) |
245 else: | 246 else: |
246 hookfn = cmd[7:].strip() | 247 hookfn = cmd[7:].strip() |
247 r, raised = _pythonhook(ui, repo, name, hname, hookfn, args, | 248 r, raised = _pythonhook(ui, repo, htype, hname, hookfn, args, |
248 throw) | 249 throw) |
249 else: | 250 else: |
250 r = _exthook(ui, repo, hname, cmd, args, throw) | 251 r = _exthook(ui, repo, hname, cmd, args, throw) |
251 raised = False | 252 raised = False |
252 | 253 |