[PATCH 7 of 8 STABLE] pager: unify handling of 'ui.pager' and '--pager'
Sean Farley
sean at farley.io
Mon May 1 14:32:10 EDT 2017
Pierre-Yves David <pierre-yves.david at ens-lyon.org> writes:
> On 05/01/2017 07:33 PM, Martin von Zweigbergk wrote:
>> On Mon, May 1, 2017 at 9:12 AM, Pierre-Yves David
>> <pierre-yves.david at ens-lyon.org> wrote:
>>> # HG changeset patch
>>> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
>>> # Date 1493651095 -7200
>>> # Mon May 01 17:04:55 2017 +0200
>>> # Branch stable
>>> # Node ID 2605f6e2ed168e6915fba6df575d80b962418ec6
>>> # Parent bdd42fa505b60739fa337e683a0f64b8dc1c4707
>>> # EXP-Topic pager
>>> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>>> # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 2605f6e2ed16
>>> pager: unify handling of 'ui.pager' and '--pager'
>>>
>>> This is similar to what we do with 'ui.color' and '--color'. Both now takes the
>>> same possible values. The config option act as a default for the global command
>>> line flag.
>>>
>>> In practice, this means 'ui.color' can now accept 'auto' as a value.
>>>
>>> diff --git a/hgext/pager.py b/hgext/pager.py
>>> --- a/hgext/pager.py
>>> +++ b/hgext/pager.py
>>> @@ -39,7 +39,10 @@ testedwith = 'ships-with-hg-core'
>>> def uisetup(ui):
>>>
>>> def pagecmd(orig, ui, options, cmd, cmdfunc):
>>> - auto = options['pager'] == 'auto'
>>> + pageropt = options.get('pager')
>>> + if not pageropt:
>>> + pageropt = ui.config('ui', 'pager', 'auto')
>>> + auto = pageropt == 'auto'
>>> if auto and not ui.pageractive:
>>> usepager = False
>>> attend = ui.configlist('pager', 'attend', attended)
>>> diff --git a/mercurial/commands.py b/mercurial/commands.py
>>> --- a/mercurial/commands.py
>>> +++ b/mercurial/commands.py
>>> @@ -99,7 +99,7 @@ globalopts = [
>>> ('', 'version', None, _('output version information and exit')),
>>> ('h', 'help', None, _('display help and exit')),
>>> ('', 'hidden', False, _('consider hidden changesets')),
>>> - ('', 'pager', 'auto',
>>> + ('', 'pager', '',
>>> _("when to paginate (boolean, always, auto, or never)"), _('TYPE')),
>>> ]
>>>
>>> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
>>> --- a/mercurial/dispatch.py
>>> +++ b/mercurial/dispatch.py
>>> @@ -833,9 +833,13 @@ def _dispatch(req):
>>> for ui_ in uis:
>>> ui_.setconfig('ui', 'interactive', 'off', '-y')
>>>
>>> - if util.parsebool(options['pager']):
>>> + pageropt = options.get('pager')
>>> + if not pageropt:
>>> + pageropt = ui.config('ui', 'pager', 'auto')
>>> +
>>> + if util.parsebool(pageropt):
>>> ui.pager('internal-always-' + cmd)
>>> - elif options['pager'] != 'auto':
>>> + elif pageropt != 'auto':
>>> ui.disablepager()
>>>
>>> if cmdoptions.get('insecure', False):
>>> diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
>>> --- a/mercurial/help/config.txt
>>> +++ b/mercurial/help/config.txt
>>> @@ -1963,8 +1963,8 @@ User interface controls.
>>> not a directory, one will be created.
>>>
>>> ``pager``
>>> - Control the pagination of command output (default: True). See :hg:`help pager`
>>> - for details.
>>> + Control the pagination of command output. Possible values are: on, auto, off
>>> + (defaul: auto). See :hg:`help pager` for details.
>>
>> The possible values for --pager was documented as "boolean, always,
>> auto, or never". Same for --color (except that it also allows
>> "debug"). ui.color is documented to support "auto, always, never, or
>> debug". Seems like we should pick one way of describing it. I vote for
>> copying the texts from the --pager/color descriptions.
>
> Good catch, +1 for always/never. I automatically used 'never' in patch 8
> without realizing.
I also agree with Martin. For what it's worth, I'd like these to make it
to the release for the user benefit (I just helped someone set up a new
Mercurial install and noticed some of these same rough spots).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170501/a8e5f092/attachment.sig>
More information about the Mercurial-devel
mailing list