Mercurial > hg-stable
comparison tests/test-ssh.t @ 30374:ad56204f733e
hook: flush stdout before restoring stderr redirection
There was a similar issue to 8b011ededfb2. If an in-process hook writes
to stdout, the data may be buffered. In which case, stdout must be flushed
before restoring its file descriptor. Otherwise, remaining data would be sent
over the ssh wire and corrupts the protocol.
Note that this is a different redirection from the one I've just removed.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 08 Nov 2016 22:22:22 +0900 |
parents | 34a5f6c66bc5 |
children | e118233172fe |
comparison
equal
deleted
inserted
replaced
30373:a1259e502bdf | 30374:ad56204f733e |
---|---|
263 $ cat <<EOF > $TESTTMP/badhook | 263 $ cat <<EOF > $TESTTMP/badhook |
264 > import sys | 264 > import sys |
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 |
273 push should succeed even though it has an unexpected response | 282 push should succeed even though it has an unexpected response |
274 | 283 |
279 remote: adding changesets | 288 remote: adding changesets |
280 remote: adding manifests | 289 remote: adding manifests |
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 |
287 parent: 3:a28a9d1a809c | 297 parent: 3:a28a9d1a809c |
288 user: test | 298 user: test |
445 remote: adding changesets | 455 remote: adding changesets |
446 remote: adding manifests | 456 remote: adding manifests |
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 |
453 | 464 |
454 $ hg pull --debug ssh://user@dummy/remote | 465 $ hg pull --debug ssh://user@dummy/remote |