hgext/pager.py
changeset 6548 962eb403165b
parent 6462 6c4e12682fb9
child 7216 292fb2ad2846
equal deleted inserted replaced
6533:65f1b97484be 6548:962eb403165b
    45 To ignore global commands like "hg version" or "hg help", you have to specify
    45 To ignore global commands like "hg version" or "hg help", you have to specify
    46 them in the global .hgrc
    46 them in the global .hgrc
    47 '''
    47 '''
    48 
    48 
    49 import sys, os, signal
    49 import sys, os, signal
    50 from mercurial import dispatch
    50 from mercurial import dispatch, util
    51 
    51 
    52 def uisetup(ui):
    52 def uisetup(ui):
    53     def pagecmd(ui, options, cmd, cmdfunc):
    53     def pagecmd(ui, options, cmd, cmdfunc):
    54         p = ui.config("pager", "pager", os.environ.get("PAGER"))
    54         p = ui.config("pager", "pager", os.environ.get("PAGER"))
    55         if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
    55         if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
    56             attend = ui.configlist('pager', 'attend')
    56             attend = ui.configlist('pager', 'attend')
    57             if (cmd in attend or
    57             if (cmd in attend or
    58                 (cmd not in ui.configlist('pager', 'ignore') and not attend)):
    58                 (cmd not in ui.configlist('pager', 'ignore') and not attend)):
    59                 sys.stderr = sys.stdout = os.popen(p, "wb")
    59                 sys.stderr = sys.stdout = util.popen(p, "wb")
    60                 if ui.configbool('pager', 'quiet'):
    60                 if ui.configbool('pager', 'quiet'):
    61                     signal.signal(signal.SIGPIPE, signal.SIG_DFL)
    61                     signal.signal(signal.SIGPIPE, signal.SIG_DFL)
    62         return oldrun(ui, options, cmd, cmdfunc)
    62         return oldrun(ui, options, cmd, cmdfunc)
    63 
    63 
    64     oldrun = dispatch._runcommand
    64     oldrun = dispatch._runcommand