Patchwork [2,of,2,pager-tweaks] dispatch: consolidate pager flag handling to a single place

login
register
mail settings
Submitter Augie Fackler
Date Feb. 20, 2017, 1:19 a.m.
Message ID <86a8d5ba8a05485fa1f9.1487553582@imladris.local>
Download mbox | patch
Permalink /patch/18679/
State Accepted
Headers show

Comments

Augie Fackler - Feb. 20, 2017, 1:19 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1487553371 18000
#      Sun Feb 19 20:16:11 2017 -0500
# Node ID 86a8d5ba8a05485fa1f90927c41ead4e7bb84b54
# Parent  147cbbe59b257eac92c779361894ae361a788f83
dispatch: consolidate pager flag handling to a single place

This makes a little more sense, thanks to Martin for suggesting it.
Martin von Zweigbergk - Feb. 20, 2017, 8:24 a.m.
On Sun, Feb 19, 2017 at 5:19 PM, Augie Fackler <raf@durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1487553371 18000
> #      Sun Feb 19 20:16:11 2017 -0500
> # Node ID 86a8d5ba8a05485fa1f90927c41ead4e7bb84b54
> # Parent  147cbbe59b257eac92c779361894ae361a788f83
> dispatch: consolidate pager flag handling to a single place
>
> This makes a little more sense, thanks to Martin for suggesting it.

And thanks for following up. Queued, thanks!

>
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -749,7 +749,10 @@ def _dispatch(req):
>              for ui_ in uis:
>                  ui_.setconfig('ui', 'interactive', 'off', '-y')
>
> -        if options['pager'] != 'auto' and not util.parsebool(options['pager']):
> +        pagerbool = util.parsebool(options['pager'])
> +        if pagerbool:
> +            ui.pager('internal-always-' + cmd)
> +        elif options['pager'] != 'auto' and not pagerbool:

pagerbool was tested above, so we know it's false here, so I dropped
the extra check in flight. Since that meant that pagerbool was used in
only one place, I also inlined the variable there.

>              ui.disablepager()
>
>          if cmdoptions.get('insecure', False):
> @@ -822,8 +825,6 @@ def _dispatch(req):
>
>  def _runcommand(ui, options, cmd, cmdfunc):
>      """Run a command function, possibly with profiling enabled."""
> -    if util.parsebool(options['pager']):
> -        ui.pager('internal-always-' + cmd)
>      try:
>          return cmdfunc()
>      except error.SignatureError:
> _______________________________________________
> 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,7 +749,10 @@  def _dispatch(req):
             for ui_ in uis:
                 ui_.setconfig('ui', 'interactive', 'off', '-y')
 
-        if options['pager'] != 'auto' and not util.parsebool(options['pager']):
+        pagerbool = util.parsebool(options['pager'])
+        if pagerbool:
+            ui.pager('internal-always-' + cmd)
+        elif options['pager'] != 'auto' and not pagerbool:
             ui.disablepager()
 
         if cmdoptions.get('insecure', False):
@@ -822,8 +825,6 @@  def _dispatch(req):
 
 def _runcommand(ui, options, cmd, cmdfunc):
     """Run a command function, possibly with profiling enabled."""
-    if util.parsebool(options['pager']):
-        ui.pager('internal-always-' + cmd)
     try:
         return cmdfunc()
     except error.SignatureError: