Patchwork [2,of,7,V2] hook: use "htype" as variable name in _pythonhook

login
register
mail settings
Submitter Pierre-Yves David
Date March 31, 2017, 10:43 p.m.
Message ID <c81fb978412978f5d108.1491000210@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19881/
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 1490950777 -7200
#      Fri Mar 31 10:59:37 2017 +0200
# Node ID c81fb978412978f5d10879987ed5a571cb9b0904
# Parent  d808e447f5188f30ec37243016536367bfe5b2c0
# 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 c81fb9784129
hook: use "htype" as variable name  in _pythonhook

We rename 'name' to 'htype' because it fits the variable content better.
Multiple python hooks already use 'htype' as a name for the argument. This makes
the difference with "hname" clearer and the code less error prone.

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -19,7 +19,7 @@  from . import (
     util,
 )
 
-def _pythonhook(ui, repo, name, hname, funcname, args, throw):
+def _pythonhook(ui, repo, htype, hname, funcname, args, throw):
     '''call python hook. hook is callable object, looked up as
     name in python module. if callable returns "true", hook
     fails, else passes. if hook raises exception, treated as
@@ -90,7 +90,7 @@  def _pythonhook(ui, repo, name, hname, f
     starttime = util.timer()
 
     try:
-        r = obj(ui=ui, repo=repo, hooktype=name, **args)
+        r = obj(ui=ui, repo=repo, hooktype=htype, **args)
     except Exception as exc:
         if isinstance(exc, error.Abort):
             ui.warn(_('error: %s hook failed: %s\n') %
@@ -107,7 +107,7 @@  def _pythonhook(ui, repo, name, hname, f
     finally:
         duration = util.timer() - starttime
         ui.log('pythonhook', 'pythonhook-%s: %s finished in %0.2f seconds\n',
-               name, funcname, duration)
+               htype, funcname, duration)
     if r:
         if throw:
             raise error.HookAbort(_('%s hook failed') % hname)