comparison mercurial/hook.py @ 20547:9d9f8ccffead

hooks: move logging of hook name to after we have found the hook We do not expect the finding process to take a significant amount of time - it is the execution time of the hook we care about.
author Mads Kiilerich <madski@unity3d.com>
date Sat, 15 Feb 2014 01:23:12 +0100
parents aac87f70f38e
children 5bd6a9fec103
comparison
equal deleted inserted replaced
20546:bf1d91ab1efb 20547:9d9f8ccffead
16 hook failure. exception propagates if throw is "true". 16 hook failure. exception propagates if throw is "true".
17 17
18 reason for "true" meaning "hook failed" is so that 18 reason for "true" meaning "hook failed" is so that
19 unmodified commands (e.g. mercurial.commands.update) can 19 unmodified commands (e.g. mercurial.commands.update) can
20 be run as hooks without wrappers to convert return values.''' 20 be run as hooks without wrappers to convert return values.'''
21
22 ui.note(_("calling hook %s: %s\n") % (hname, funcname))
23 starttime = time.time()
24 21
25 obj = funcname 22 obj = funcname
26 if not util.safehasattr(obj, '__call__'): 23 if not util.safehasattr(obj, '__call__'):
27 d = funcname.rfind('.') 24 d = funcname.rfind('.')
28 if d == -1: 25 if d == -1:
73 (hname, funcname)) 70 (hname, funcname))
74 if not util.safehasattr(obj, '__call__'): 71 if not util.safehasattr(obj, '__call__'):
75 raise util.Abort(_('%s hook is invalid ' 72 raise util.Abort(_('%s hook is invalid '
76 '("%s" is not callable)') % 73 '("%s" is not callable)') %
77 (hname, funcname)) 74 (hname, funcname))
75
76 ui.note(_("calling hook %s: %s\n") % (hname, funcname))
77 starttime = time.time()
78
78 try: 79 try:
79 try: 80 try:
80 # redirect IO descriptors to the ui descriptors so hooks 81 # redirect IO descriptors to the ui descriptors so hooks
81 # that write directly to these don't mess up the command 82 # that write directly to these don't mess up the command
82 # protocol when running through the command server 83 # protocol when running through the command server