##// END OF EJS Templates
hook: flush stdout before restoring stderr redirection...
Yuya Nishihara -
r30364:ad56204f default
parent child Browse files
Show More
@@ -258,6 +258,7 b' def runhooks(ui, repo, name, hooks, thro'
258 sys.stderr.flush()
258 sys.stderr.flush()
259 finally:
259 finally:
260 if _redirect and oldstdout >= 0:
260 if _redirect and oldstdout >= 0:
261 sys.__stdout__.flush() # write hook output to stderr fd
261 os.dup2(oldstdout, stdoutno)
262 os.dup2(oldstdout, stdoutno)
262 os.close(oldstdout)
263 os.close(oldstdout)
263
264
@@ -265,8 +265,17 b' a bad, evil hook that prints to stdout'
265 > sys.stdout.write("KABOOM\n")
265 > sys.stdout.write("KABOOM\n")
266 > EOF
266 > EOF
267
267
268 $ echo '[hooks]' >> ../remote/.hg/hgrc
268 $ cat <<EOF > $TESTTMP/badpyhook.py
269 $ echo "changegroup.stdout = python $TESTTMP/badhook" >> ../remote/.hg/hgrc
269 > import sys
270 > def hook(ui, repo, hooktype, **kwargs):
271 > sys.stdout.write("KABOOM IN PROCESS\n")
272 > EOF
273
274 $ cat <<EOF >> ../remote/.hg/hgrc
275 > [hooks]
276 > changegroup.stdout = python $TESTTMP/badhook
277 > changegroup.pystdout = python:$TESTTMP/badpyhook.py:hook
278 > EOF
270 $ echo r > r
279 $ echo r > r
271 $ hg ci -A -m z r
280 $ hg ci -A -m z r
272
281
@@ -281,6 +290,7 b' push should succeed even though it has a'
281 remote: adding file changes
290 remote: adding file changes
282 remote: added 1 changesets with 1 changes to 1 files
291 remote: added 1 changesets with 1 changes to 1 files
283 remote: KABOOM
292 remote: KABOOM
293 remote: KABOOM IN PROCESS
284 $ hg -R ../remote heads
294 $ hg -R ../remote heads
285 changeset: 5:1383141674ec
295 changeset: 5:1383141674ec
286 tag: tip
296 tag: tip
@@ -447,6 +457,7 b' stderr from remote commands should be pr'
447 remote: adding file changes
457 remote: adding file changes
448 remote: added 1 changesets with 1 changes to 1 files
458 remote: added 1 changesets with 1 changes to 1 files
449 remote: KABOOM
459 remote: KABOOM
460 remote: KABOOM IN PROCESS
450 local stdout
461 local stdout
451
462
452 debug output
463 debug output
General Comments 0
You need to be logged in to leave comments. Login now