[PATCH 2 of 3 resend v2] pager: add global --pager=<auto/boolean> option
Brodie Rao
brodie at bitheap.org
Sun Oct 10 17:24:15 UTC 2010
# HG changeset patch
# User Brodie Rao <brodie at bitheap.org>
# Date 1286731308 18000
# Node ID 423aeec2d2dbcf7a11cace795674834d003c6a3c
# Parent a27be73fcd7857c45f60887653b517bd83dd5738
pager: add global --pager=<auto/boolean> option
diff --git a/hgext/pager.py b/hgext/pager.py
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -47,10 +47,15 @@ If pager.attend is present, pager.ignore
To ignore global commands like :hg:`version` or :hg:`help`, you have
to specify them in your user configuration file.
+
+The --pager=... option can also be used to control when the pager is
+used. Use a boolean value like yes, no, on, off, or use auto for
+normal behavior.
'''
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'):
@@ -85,8 +90,11 @@ def uisetup(ui):
p = ui.config("pager", "pager", os.environ.get("PAGER"))
if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
attend = ui.configlist('pager', 'attend', attended)
- if (cmd in attend or
- (cmd not in ui.configlist('pager', 'ignore') and not attend)):
+ auto = options['pager'] == 'auto'
+ always = util.parsebool(options['pager'])
+ if (always or auto and
+ (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)
_runpager(p)
@@ -96,4 +104,10 @@ def uisetup(ui):
extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
+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']
More information about the Mercurial-devel
mailing list