comparison hgext/pager.py @ 21277:2bc778e2f9b3

pager: break pager invocation out of command check loop
author Matt Mackall <mpm@selenic.com>
date Fri, 09 May 2014 12:58:53 -0500
parents 49f2d5644f04
children e1f5f38fd944
comparison
equal deleted inserted replaced
21276:25b7c760235a 21277:2bc778e2f9b3
114 if '--debugger' in sys.argv or not ui.formatted(): 114 if '--debugger' in sys.argv or not ui.formatted():
115 return 115 return
116 116
117 def pagecmd(orig, ui, options, cmd, cmdfunc): 117 def pagecmd(orig, ui, options, cmd, cmdfunc):
118 p = ui.config("pager", "pager", os.environ.get("PAGER")) 118 p = ui.config("pager", "pager", os.environ.get("PAGER"))
119 usepager = False
119 120
120 if p: 121 if not p:
122 pass
123 else:
121 attend = ui.configlist('pager', 'attend', attended) 124 attend = ui.configlist('pager', 'attend', attended)
122 auto = options['pager'] == 'auto' 125 auto = options['pager'] == 'auto'
123 always = util.parsebool(options['pager']) 126 always = util.parsebool(options['pager'])
124 127
125 cmds, _ = cmdutil.findcmd(cmd, commands.table) 128 cmds, _ = cmdutil.findcmd(cmd, commands.table)
127 ignore = ui.configlist('pager', 'ignore') 130 ignore = ui.configlist('pager', 'ignore')
128 for cmd in cmds: 131 for cmd in cmds:
129 if (always or auto and 132 if (always or auto and
130 (cmd in attend or 133 (cmd in attend or
131 (cmd not in ignore and not attend))): 134 (cmd not in ignore and not attend))):
132 ui.setconfig('ui', 'formatted', ui.formatted(), 'pager') 135 usepager = True
133 ui.setconfig('ui', 'interactive', False, 'pager')
134 if util.safehasattr(signal, "SIGPIPE"):
135 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
136 _runpager(ui, p)
137 break 136 break
137
138 if usepager:
139 ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
140 ui.setconfig('ui', 'interactive', False, 'pager')
141 if util.safehasattr(signal, "SIGPIPE"):
142 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
143 _runpager(ui, p)
138 return orig(ui, options, cmd, cmdfunc) 144 return orig(ui, options, cmd, cmdfunc)
139 145
140 extensions.wrapfunction(dispatch, '_runcommand', pagecmd) 146 extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
141 147
142 def extsetup(ui): 148 def extsetup(ui):