Patchwork [06,of,11] hooks: move logging of hook name to after we have found the hook

login
register
mail settings
Submitter Mads Kiilerich
Date Feb. 20, 2014, 1:43 a.m.
Message ID <979f87f54d6447a30360.1392860610@localhost.localdomain>
Download mbox | patch
Permalink /patch/3712/
State Accepted
Commit 9d9f8ccffeadb8bb706920ebbdd4f70da8b6d9f0
Headers show

Comments

Mads Kiilerich - Feb. 20, 2014, 1:43 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1392423792 -3600
#      Sat Feb 15 01:23:12 2014 +0100
# Node ID 979f87f54d6447a30360c841b2e4877a6eddd1aa
# Parent  dc8cd282881b9d340184d95084cbec5e35750ccb
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.

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -19,9 +19,6 @@  def _pythonhook(ui, repo, name, hname, f
     unmodified commands (e.g. mercurial.commands.update) can
     be run as hooks without wrappers to convert return values.'''
 
-    ui.note(_("calling hook %s: %s\n") % (hname, funcname))
-    starttime = time.time()
-
     obj = funcname
     if not util.safehasattr(obj, '__call__'):
         d = funcname.rfind('.')
@@ -75,6 +72,10 @@  def _pythonhook(ui, repo, name, hname, f
             raise util.Abort(_('%s hook is invalid '
                                '("%s" is not callable)') %
                              (hname, funcname))
+
+    ui.note(_("calling hook %s: %s\n") % (hname, funcname))
+    starttime = time.time()
+
     try:
         try:
             # redirect IO descriptors to the ui descriptors so hooks