##// END OF EJS Templates
blackbox: logs python and extension hooks via ui.log()...
Durham Goode -
r18671:1c305128 default
parent child Browse files
Show More
@@ -6,7 +6,7 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import _
8 from i18n import _
9 import os, sys
9 import os, sys, time, types
10 import extensions, util, demandimport
10 import extensions, util, demandimport
11
11
12 def _pythonhook(ui, repo, name, hname, funcname, args, throw):
12 def _pythonhook(ui, repo, name, hname, funcname, args, throw):
@@ -20,6 +20,8 b' def _pythonhook(ui, repo, name, hname, f'
20 be run as hooks without wrappers to convert return values.'''
20 be run as hooks without wrappers to convert return values.'''
21
21
22 ui.note(_("calling hook %s: %s\n") % (hname, funcname))
22 ui.note(_("calling hook %s: %s\n") % (hname, funcname))
23 starttime = time.time()
24
23 obj = funcname
25 obj = funcname
24 if not util.safehasattr(obj, '__call__'):
26 if not util.safehasattr(obj, '__call__'):
25 d = funcname.rfind('.')
27 d = funcname.rfind('.')
@@ -92,6 +94,12 b' def _pythonhook(ui, repo, name, hname, f'
92 return True
94 return True
93 finally:
95 finally:
94 sys.stdout, sys.stderr, sys.stdin = old
96 sys.stdout, sys.stderr, sys.stdin = old
97 duration = time.time() - starttime
98 readablefunc = funcname
99 if isinstance(funcname, types.FunctionType):
100 readablefunc = funcname.__module__ + "." + funcname.__name__
101 ui.log('pythonhook', _('pythonhook-%s: %s finished in %0.2f seconds\n'),
102 name, readablefunc, duration)
95 if r:
103 if r:
96 if throw:
104 if throw:
97 raise util.Abort(_('%s hook failed') % hname)
105 raise util.Abort(_('%s hook failed') % hname)
@@ -101,6 +109,7 b' def _pythonhook(ui, repo, name, hname, f'
101 def _exthook(ui, repo, name, cmd, args, throw):
109 def _exthook(ui, repo, name, cmd, args, throw):
102 ui.note(_("running hook %s: %s\n") % (name, cmd))
110 ui.note(_("running hook %s: %s\n") % (name, cmd))
103
111
112 starttime = time.time()
104 env = {}
113 env = {}
105 for k, v in args.iteritems():
114 for k, v in args.iteritems():
106 if util.safehasattr(v, '__call__'):
115 if util.safehasattr(v, '__call__'):
@@ -121,6 +130,10 b' def _exthook(ui, repo, name, cmd, args, '
121 r = util.system(cmd, environ=env, cwd=cwd, out=ui)
130 r = util.system(cmd, environ=env, cwd=cwd, out=ui)
122 else:
131 else:
123 r = util.system(cmd, environ=env, cwd=cwd, out=ui.fout)
132 r = util.system(cmd, environ=env, cwd=cwd, out=ui.fout)
133
134 duration = time.time() - starttime
135 ui.log('exthook', _('exthook-%s: %s finished in %0.2f seconds\n'),
136 name, cmd, duration)
124 if r:
137 if r:
125 desc, r = util.explainexit(r)
138 desc, r = util.explainexit(r)
126 if throw:
139 if throw:
General Comments 0
You need to be logged in to leave comments. Login now