pager: use less as a fallback on Unix stable
authorYuya Nishihara <yuya@tcha.org>
Fri, 28 Apr 2017 20:51:14 +0900
branchstable
changeset 32078 bf5e13e38390
parent 32077 de115db3688e
child 32079 76ed60630dd5
pager: use less as a fallback on Unix This seems reasonable choice per discussion, and the default-default of Git. See also the inline-comment for why. https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-April/097042.html
mercurial/help/pager.txt
mercurial/rcutil.py
mercurial/scmposix.py
mercurial/scmwindows.py
mercurial/ui.py
--- a/mercurial/help/pager.txt	Tue Apr 25 22:10:26 2017 -0400
+++ b/mercurial/help/pager.txt	Fri Apr 28 20:51:14 2017 +0900
@@ -8,7 +8,7 @@
 
 If no pager is set, the pager extensions uses the environment variable
 $PAGER. If neither pager.pager, nor $PAGER is set, a default pager
-will be used, typically `more`.
+will be used, typically `less` on Unix and `more` on Windows.
 
 You can disable the pager for certain commands by adding them to the
 pager.ignore list::
--- a/mercurial/rcutil.py	Tue Apr 25 22:10:26 2017 -0400
+++ b/mercurial/rcutil.py	Fri Apr 28 20:51:14 2017 +0900
@@ -21,6 +21,7 @@
 else:
     from . import scmposix as scmplatform
 
+fallbackpager = scmplatform.fallbackpager
 systemrcpath = scmplatform.systemrcpath
 userrcpath = scmplatform.userrcpath
 
--- a/mercurial/scmposix.py	Tue Apr 25 22:10:26 2017 -0400
+++ b/mercurial/scmposix.py	Fri Apr 28 20:51:14 2017 +0900
@@ -12,6 +12,12 @@
     pycompat,
 )
 
+# BSD 'more' escapes ANSI color sequences by default. This can be disabled by
+# $MORE variable, but there's no compatible option with Linux 'more'. Given
+# OS X is widely used and most modern Unix systems would have 'less', setting
+# 'less' as the default seems reasonable.
+fallbackpager = 'less'
+
 def _rcfiles(path):
     rcs = [os.path.join(path, 'hgrc')]
     rcdir = os.path.join(path, 'hgrc.d')
--- a/mercurial/scmwindows.py	Tue Apr 25 22:10:26 2017 -0400
+++ b/mercurial/scmwindows.py	Fri Apr 28 20:51:14 2017 +0900
@@ -16,6 +16,9 @@
 except ImportError:
     import winreg
 
+# MS-DOS 'more' is the only pager available by default on Windows.
+fallbackpager = 'more'
+
 def systemrcpath():
     '''return default os-specific hgrc search path'''
     rcpath = []
--- a/mercurial/ui.py	Tue Apr 25 22:10:26 2017 -0400
+++ b/mercurial/ui.py	Fri Apr 28 20:51:14 2017 +0900
@@ -857,8 +857,7 @@
             # HGPLAINEXCEPT=pager, and the user didn't specify --debug.
             return
 
-        fallbackpager = 'more'
-        pagercmd = self.config('pager', 'pager', fallbackpager)
+        pagercmd = self.config('pager', 'pager', rcutil.fallbackpager)
         if not pagercmd:
             return