[PATCH STABLE] pager: use less as a fallback on Unix
Yuya Nishihara
yuya at tcha.org
Fri Apr 28 12:14:04 UTC 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1493380274 -32400
# Fri Apr 28 20:51:14 2017 +0900
# Branch stable
# Node ID a05035fe3995e4cfaa362d4976d89f5d8be3c5d9
# Parent f9dd22b588e9f0eb475ce522a78c640d35c12310
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
diff --git a/mercurial/help/pager.txt b/mercurial/help/pager.txt
--- a/mercurial/help/pager.txt
+++ b/mercurial/help/pager.txt
@@ -8,7 +8,7 @@ To set the pager that should be used, se
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::
diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -21,6 +21,7 @@ if pycompat.osname == 'nt':
else:
from . import scmposix as scmplatform
+fallbackpager = scmplatform.fallbackpager
systemrcpath = scmplatform.systemrcpath
userrcpath = scmplatform.userrcpath
diff --git a/mercurial/scmposix.py b/mercurial/scmposix.py
--- a/mercurial/scmposix.py
+++ b/mercurial/scmposix.py
@@ -12,6 +12,12 @@ from . import (
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')
diff --git a/mercurial/scmwindows.py b/mercurial/scmwindows.py
--- a/mercurial/scmwindows.py
+++ b/mercurial/scmwindows.py
@@ -16,6 +16,9 @@ try:
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 = []
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -857,8 +857,7 @@ class ui(object):
# 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
More information about the Mercurial-devel
mailing list