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

login
register
mail settings
Submitter Augie Fackler
Date Feb. 16, 2017, 4:59 p.m.
Message ID <2dcaa379926fbe6a5a3d.1487264352@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/18549/
State Accepted
Headers show

Comments

Augie Fackler - Feb. 16, 2017, 4:59 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1487198883 18000
#      Wed Feb 15 17:48:03 2017 -0500
# Node ID 2dcaa379926fbe6a5a3d628642ae61f363b500c4
# Parent  1a7ae87a4e564240a76d4841f91ffdd4331c90ee
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.
via Mercurial-devel - Feb. 16, 2017, 11:43 p.m.
On Thu, Feb 16, 2017 at 8:59 AM, Augie Fackler <raf@durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1487198883 18000
> #      Wed Feb 15 17:48:03 2017 -0500
> # Node ID 2dcaa379926fbe6a5a3d628642ae61f363b500c4
> # Parent  1a7ae87a4e564240a76d4841f91ffdd4331c90ee
> 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.
>
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -749,6 +749,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()
> +

It seems like it would make sense to have the pager=yes code together
with this. If we don't care that the command string (currently
"'internal-always-' + cmd") contains the command, it seems to me like
that would work.

>          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
> @@ -160,6 +160,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()
> @@ -178,6 +179,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
> @@ -836,6 +838,9 @@ class ui(object):
>              return False
>          return util.isatty(fh)
>
> +    def neverpager(self):
> +        self._neverpager = True
> +

Similar nit to the one I had on Simon's timing series: neverpager()
sounds like it's going to return a pager. Maybe disablepager()?

>      def pager(self, command):
>          """Start a pager for subsequent command output.
>
> @@ -849,7 +854,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()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -749,6 +749,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
@@ -160,6 +160,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()
@@ -178,6 +179,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
@@ -836,6 +838,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.
 
@@ -849,7 +854,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()