Patchwork [2,of,2,pager-endgame] pager: add a config knob to just globally turn off the pager

login
register
mail settings
Submitter Augie Fackler
Date Feb. 21, 2017, 9:18 p.m.
Message ID <390e26db66994cc2f627.1487711893@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/18695/
State Accepted
Headers show

Comments

Augie Fackler - Feb. 21, 2017, 9:18 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1486505605 18000
#      Tue Feb 07 17:13:25 2017 -0500
# Node ID 390e26db66994cc2f627933815db02353958289f
# Parent  589dcabe2b7a2b9f2d49646d710335e5a70ad492
pager: add a config knob to just globally turn off the pager
Yuya Nishihara - Feb. 22, 2017, 2:33 p.m.
On Tue, 21 Feb 2017 16:18:13 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1486505605 18000
> #      Tue Feb 07 17:13:25 2017 -0500
> # Node ID 390e26db66994cc2f627933815db02353958289f
> # Parent  589dcabe2b7a2b9f2d49646d710335e5a70ad492
> pager: add a config knob to just globally turn off the pager
> 
> diff --git a/mercurial/help/pager.txt b/mercurial/help/pager.txt
> --- a/mercurial/help/pager.txt
> +++ b/mercurial/help/pager.txt
> @@ -26,3 +26,10 @@ you can use --pager=<value>::
>    - require the pager: `yes` or `on`.
>    - suppress the pager: `no` or `off` (any unrecognized value
>    will also work).
> +
> +To globally turn off all attempts to use a pager, set::
> +
> +  [pager]
> +  enable = false
> +
> +which will prevent the pager from running.
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -857,6 +857,7 @@ class ui(object):
>          if (self._disablepager
>              or self.pageractive
>              or command in self.configlist('pager', 'ignore')
> +            or not self.configbool('pager', 'enable', True)

Perhaps disablepager() could be merged with this?
Augie Fackler - March 8, 2017, 11:26 p.m.
> On Feb 22, 2017, at 09:33, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> On Tue, 21 Feb 2017 16:18:13 -0500, Augie Fackler wrote:
>> # HG changeset patch
>> # User Augie Fackler <augie@google.com>
>> # Date 1486505605 18000
>> #      Tue Feb 07 17:13:25 2017 -0500
>> # Node ID 390e26db66994cc2f627933815db02353958289f
>> # Parent  589dcabe2b7a2b9f2d49646d710335e5a70ad492
>> pager: add a config knob to just globally turn off the pager
>> 
>> diff --git a/mercurial/help/pager.txt b/mercurial/help/pager.txt
>> --- a/mercurial/help/pager.txt
>> +++ b/mercurial/help/pager.txt
>> @@ -26,3 +26,10 @@ you can use --pager=<value>::
>>   - require the pager: `yes` or `on`.
>>   - suppress the pager: `no` or `off` (any unrecognized value
>>   will also work).
>> +
>> +To globally turn off all attempts to use a pager, set::
>> +
>> +  [pager]
>> +  enable = false
>> +
>> +which will prevent the pager from running.
>> diff --git a/mercurial/ui.py b/mercurial/ui.py
>> --- a/mercurial/ui.py
>> +++ b/mercurial/ui.py
>> @@ -857,6 +857,7 @@ class ui(object):
>>         if (self._disablepager
>>             or self.pageractive
>>             or command in self.configlist('pager', 'ignore')
>> +            or not self.configbool('pager', 'enable', True)
> 
> Perhaps disablepager() could be merged with this?

I suppose it could, although I kind of like the explicitness of --pager=never overriding some well-intentioned extension that tries to turn the pager on for you.

I don't feel strongly either way though.

Patch

diff --git a/mercurial/help/pager.txt b/mercurial/help/pager.txt
--- a/mercurial/help/pager.txt
+++ b/mercurial/help/pager.txt
@@ -26,3 +26,10 @@  you can use --pager=<value>::
   - require the pager: `yes` or `on`.
   - suppress the pager: `no` or `off` (any unrecognized value
   will also work).
+
+To globally turn off all attempts to use a pager, set::
+
+  [pager]
+  enable = false
+
+which will prevent the pager from running.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -857,6 +857,7 @@  class ui(object):
         if (self._disablepager
             or self.pageractive
             or command in self.configlist('pager', 'ignore')
+            or not self.configbool('pager', 'enable', True)
             or not self.configbool('pager', 'attend-' + command, True)
             # TODO: if we want to allow HGPLAINEXCEPT=pager,
             # formatted() will need some adjustment.