pager: break pager invocation out of command check loop
authorMatt Mackall <mpm@selenic.com>
Fri, 09 May 2014 12:58:53 -0500
changeset 21277 2bc778e2f9b3
parent 21276 25b7c760235a
child 21278 e1f5f38fd944
pager: break pager invocation out of command check loop
hgext/pager.py
--- a/hgext/pager.py	Thu May 08 11:11:27 2014 -0500
+++ b/hgext/pager.py	Fri May 09 12:58:53 2014 -0500
@@ -116,8 +116,11 @@
 
     def pagecmd(orig, ui, options, cmd, cmdfunc):
         p = ui.config("pager", "pager", os.environ.get("PAGER"))
+        usepager = False
 
-        if p:
+        if not p:
+            pass
+        else:
             attend = ui.configlist('pager', 'attend', attended)
             auto = options['pager'] == 'auto'
             always = util.parsebool(options['pager'])
@@ -129,12 +132,15 @@
                 if (always or auto and
                     (cmd in attend or
                      (cmd not in ignore and not attend))):
-                    ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
-                    ui.setconfig('ui', 'interactive', False, 'pager')
-                    if util.safehasattr(signal, "SIGPIPE"):
-                        signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-                    _runpager(ui, p)
+                    usepager = True
                     break
+
+        if usepager:
+            ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
+            ui.setconfig('ui', 'interactive', False, 'pager')
+            if util.safehasattr(signal, "SIGPIPE"):
+                signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+            _runpager(ui, p)
         return orig(ui, options, cmd, cmdfunc)
 
     extensions.wrapfunction(dispatch, '_runcommand', pagecmd)