Mercurial > hg-stable
changeset 26738:9abc2c921bbd
hook.runhooks: return a dict of result values
This will be useful to other calling code that would be interested in what the
individual hooks return.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 14 Oct 2015 16:19:47 -0700 |
parents | a930d66a04af |
children | 8429369eeb85 |
files | mercurial/hook.py |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hook.py Wed Oct 14 16:13:31 2015 -0700 +++ b/mercurial/hook.py Wed Oct 14 16:19:47 2015 -0700 @@ -167,10 +167,14 @@ if hname.split('.')[0] == name and cmd: hooks.append((hname, cmd)) - return runhooks(ui, repo, name, hooks, throw=throw, **args) + res = runhooks(ui, repo, name, hooks, throw=throw, **args) + r = False + for hname, cmd in hooks: + r = res[hname] or r + return r def runhooks(ui, repo, name, hooks, throw=False, **args): - r = False + res = {} oldstdout = -1 try: @@ -189,7 +193,7 @@ pass if callable(cmd): - r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r + r = _pythonhook(ui, repo, name, hname, cmd, args, throw) elif cmd.startswith('python:'): if cmd.count(':') >= 2: path, cmd = cmd[7:].rsplit(':', 1) @@ -204,9 +208,11 @@ hookfn = getattr(mod, cmd) else: hookfn = cmd[7:].strip() - r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r + r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) else: - r = _exthook(ui, repo, hname, cmd, args, throw) or r + r = _exthook(ui, repo, hname, cmd, args, throw) + + res[hname] = r # The stderr is fully buffered on Windows when connected to a pipe. # A forcible flush is required to make small stderr data in the @@ -217,4 +223,4 @@ os.dup2(oldstdout, stdoutno) os.close(oldstdout) - return r + return res