[PATCH 2 of 2] pager: add global --paginate/--no-pager options

Augie Fackler durin42 at gmail.com
Sun Aug 22 09:03:57 CDT 2010


On Aug 21, 2010, at 10:17 PM, Brodie Rao wrote:

> # HG changeset patch
> # User Brodie Rao <brodie at bitheap.org>
> # Date 1282447030 14400
> # Node ID 3dff96bfd886be74c9c1c151a1ca76be0a133fc3
> # Parent  2f351b05d85db8e243156141398217bdf30f01c5
> pager: add global --paginate/--no-pager options
> 
> diff -r 2f351b05d85d -r 3dff96bfd886 hgext/pager.py
> --- a/hgext/pager.py	Sat Aug 21 23:11:35 2010 -0400
> +++ b/hgext/pager.py	Sat Aug 21 23:17:10 2010 -0400
> @@ -47,10 +47,14 @@ If pager.attend is present, pager.ignore
> 
> To ignore global commands like :hg:`version` or :hg:`help`, you have
> to specify them in the global .hgrc
> +
> +The --paginate and --no-pager options can also be used to control
> +when then pager is used.

Would it make sense for both of these flags to instead be a --pager flag which took never,always,auto much like the --color flag for the color extension?


> '''
> 
> import sys, os, signal, shlex, errno
> -from mercurial import dispatch, util, extensions
> +from mercurial import commands, dispatch, util, extensions
> +from mercurial.i18n import _
> 
> def _runpager(p):
>     if not hasattr(os, 'fork'):
> @@ -83,9 +87,10 @@ def uisetup(ui):
> 
>     def pagecmd(orig, ui, options, cmd, cmdfunc):
>         p = ui.config("pager", "pager", os.environ.get("PAGER"))
> -        if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
> +        if (not options['no_pager'] and p and sys.stdout.isatty() and
> +            '--debugger' not in sys.argv):
>             attend = ui.configlist('pager', 'attend', attended)
> -            if (cmd in attend or
> +            if (options['paginate'] or cmd in attend or
>                 (cmd not in ui.configlist('pager', 'ignore') and not attend)):
>                 ui.setconfig('ui', 'formatted', ui.formatted())
>                 ui.setconfig('ui', 'interactive', False)
> @@ -96,4 +101,9 @@ def uisetup(ui):
> 
>     extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
> 
> +commands.globalopts.extend([('', 'paginate', None,
> +                             _('enable paginated output')),
> +                            ('', 'no-pager', None,
> +                             _('disable paginated output'))])
> +
> attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list