Mercurial > hg-stable
changeset 31013:9c2977ceaa46
pager: move more behavior into core
This moves the global flag and the --pager=yes logic into core. Only
functionality change is that users now always get a --pager flag and
can enable the pager via the flag without the extension active.
Moving the flag into core exposes a defect in the ro localization,
which will have to be corrected later.
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 15 Feb 2017 17:47:57 -0500 |
parents | 61b4122019d3 |
children | 3ed6e43998df |
files | hgext/pager.py mercurial/commands.py mercurial/dispatch.py tests/test-completion.t tests/test-extension.t tests/test-gendoc-ro.t tests/test-help.t |
diffstat | 7 files changed, 36 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/pager.py Wed Feb 15 17:47:51 2017 -0500 +++ b/hgext/pager.py Wed Feb 15 17:47:57 2017 -0500 @@ -60,13 +60,11 @@ ''' from __future__ import absolute_import -from mercurial.i18n import _ from mercurial import ( cmdutil, commands, dispatch, extensions, - util, ) # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for @@ -78,15 +76,9 @@ def uisetup(ui): def pagecmd(orig, ui, options, cmd, cmdfunc): - usepager = False - always = util.parsebool(options['pager']) auto = options['pager'] == 'auto' - - if always: - usepager = True - elif not auto: + if auto and not ui.pageractive: usepager = False - else: attend = ui.configlist('pager', 'attend', attended) ignore = ui.configlist('pager', 'ignore') cmds, _ = cmdutil.findcmd(cmd, commands.table) @@ -101,8 +93,8 @@ usepager = True break - if usepager: - ui.pager('extension-via-attend-' + cmd) + if usepager: + ui.pager('extension-via-attend-' + cmd) return orig(ui, options, cmd, cmdfunc) # Wrap dispatch._runcommand after color is loaded so color can see @@ -112,10 +104,4 @@ extensions.wrapfunction(dispatch, '_runcommand', pagecmd) extensions.afterloaded('color', afterloaded) -def extsetup(ui): - commands.globalopts.append( - ('', 'pager', 'auto', - _("when to paginate (boolean, always, auto, or never)"), - _('TYPE'))) - attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']
--- a/mercurial/commands.py Wed Feb 15 17:47:51 2017 -0500 +++ b/mercurial/commands.py Wed Feb 15 17:47:57 2017 -0500 @@ -93,6 +93,8 @@ ('', 'version', None, _('output version information and exit')), ('h', 'help', None, _('display help and exit')), ('', 'hidden', False, _('consider hidden changesets')), + ('', 'pager', 'auto', + _("when to paginate (boolean, always, auto, or never)"), _('TYPE')), ] dryrunopts = [('n', 'dry-run', None,
--- a/mercurial/dispatch.py Wed Feb 15 17:47:51 2017 -0500 +++ b/mercurial/dispatch.py Wed Feb 15 17:47:57 2017 -0500 @@ -819,6 +819,8 @@ def _runcommand(ui, options, cmd, cmdfunc): """Run a command function, possibly with profiling enabled.""" + if util.parsebool(options['pager']): + ui.pager('internal-always-' + cmd) try: return cmdfunc() except error.SignatureError:
--- a/tests/test-completion.t Wed Feb 15 17:47:51 2017 -0500 +++ b/tests/test-completion.t Wed Feb 15 17:47:57 2017 -0500 @@ -138,6 +138,7 @@ --help --hidden --noninteractive + --pager --profile --quiet --repository @@ -171,6 +172,7 @@ --ipv6 --name --noninteractive + --pager --pid-file --port --prefix
--- a/tests/test-extension.t Wed Feb 15 17:47:51 2017 -0500 +++ b/tests/test-extension.t Wed Feb 15 17:47:57 2017 -0500 @@ -543,6 +543,8 @@ --version output version information and exit -h --help display help and exit --hidden consider hidden changesets + --pager TYPE when to paginate (boolean, always, auto, or never) + (default: auto) @@ -578,6 +580,8 @@ --version output version information and exit -h --help display help and exit --hidden consider hidden changesets + --pager TYPE when to paginate (boolean, always, auto, or never) + (default: auto) @@ -856,6 +860,8 @@ --version output version information and exit -h --help display help and exit --hidden consider hidden changesets + --pager TYPE when to paginate (boolean, always, auto, or never) + (default: auto) Make sure that single '-v' option shows help and built-ins only for 'dodo' command $ hg help -v dodo @@ -889,6 +895,8 @@ --version output version information and exit -h --help display help and exit --hidden consider hidden changesets + --pager TYPE when to paginate (boolean, always, auto, or never) + (default: auto) In case when extension name doesn't match any of its commands, help message should ask for '-v' to get list of built-in aliases @@ -960,6 +968,8 @@ --version output version information and exit -h --help display help and exit --hidden consider hidden changesets + --pager TYPE when to paginate (boolean, always, auto, or never) + (default: auto) $ hg help -v -e dudu dudu extension - @@ -992,6 +1002,8 @@ --version output version information and exit -h --help display help and exit --hidden consider hidden changesets + --pager TYPE when to paginate (boolean, always, auto, or never) + (default: auto) Disabled extension commands:
--- a/tests/test-gendoc-ro.t Wed Feb 15 17:47:51 2017 -0500 +++ b/tests/test-gendoc-ro.t Wed Feb 15 17:47:57 2017 -0500 @@ -1,4 +1,9 @@ #require docutils gettext +Error: the current ro localization has some rst defects exposed by +moving pager to core. These two warnings about references are expected +until the localization is corrected. $ $TESTDIR/check-gendoc ro checking for parse errors + gendoc.txt:55: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string. + gendoc.txt:55: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.
--- a/tests/test-help.t Wed Feb 15 17:47:51 2017 -0500 +++ b/tests/test-help.t Wed Feb 15 17:47:57 2017 -0500 @@ -326,6 +326,8 @@ --version output version information and exit -h --help display help and exit --hidden consider hidden changesets + --pager TYPE when to paginate (boolean, always, auto, or never) + (default: auto) (use 'hg help' for the full list of commands) @@ -422,6 +424,8 @@ --version output version information and exit -h --help display help and exit --hidden consider hidden changesets + --pager TYPE when to paginate (boolean, always, auto, or never) + (default: auto) Test the textwidth config option @@ -2523,6 +2527,9 @@ <tr><td></td> <td>--hidden</td> <td>consider hidden changesets</td></tr> + <tr><td></td> + <td>--pager TYPE</td> + <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr> </table> </div> @@ -2718,6 +2725,9 @@ <tr><td></td> <td>--hidden</td> <td>consider hidden changesets</td></tr> + <tr><td></td> + <td>--pager TYPE</td> + <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr> </table> </div>