equal
deleted
inserted
replaced
5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
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, time |
9 import os, sys, time |
10 import extensions, util, demandimport |
10 import extensions, util, demandimport, error |
11 |
11 |
12 def _pythonhook(ui, repo, name, hname, funcname, args, throw): |
12 def _pythonhook(ui, repo, name, hname, funcname, args, throw): |
13 '''call python hook. hook is callable object, looked up as |
13 '''call python hook. hook is callable object, looked up as |
14 name in python module. if callable returns "true", hook |
14 name in python module. if callable returns "true", hook |
15 fails, else passes. if hook raises exception, treated as |
15 fails, else passes. if hook raises exception, treated as |
105 duration = time.time() - starttime |
105 duration = time.time() - starttime |
106 ui.log('pythonhook', 'pythonhook-%s: %s finished in %0.2f seconds\n', |
106 ui.log('pythonhook', 'pythonhook-%s: %s finished in %0.2f seconds\n', |
107 name, funcname, duration) |
107 name, funcname, duration) |
108 if r: |
108 if r: |
109 if throw: |
109 if throw: |
110 raise util.Abort(_('%s hook failed') % hname) |
110 raise error.HookAbort(_('%s hook failed') % hname) |
111 ui.warn(_('warning: %s hook failed\n') % hname) |
111 ui.warn(_('warning: %s hook failed\n') % hname) |
112 return r |
112 return r |
113 |
113 |
114 def _exthook(ui, repo, name, cmd, args, throw): |
114 def _exthook(ui, repo, name, cmd, args, throw): |
115 ui.note(_("running hook %s: %s\n") % (name, cmd)) |
115 ui.note(_("running hook %s: %s\n") % (name, cmd)) |
137 ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n', |
137 ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n', |
138 name, cmd, duration) |
138 name, cmd, duration) |
139 if r: |
139 if r: |
140 desc, r = util.explainexit(r) |
140 desc, r = util.explainexit(r) |
141 if throw: |
141 if throw: |
142 raise util.Abort(_('%s hook %s') % (name, desc)) |
142 raise error.HookAbort(_('%s hook %s') % (name, desc)) |
143 ui.warn(_('warning: %s hook %s\n') % (name, desc)) |
143 ui.warn(_('warning: %s hook %s\n') % (name, desc)) |
144 return r |
144 return r |
145 |
145 |
146 def _allhooks(ui): |
146 def _allhooks(ui): |
147 hooks = [] |
147 hooks = [] |