Show More
@@ -6,7 +6,7 b'' | |||
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from i18n import _ |
|
9 | import os, sys | |
|
9 | import os, sys, time, types | |
|
10 | 10 | import extensions, util, demandimport |
|
11 | 11 | |
|
12 | 12 | def _pythonhook(ui, repo, name, hname, funcname, args, throw): |
@@ -20,6 +20,8 b' def _pythonhook(ui, repo, name, hname, f' | |||
|
20 | 20 | be run as hooks without wrappers to convert return values.''' |
|
21 | 21 | |
|
22 | 22 | ui.note(_("calling hook %s: %s\n") % (hname, funcname)) |
|
23 | starttime = time.time() | |
|
24 | ||
|
23 | 25 | obj = funcname |
|
24 | 26 | if not util.safehasattr(obj, '__call__'): |
|
25 | 27 | d = funcname.rfind('.') |
@@ -92,6 +94,12 b' def _pythonhook(ui, repo, name, hname, f' | |||
|
92 | 94 | return True |
|
93 | 95 | finally: |
|
94 | 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 | 103 | if r: |
|
96 | 104 | if throw: |
|
97 | 105 | raise util.Abort(_('%s hook failed') % hname) |
@@ -101,6 +109,7 b' def _pythonhook(ui, repo, name, hname, f' | |||
|
101 | 109 | def _exthook(ui, repo, name, cmd, args, throw): |
|
102 | 110 | ui.note(_("running hook %s: %s\n") % (name, cmd)) |
|
103 | 111 | |
|
112 | starttime = time.time() | |
|
104 | 113 | env = {} |
|
105 | 114 | for k, v in args.iteritems(): |
|
106 | 115 | if util.safehasattr(v, '__call__'): |
@@ -121,6 +130,10 b' def _exthook(ui, repo, name, cmd, args, ' | |||
|
121 | 130 | r = util.system(cmd, environ=env, cwd=cwd, out=ui) |
|
122 | 131 | else: |
|
123 | 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 | 137 | if r: |
|
125 | 138 | desc, r = util.explainexit(r) |
|
126 | 139 | if throw: |
General Comments 0
You need to be logged in to leave comments.
Login now