Mercurial > public > mercurial-scm > hg
diff hgext/pager.py @ 6457:7ef281e78c64
Merge from crew-stable.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 03 Apr 2008 11:16:07 +0200 |
parents | db5324d3c257 13fafd8cc4a1 |
children | 6c4e12682fb9 |
line wrap: on
line diff
--- a/hgext/pager.py Thu Apr 03 11:11:31 2008 +0200 +++ b/hgext/pager.py Thu Apr 03 11:16:07 2008 +0200 @@ -24,12 +24,37 @@ # # [pager] # quiet = True +# +# You can disable the pager for certain commands by adding them to the +# pager.ignore list: +# +# [pager] +# ignore = version, help, update +# +# You can also enable the pager only for certain commands using pager.attend: +# +# [pager] +# attend = log +# +# If pager.attend is present, pager.ignore will be ignored. +# +# To ignore global commands like 'hg version' or 'hg help', you have to specify them +# in the global .hgrc import sys, os, signal +from mercurial import dispatch def uisetup(ui): - p = ui.config("pager", "pager", os.environ.get("PAGER")) - if p and sys.stdout.isatty() and '--debugger' not in sys.argv: - if ui.configbool('pager', 'quiet'): - signal.signal(signal.SIGPIPE, signal.SIG_DFL) - sys.stderr = sys.stdout = os.popen(p, "wb") + def pagecmd(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: + attend = ui.configlist('pager', 'attend') + if (cmd in attend or + (cmd not in ui.configlist('pager', 'ignore') and not attend)): + sys.stderr = sys.stdout = os.popen(p, "wb") + if ui.configbool('pager', 'quiet'): + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + return oldrun(ui, options, cmd, cmdfunc) + + oldrun = dispatch._runcommand + dispatch._runcommand = pagecmd