Mercurial > public > mercurial-scm > hg
comparison mercurial/hook.py @ 14999:f6a737357195
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 01 Aug 2011 10:54:34 -0500 |
parents | d3bb825ddae3 e5b2ee5157ae |
children | 8b011ededfb2 |
comparison
equal
deleted
inserted
replaced
14995:8d928799dab5 | 14999:f6a737357195 |
---|---|
132 def hook(ui, repo, name, throw=False, **args): | 132 def hook(ui, repo, name, throw=False, **args): |
133 r = False | 133 r = False |
134 | 134 |
135 oldstdout = -1 | 135 oldstdout = -1 |
136 if _redirect: | 136 if _redirect: |
137 stdoutno = sys.__stdout__.fileno() | 137 try: |
138 stderrno = sys.__stderr__.fileno() | 138 stdoutno = sys.__stdout__.fileno() |
139 # temporarily redirect stdout to stderr, if possible | 139 stderrno = sys.__stderr__.fileno() |
140 if stdoutno >= 0 and stderrno >= 0: | 140 # temporarily redirect stdout to stderr, if possible |
141 oldstdout = os.dup(stdoutno) | 141 if stdoutno >= 0 and stderrno >= 0: |
142 os.dup2(stderrno, stdoutno) | 142 oldstdout = os.dup(stdoutno) |
143 os.dup2(stderrno, stdoutno) | |
144 except AttributeError: | |
145 # __stdout/err__ doesn't have fileno(), it's not a real file | |
146 pass | |
143 | 147 |
144 try: | 148 try: |
145 for hname, cmd in ui.configitems('hooks'): | 149 for hname, cmd in ui.configitems('hooks'): |
146 if hname.split('.')[0] != name or not cmd: | 150 if hname.split('.')[0] != name or not cmd: |
147 continue | 151 continue |