changeset 31096:873ebdd6e84d

pager: do not try to run an empty pager command If pagercmd is explicitly set to '', the pager process would exit silently and the output would be lost. We'd better disable the pager in such case.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 23 Feb 2017 21:27:25 +0900
parents a113284f54a0
children 6918c9215201
files mercurial/ui.py tests/test-pager.t
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Thu Feb 23 21:20:26 2017 +0900
+++ b/mercurial/ui.py	Thu Feb 23 21:27:25 2017 +0900
@@ -869,7 +869,6 @@
             # interactive, the user didn't say HGPLAIN or
             # HGPLAINEXCEPT=pager, and the user didn't specify --debug.
             return
-        self.debug('starting pager for command %r\n' % command)
 
         # TODO: add a "system defaults" config section so this default
         # of more(1) can be easily replaced with a global
@@ -879,6 +878,10 @@
         # default editor command similar treatment.
         envpager = encoding.environ.get('PAGER', 'more')
         pagercmd = self.config('pager', 'pager', envpager)
+        if not pagercmd:
+            return
+
+        self.debug('starting pager for command %r\n' % command)
         self.pageractive = True
         # Preserve the formatted-ness of the UI. This is important
         # because we mess with stdout, which might confuse
--- a/tests/test-pager.t	Thu Feb 23 21:20:26 2017 +0900
+++ b/tests/test-pager.t	Thu Feb 23 21:27:25 2017 +0900
@@ -89,6 +89,12 @@
   $ hg log -l1 -q --config ui.formatted=False
   10:46106edeeb38
 
+Pager should be disabled if pager.pager is empty (otherwise the output would
+be silently lost.)
+
+  $ hg log -l1 -q --config pager.pager=
+  10:46106edeeb38
+
 Pager with color enabled allows colors to come through by default,
 even though stdout is no longer a tty.
   $ cat >> $HGRCPATH <<EOF