Patchwork [4,of,7,V2] hook: use 'htype' in 'runhooks'

login
register
mail settings
Submitter Pierre-Yves David
Date March 31, 2017, 10:43 p.m.
Message ID <2043a184b25cda298f5d.1491000212@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19880/
State Accepted
Headers show

Comments

Pierre-Yves David - March 31, 2017, 10:43 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1490951003 -7200
#      Fri Mar 31 11:03:23 2017 +0200
# Node ID 2043a184b25cda298f5d590c5c08500471c488d9
# Parent  e033dfed0a983e7c4230fd16eb86bce0e2008659
# EXP-Topic hookname
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 2043a184b25c
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.

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -201,7 +201,7 @@  def hook(ui, repo, name, throw=False, **
         r = res[hname][0] or r
     return r
 
-def runhooks(ui, repo, name, hooks, throw=False, **args):
+def runhooks(ui, repo, htype, hooks, throw=False, **args):
     res = {}
     oldstdout = -1
 
@@ -229,7 +229,8 @@  def runhooks(ui, repo, name, hooks, thro
                 r = 1
                 raised = False
             elif callable(cmd):
-                r, raised = _pythonhook(ui, repo, name, hname, cmd, args, throw)
+                r, raised = _pythonhook(ui, repo, htype, hname, cmd, args,
+                                        throw)
             elif cmd.startswith('python:'):
                 if cmd.count(':') >= 2:
                     path, cmd = cmd[7:].rsplit(':', 1)
@@ -244,7 +245,7 @@  def runhooks(ui, repo, name, hooks, thro
                     hookfn = getattr(mod, cmd)
                 else:
                     hookfn = cmd[7:].strip()
-                r, raised = _pythonhook(ui, repo, name, hname, hookfn, args,
+                r, raised = _pythonhook(ui, repo, htype, hname, hookfn, args,
                                         throw)
             else:
                 r = _exthook(ui, repo, hname, cmd, args, throw)