mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
62ba7447f6
Summary: The Rust IO handles progress and streampager stuff. Switch to it so we don't need to changing the `fout`, `ferr` when handling streampager in Python. The chgserver logic is updated to just set raw fd 0, 1, 2 to update stdio, since `fileno` is no longer exposed from Rust. Manually tested the following commands, both without chg and with chg: - lhg log -r . (no pager) - lhg log (with streampager) - lhg log --config pager.pager=less (with less pager) - lhg commit (spawns pager) - lhg debugprogress -s 100 --sleep 100 --with-output --pager=off (progress in stderr) - lhg debugprogress -s 100 --sleep 100 --with-output --pager=on --config pager.interface=fullscreen (progress in streampager) - lhg debugprogress -s 100 --sleep 100 --with-output --pager=on --config pager.pager='LESS= less' (progress is disabled with external pager) Reviewed By: sfilipco Differential Revision: D26612487 fbshipit-source-id: 8b4e36b614a0c080b93e41474f9a8fc33f890083
50 lines
1.5 KiB
Perl
50 lines
1.5 KiB
Perl
$ cat > a.py << EOF
|
|
> import os
|
|
> def uisetup(ui):
|
|
> # make the test slightly more interesting
|
|
> @ui.atexit
|
|
> def printlines():
|
|
> ui.write("line1\n")
|
|
> ui.write("line2\n" * 10000) # probably triggers EPIPE or SIGPIPE
|
|
> open("executed-here1", "w").close()
|
|
> EOF
|
|
|
|
This should not trigger StdioError (IOError), or BrokenPipeError (OSError):
|
|
|
|
$ hg --config extensions.a=a.py init foo1 | head -1
|
|
line1
|
|
|
|
'executed-here1' should exist to indicate the execution flow:
|
|
|
|
$ [ -f executed-here1 ]
|
|
|
|
Try again, using a pager:
|
|
|
|
$ cat > b.py << EOF
|
|
> import os
|
|
> def uisetup(ui):
|
|
> @ui.atexit
|
|
> def printlines():
|
|
> # This is hacky. But it makes sure pager is running.
|
|
> # Using --pager=always is not enough, because killpager is also
|
|
> # an atexit handler and gets executed before this one.
|
|
> ui.pager("internal-always-atexit")
|
|
> # Redo signal.signal(signal.SIGPIPE, signal.SIG_IGN) called by
|
|
> # _runexithandlers.
|
|
> import signal
|
|
> signal.signal(signal.SIGPIPE, signal.SIG_IGN)
|
|
> ui.write("line1\n")
|
|
> ui.write("line2\n" * 10000) # probably triggers EPIPE or SIGPIPE
|
|
> open("executed-here2", "w").close()
|
|
> EOF
|
|
|
|
This should not raise SignalInterrupt (KeyboardInterrupt):
|
|
|
|
$ hg --config extensions.b=b.py --config 'pager.pager=head -1' init foo2
|
|
line1
|
|
|
|
'executed-here2' should exist to indicate the execution flow:
|
|
|
|
$ [ -f executed-here2 ]
|
|
|