##// END OF EJS Templates
hook: for python hooks, also return whether an exception was raised...
Siddharth Agarwal -
r26739:8429369e default
parent child Browse files
Show More
@@ -101,7 +101,7 b' def _pythonhook(ui, repo, name, hname, f'
101 101 if throw:
102 102 raise
103 103 ui.traceback()
104 return True
104 return True, True
105 105 finally:
106 106 sys.stdout, sys.stderr, sys.stdin = old
107 107 duration = time.time() - starttime
@@ -111,7 +111,7 b' def _pythonhook(ui, repo, name, hname, f'
111 111 if throw:
112 112 raise error.HookAbort(_('%s hook failed') % hname)
113 113 ui.warn(_('warning: %s hook failed\n') % hname)
114 return r
114 return r, False
115 115
116 116 def _exthook(ui, repo, name, cmd, args, throw):
117 117 ui.note(_("running hook %s: %s\n") % (name, cmd))
@@ -170,7 +170,7 b' def hook(ui, repo, name, throw=False, **'
170 170 res = runhooks(ui, repo, name, hooks, throw=throw, **args)
171 171 r = False
172 172 for hname, cmd in hooks:
173 r = res[hname] or r
173 r = res[hname][0] or r
174 174 return r
175 175
176 176 def runhooks(ui, repo, name, hooks, throw=False, **args):
@@ -193,7 +193,7 b' def runhooks(ui, repo, name, hooks, thro'
193 193 pass
194 194
195 195 if callable(cmd):
196 r = _pythonhook(ui, repo, name, hname, cmd, args, throw)
196 r, raised = _pythonhook(ui, repo, name, hname, cmd, args, throw)
197 197 elif cmd.startswith('python:'):
198 198 if cmd.count(':') >= 2:
199 199 path, cmd = cmd[7:].rsplit(':', 1)
@@ -208,11 +208,13 b' def runhooks(ui, repo, name, hooks, thro'
208 208 hookfn = getattr(mod, cmd)
209 209 else:
210 210 hookfn = cmd[7:].strip()
211 r = _pythonhook(ui, repo, name, hname, hookfn, args, throw)
211 r, raised = _pythonhook(ui, repo, name, hname, hookfn, args,
212 throw)
212 213 else:
213 214 r = _exthook(ui, repo, hname, cmd, args, throw)
215 raised = False
214 216
215 res[hname] = r
217 res[hname] = r, raised
216 218
217 219 # The stderr is fully buffered on Windows when connected to a pipe.
218 220 # A forcible flush is required to make small stderr data in the
General Comments 0
You need to be logged in to leave comments. Login now