##// END OF EJS Templates
hook.runhooks: return a dict of result values...
Siddharth Agarwal -
r26738:9abc2c92 default
parent child Browse files
Show More
@@ -167,10 +167,14 b' def hook(ui, repo, name, throw=False, **'
167 if hname.split('.')[0] == name and cmd:
167 if hname.split('.')[0] == name and cmd:
168 hooks.append((hname, cmd))
168 hooks.append((hname, cmd))
169
169
170 return runhooks(ui, repo, name, hooks, throw=throw, **args)
170 res = runhooks(ui, repo, name, hooks, throw=throw, **args)
171 r = False
172 for hname, cmd in hooks:
173 r = res[hname] or r
174 return r
171
175
172 def runhooks(ui, repo, name, hooks, throw=False, **args):
176 def runhooks(ui, repo, name, hooks, throw=False, **args):
173 r = False
177 res = {}
174 oldstdout = -1
178 oldstdout = -1
175
179
176 try:
180 try:
@@ -189,7 +193,7 b' def runhooks(ui, repo, name, hooks, thro'
189 pass
193 pass
190
194
191 if callable(cmd):
195 if callable(cmd):
192 r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
196 r = _pythonhook(ui, repo, name, hname, cmd, args, throw)
193 elif cmd.startswith('python:'):
197 elif cmd.startswith('python:'):
194 if cmd.count(':') >= 2:
198 if cmd.count(':') >= 2:
195 path, cmd = cmd[7:].rsplit(':', 1)
199 path, cmd = cmd[7:].rsplit(':', 1)
@@ -204,9 +208,11 b' def runhooks(ui, repo, name, hooks, thro'
204 hookfn = getattr(mod, cmd)
208 hookfn = getattr(mod, cmd)
205 else:
209 else:
206 hookfn = cmd[7:].strip()
210 hookfn = cmd[7:].strip()
207 r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r
211 r = _pythonhook(ui, repo, name, hname, hookfn, args, throw)
208 else:
212 else:
209 r = _exthook(ui, repo, hname, cmd, args, throw) or r
213 r = _exthook(ui, repo, hname, cmd, args, throw)
214
215 res[hname] = r
210
216
211 # The stderr is fully buffered on Windows when connected to a pipe.
217 # The stderr is fully buffered on Windows when connected to a pipe.
212 # A forcible flush is required to make small stderr data in the
218 # A forcible flush is required to make small stderr data in the
@@ -217,4 +223,4 b' def runhooks(ui, repo, name, hooks, thro'
217 os.dup2(oldstdout, stdoutno)
223 os.dup2(oldstdout, stdoutno)
218 os.close(oldstdout)
224 os.close(oldstdout)
219
225
220 return r
226 return res
General Comments 0
You need to be logged in to leave comments. Login now