Moving Pager to Core
Note:
This page is primarily intended for developers of Mercurial.
Pager is currently a hacky extension, and breaks some things in odd ways. Given a concerted refactor, it could be much less fragile by moving it into core hg.
Contents
1. Current Problems
- Pager only applies to a handful of whitelisted commands, and aliases using those commands don't get paged
- Pager breaks interactivity of commands
- Sometimes surprising things get paged.
We don't know what the default pager configuration be?
Probably less, and probably set LESS=FSRX if LESS isn't already set?
2. Proposal
It looks like git just hard-codes which commands use the pager. We could probably do something similar by having a paged context manager on ui, eg:
with ui.paged: # all ui prints here go to the pager
or we could have a function to page the output, since I [augie] think that starting the pager isn't reversible:
ui.pager() # all subsequent output goes to the pager
That'd solve the problem of [alias] entries not getting paged, and would avoid multi-mode commands (eg shelve) from always being paged. We could also have ui.interactive() produce a developer warning ('tried to use ui.interactive() after enabling the pager') to prevent interactive-with-pager-running problems.
3. Handling errors
If you use --traceback, currently the error is paged. This doesn't seem ideal, but there doesn't appear to be a good solution other than always emitting the error on stderr and terminating output to the pager as soon as an error occurs.