Patchwork [3,of,9,pager] ui: introduce neverpager() call

login
register
mail settings
Submitter Augie Fackler
Date Feb. 16, 2017, 2:12 a.m.
Message ID <8695f290ba7c1a7f6c1b.1487211155@imladris.local>
Download mbox | patch
Permalink /patch/18534/
State Superseded
Headers show

Comments

Augie Fackler - Feb. 16, 2017, 2:12 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1487198883 18000
#      Wed Feb 15 17:48:03 2017 -0500
# Node ID 8695f290ba7c1a7f6c1b93ba344fbbe1193ab1a5
# Parent  cafe46e7d79c59567edc185979cf6568367def93
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.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -746,6 +746,9 @@  def _dispatch(req):
             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
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -147,6 +147,7 @@  class ui(object):
             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()
@@ -164,6 +165,7 @@  class ui(object):
             self.ferr = util.stderr
             self.fin = util.stdin
             self.pageractive = False
+            self._neverpager = False
 
             # shared read-only environment
             self.environ = encoding.environ
@@ -797,6 +799,9 @@  class ui(object):
             return False
         return util.isatty(fh)
 
+    def neverpager(self):
+        self._neverpager = True
+
     def pager(self, command):
         """Start a pager for subsequent command output.
 
@@ -810,7 +815,8 @@  class ui(object):
           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()