ui: introduce neverpager() call
authorAugie Fackler <augie@google.com>
Wed, 15 Feb 2017 17:48:03 -0500
changeset 30994 3ed6e43998df
parent 30993 9c2977ceaa46
child 30995 5e85bab867a7
ui: introduce neverpager() call I'm about to add direct paging support to some commands, and as a result we need a way to communicate from the higher layers of dispatch that paging is explicitly disabled.
mercurial/dispatch.py
mercurial/ui.py
--- a/mercurial/dispatch.py	Wed Feb 15 17:47:57 2017 -0500
+++ b/mercurial/dispatch.py	Wed Feb 15 17:48:03 2017 -0500
@@ -749,6 +749,9 @@
             for ui_ in uis:
                 ui_.setconfig('ui', 'interactive', 'off', '-y')
 
+        if options['pager'] != 'auto' and not util.parsebool(options['pager']):
+            ui.neverpager()
+
         if cmdoptions.get('insecure', False):
             for ui_ in uis:
                 ui_.insecureconnections = True
--- a/mercurial/ui.py	Wed Feb 15 17:47:57 2017 -0500
+++ b/mercurial/ui.py	Wed Feb 15 17:48:03 2017 -0500
@@ -155,6 +155,7 @@
             self.ferr = src.ferr
             self.fin = src.fin
             self.pageractive = src.pageractive
+            self._neverpager = src._neverpager
 
             self._tcfg = src._tcfg.copy()
             self._ucfg = src._ucfg.copy()
@@ -173,6 +174,7 @@
             self.ferr = util.stderr
             self.fin = util.stdin
             self.pageractive = False
+            self._neverpager = False
 
             # shared read-only environment
             self.environ = encoding.environ
@@ -831,6 +833,9 @@
             return False
         return util.isatty(fh)
 
+    def neverpager(self):
+        self._neverpager = True
+
     def pager(self, command):
         """Start a pager for subsequent command output.
 
@@ -844,7 +849,8 @@
           command: The full, non-aliased name of the command. That is, "log"
                    not "history, "summary" not "summ", etc.
         """
-        if (self.pageractive
+        if (self._neverpager
+            or self.pageractive
             # TODO: if we want to allow HGPLAINEXCEPT=pager,
             # formatted() will need some adjustment.
             or not self.formatted()