Show More
@@ -106,10 +106,14 b' def redirect(state):' | |||||
106 | def hook(ui, repo, name, throw=False, **args): |
|
106 | def hook(ui, repo, name, throw=False, **args): | |
107 | r = False |
|
107 | r = False | |
108 |
|
108 | |||
|
109 | oldstdout = -1 | |||
109 | if _redirect: |
|
110 | if _redirect: | |
110 | # temporarily redirect stdout to stderr |
|
111 | stdoutno = sys.__stdout__.fileno() | |
111 |
|
|
112 | stderrno = sys.__stderr__.fileno() | |
112 | os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno()) |
|
113 | # temporarily redirect stdout to stderr, if possible | |
|
114 | if stdoutno >= 0 and stderrno >= 0: | |||
|
115 | oldstdout = os.dup(stdoutno) | |||
|
116 | os.dup2(stderrno, stdoutno) | |||
113 |
|
117 | |||
114 | try: |
|
118 | try: | |
115 | for hname, cmd in ui.configitems('hooks'): |
|
119 | for hname, cmd in ui.configitems('hooks'): | |
@@ -128,8 +132,8 b' def hook(ui, repo, name, throw=False, **' | |||||
128 | else: |
|
132 | else: | |
129 | r = _exthook(ui, repo, hname, cmd, args, throw) or r |
|
133 | r = _exthook(ui, repo, hname, cmd, args, throw) or r | |
130 | finally: |
|
134 | finally: | |
131 | if _redirect: |
|
135 | if _redirect and oldstdout >= 0: | |
132 |
os.dup2(oldstdout, |
|
136 | os.dup2(oldstdout, stdoutno) | |
133 | os.close(oldstdout) |
|
137 | os.close(oldstdout) | |
134 |
|
138 | |||
135 | return r |
|
139 | return r |
General Comments 0
You need to be logged in to leave comments.
Login now