Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hook.py @ 6266:9f76df0edb7d
hook.py: fix redirections introduced by 323b9c55b328
The only non-obvious part is the use of sys.{__stderr__,__stdout__},
which is needed because sshserver overrides sys.stdout.
This makes a test that I added back in revision 7939c71f3132 ineffective.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Fri, 14 Mar 2008 21:57:46 -0300 |
parents | 2c565b9598b8 |
children | f67d1468ac50 |
line wrap: on
line diff
--- a/mercurial/hook.py Mon Feb 25 09:55:57 2008 -0500 +++ b/mercurial/hook.py Fri Mar 14 21:57:46 2008 -0300 @@ -85,6 +85,7 @@ _redirect = False def redirect(state): + global _redirect _redirect = state def hook(ui, repo, name, throw=False, **args): @@ -92,8 +93,8 @@ if _redirect: # temporarily redirect stdout to stderr - oldstdout = os.dup(sys.stdout.fileno()) - os.dup2(sys.stderr.fileno(), sys.stdout.fileno()) + oldstdout = os.dup(sys.__stdout__.fileno()) + os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno()) hooks = [(hname, cmd) for hname, cmd in ui.configitems("hooks") if hname.split(".", 1)[0] == name and cmd] @@ -106,8 +107,9 @@ args, throw) or r else: r = _exthook(ui, repo, hname, cmd, args, throw) or r - return r if _redirect: - os.dup2(oldstdout, sys.stdout.fileno()) + os.dup2(oldstdout, sys.__stdout__.fileno()) os.close(oldstdout) + + return r