# HG changeset patch # User Jun Wu # Date 2017-08-30 21:04:55 # Node ID 31a2eb0f74e59327c0e1b49ee848c126993a29dc # Parent 37b82485097f928edce95b31071734be9edc107b pager: do not start pager if `ui` has been `pushbuffer`-ed The `pushbuffer`, `popbuffer` APIs are intended to capture internal output. They will prevent `ui.write` from writing to the actual `ui.fout`. So a pager won't receive the output and do the right thing. In general, it does not make sense to start a pager if ui is in the "pushbuffer" mode. Differential Revision: https://phab.mercurial-scm.org/D574 diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -962,6 +962,7 @@ class ui(object): # formatted() will need some adjustment. or not self.formatted() or self.plain() + or self._buffers # TODO: expose debugger-enabled on the UI object or '--debugger' in pycompat.sysargv): # We only want to paginate if the ui appears to be diff --git a/tests/test-pager.t b/tests/test-pager.t --- a/tests/test-pager.t +++ b/tests/test-pager.t @@ -340,6 +340,20 @@ Put annotate in the ignore list for page 9: a 9 10: a 10 +During pushbuffer, pager should not start: + $ cat > $TESTTMP/pushbufferpager.py < def uisetup(ui): + > ui.pushbuffer() + > ui.pager('mycmd') + > ui.write('content\n') + > ui.write(ui.popbuffer()) + > EOF + + $ echo append >> a + $ hg --config extensions.pushbuffer=$TESTTMP/pushbufferpager.py status --color=off + content + paged! 'M a\n' + Environment variables like LESS and LV are set automatically: $ cat > $TESTTMP/printlesslv.py < from __future__ import absolute_import