comparison 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
comparison
equal deleted inserted replaced
6456:db5324d3c257 6457:7ef281e78c64
22 # If you notice "BROKEN PIPE" error messages, you can disable them 22 # If you notice "BROKEN PIPE" error messages, you can disable them
23 # by setting: 23 # by setting:
24 # 24 #
25 # [pager] 25 # [pager]
26 # quiet = True 26 # quiet = True
27 #
28 # You can disable the pager for certain commands by adding them to the
29 # pager.ignore list:
30 #
31 # [pager]
32 # ignore = version, help, update
33 #
34 # You can also enable the pager only for certain commands using pager.attend:
35 #
36 # [pager]
37 # attend = log
38 #
39 # If pager.attend is present, pager.ignore will be ignored.
40 #
41 # To ignore global commands like 'hg version' or 'hg help', you have to specify them
42 # in the global .hgrc
27 43
28 import sys, os, signal 44 import sys, os, signal
45 from mercurial import dispatch
29 46
30 def uisetup(ui): 47 def uisetup(ui):
31 p = ui.config("pager", "pager", os.environ.get("PAGER")) 48 def pagecmd(ui, options, cmd, cmdfunc):
32 if p and sys.stdout.isatty() and '--debugger' not in sys.argv: 49 p = ui.config("pager", "pager", os.environ.get("PAGER"))
33 if ui.configbool('pager', 'quiet'): 50 if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
34 signal.signal(signal.SIGPIPE, signal.SIG_DFL) 51 attend = ui.configlist('pager', 'attend')
35 sys.stderr = sys.stdout = os.popen(p, "wb") 52 if (cmd in attend or
53 (cmd not in ui.configlist('pager', 'ignore') and not attend)):
54 sys.stderr = sys.stdout = os.popen(p, "wb")
55 if ui.configbool('pager', 'quiet'):
56 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
57 return oldrun(ui, options, cmd, cmdfunc)
58
59 oldrun = dispatch._runcommand
60 dispatch._runcommand = pagecmd