# HG changeset patch # User Yuya Nishihara # Date 1495878766 -32400 # Node ID 3b569745af6ca0706b1c289cae49e431731cbd49 # Parent f4cd4c49e3020c860d08a483422ceb2ad4f6da9e cat: do not start pager if output will be written to file diff -r f4cd4c49e302 -r 3b569745af6c mercurial/commands.py --- a/mercurial/commands.py Sat May 27 18:50:05 2017 +0900 +++ b/mercurial/commands.py Sat May 27 18:52:46 2017 +0900 @@ -1364,8 +1364,11 @@ ctx = scmutil.revsingle(repo, opts.get('rev')) m = scmutil.match(ctx, (file1,) + pats, opts) fntemplate = opts.pop('output', '') - - ui.pager('cat') + if cmdutil.isstdiofilename(fntemplate): + fntemplate = '' + + if not fntemplate: + ui.pager('cat') return cmdutil.cat(ui, repo, ctx, m, fntemplate, '', **opts) @command('^clone', diff -r f4cd4c49e302 -r 3b569745af6c tests/test-pager.t --- a/tests/test-pager.t Sat May 27 18:50:05 2017 +0900 +++ b/tests/test-pager.t Sat May 27 18:52:46 2017 +0900 @@ -1,7 +1,11 @@ $ cat >> fakepager.py < import sys + > printed = False > for line in sys.stdin: > sys.stdout.write('paged! %r\n' % line) + > printed = True + > if not printed: + > sys.stdout.write('paged empty output!\n') > EOF Enable ui.formatted because pager won't fire without it, and set up @@ -281,6 +285,15 @@ 9: a 9 10: a 10 +A command with --output option: + + $ hg cat -r0 a + paged! 'a\n' + $ hg cat -r0 a --output=- + paged! 'a\n' + $ hg cat -r0 a --output=out + $ rm out + Put annotate in the ignore list for pager: $ cat >> $HGRCPATH < [pager]