[PATCH STABLE] ui: enable pager always for explicit --pager=on (issue5580)
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed Aug 2 12:51:11 UTC 2017
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1501581172 -32400
# Tue Aug 01 18:52:52 2017 +0900
# Branch stable
# Node ID e9883ae6e2d70b0f78ec8c8953b47130ecba3f07
# Parent 76b171209151fe41dbf8dbfec473cc533f3b40ca
# Available At https://bitbucket.org/foozy/mercurial-wip
# hg pull https://bitbucket.org/foozy/mercurial-wip -r e9883ae6e2d7
# EXP-Topic issue5580
ui: enable pager always for explicit --pager=on (issue5580)
Before this patch, explicit --pager=on is unintentionally ignored by
any disabling factor, even if priority of it is less than --pager=on
(e.g. "[ui] paginate = off").
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -828,6 +828,7 @@ def _dispatch(req):
color.setup(ui_)
if util.parsebool(options['pager']):
+ # ui.pager() expects 'internal-always-' prefix in this case
ui.pager('internal-always-' + cmd)
elif options['pager'] != 'auto':
ui.disablepager()
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -945,8 +945,14 @@ class ui(object):
not "history, "summary" not "summ", etc.
"""
if (self._disablepager
- or self.pageractive
- or command in self.configlist('pager', 'ignore')
+ or self.pageractive):
+ # how pager should do is already determined
+ return
+
+ if not command.startswith('internal-always-') and (
+ # explicit --pager=on (= 'internal-always-' prefix) should
+ # take precedence over disabling factors below
+ command in self.configlist('pager', 'ignore')
or not self.configbool('ui', 'paginate')
or not self.configbool('pager', 'attend-' + command, True)
# TODO: if we want to allow HGPLAINEXCEPT=pager,
diff --git a/tests/test-pager.t b/tests/test-pager.t
--- a/tests/test-pager.t
+++ b/tests/test-pager.t
@@ -80,6 +80,34 @@ We can control the pager from the config
paged! 'summary: modify a 10\n'
paged! '\n'
+explicit --pager=on should take precedence over other configurations
+(issue5580)
+
+ $ cat >> $HGRCPATH <<EOF
+ > [ui]
+ > paginate = false
+ > EOF
+ $ hg log --limit 1 --pager=on
+ paged! 'changeset: 10:46106edeeb38\n'
+ paged! 'tag: tip\n'
+ paged! 'user: test\n'
+ paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
+ paged! 'summary: modify a 10\n'
+ paged! '\n'
+
+ $ cat >> $HGRCPATH <<EOF
+ > [ui]
+ > # true is default value of ui.paginate
+ > paginate = true
+ > EOF
+ $ hg log --limit 1 --pager=off
+ changeset: 10:46106edeeb38
+ tag: tip
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: modify a 10
+
+
We can enable the pager on id:
BROKEN: should be paged
More information about the Mercurial-devel
mailing list