tests/test-pager.t
author Gregory Szorc <gregory.szorc@gmail.com>
Mon, 24 Apr 2017 23:10:43 -0700
branchstable
changeset 32072 05cdd5678c6b
parent 32026 57042e91521a
child 32073 04629b2da72c
permissions -rw-r--r--
tests: drop unnecessary pager attend in test `log` is attended by default. We don't need to specify pager.attend-log in this test.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
  $ cat >> fakepager.py <<EOF
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     2
  > import sys
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     3
  > for line in sys.stdin:
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     4
  >     sys.stdout.write('paged! %r\n' % line)
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     5
  > EOF
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     6
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     7
Enable ui.formatted because pager won't fire without it, and set up
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     8
pager and tell it to use our fake pager that lets us see when the
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
     9
pager was running.
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    10
  $ cat >> $HGRCPATH <<EOF
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    11
  > [ui]
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    12
  > formatted = yes
32026
57042e91521a color: turn on by default (but for windows)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32025
diff changeset
    13
  > color = no
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    14
  > [pager]
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    15
  > pager = python $TESTTMP/fakepager.py
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
  > EOF
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    18
  $ hg init repo
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
  $ cd repo
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
  $ echo a >> a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    21
  $ hg add a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
  $ hg ci -m 'add a'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    23
  $ for x in `python $TESTDIR/seq.py 1 10`; do
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
  >   echo a $x >> a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    25
  >   hg ci -m "modify a $x"
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    26
  > done
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    27
30964
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30962
diff changeset
    28
By default diff and log are paged, but id is not:
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    30
  $ hg diff -c 2 --pager=yes
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    31
  paged! 'diff -r f4be7687d414 -r bce265549556 a\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    32
  paged! '--- a/a\tThu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    33
  paged! '+++ b/a\tThu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    34
  paged! '@@ -1,2 +1,3 @@\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    35
  paged! ' a\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    36
  paged! ' a 1\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    37
  paged! '+a 2\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    38
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    39
  $ hg log --limit 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    40
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    41
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    42
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    43
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    44
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    45
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    46
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    47
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    48
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    49
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    50
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    51
30964
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30962
diff changeset
    52
  $ hg id
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30962
diff changeset
    53
  46106edeeb38 tip
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    54
30964
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30962
diff changeset
    55
We can enable the pager on id:
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    56
31414
d5eb20934c36 tests: duplicate test for pager for old extension and for in-core pager
Martin von Zweigbergk <martinvonz@google.com>
parents: 31096
diff changeset
    57
BROKEN: should be paged
30964
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30962
diff changeset
    58
  $ hg --config pager.attend-id=yes id
31414
d5eb20934c36 tests: duplicate test for pager for old extension and for in-core pager
Martin von Zweigbergk <martinvonz@google.com>
parents: 31096
diff changeset
    59
  46106edeeb38 tip
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    60
31016
cc3c9b6f1e09 tests: clean up a bunch of pager testing that is about to be invalidated
Augie Fackler <augie@google.com>
parents: 30964
diff changeset
    61
Setting attend-$COMMAND to a false value works, even with pager in
cc3c9b6f1e09 tests: clean up a bunch of pager testing that is about to be invalidated
Augie Fackler <augie@google.com>
parents: 30964
diff changeset
    62
core:
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    63
  $ hg --config pager.attend-diff=no diff -c 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    64
  diff -r f4be7687d414 -r bce265549556 a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    65
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    66
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    67
  @@ -1,2 +1,3 @@
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    68
   a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    69
   a 1
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    70
  +a 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    71
32072
05cdd5678c6b tests: drop unnecessary pager attend in test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32026
diff changeset
    72
Command aliases should have same behavior as main command
05cdd5678c6b tests: drop unnecessary pager attend in test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32026
diff changeset
    73
05cdd5678c6b tests: drop unnecessary pager attend in test
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32026
diff changeset
    74
  $ hg history --limit 2
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    75
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    76
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    77
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    78
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    79
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    80
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    81
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    82
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    83
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    84
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    85
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    86
30847
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 29344
diff changeset
    87
Pager should not start if stdout is not a tty.
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 29344
diff changeset
    88
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 29344
diff changeset
    89
  $ hg log -l1 -q --config ui.formatted=False
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 29344
diff changeset
    90
  10:46106edeeb38
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 29344
diff changeset
    91
31096
873ebdd6e84d pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents: 31020
diff changeset
    92
Pager should be disabled if pager.pager is empty (otherwise the output would
873ebdd6e84d pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents: 31020
diff changeset
    93
be silently lost.)
873ebdd6e84d pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents: 31020
diff changeset
    94
873ebdd6e84d pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents: 31020
diff changeset
    95
  $ hg log -l1 -q --config pager.pager=
873ebdd6e84d pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents: 31020
diff changeset
    96
  10:46106edeeb38
873ebdd6e84d pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents: 31020
diff changeset
    97
28531
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
    98
Pager with color enabled allows colors to come through by default,
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
    99
even though stdout is no longer a tty.
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   100
  $ cat >> $HGRCPATH <<EOF
32025
d323d9e0d7b4 pager: stop using the color extension in tests
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31954
diff changeset
   101
  > [ui]
d323d9e0d7b4 pager: stop using the color extension in tests
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31954
diff changeset
   102
  > color = yes
28531
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   103
  > [color]
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   104
  > mode = ansi
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   105
  > EOF
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   106
  $ hg log --limit 3
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   107
  paged! '\x1b[0;33mchangeset:   10:46106edeeb38\x1b[0m\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   108
  paged! 'tag:         tip\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   109
  paged! 'user:        test\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   110
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   111
  paged! 'summary:     modify a 10\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   112
  paged! '\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   113
  paged! '\x1b[0;33mchangeset:   9:6dd8ea7dd621\x1b[0m\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   114
  paged! 'user:        test\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   115
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   116
  paged! 'summary:     modify a 9\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   117
  paged! '\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   118
  paged! '\x1b[0;33mchangeset:   8:cff05a6312fe\x1b[0m\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   119
  paged! 'user:        test\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   120
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   121
  paged! 'summary:     modify a 8\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   122
  paged! '\n'
29132
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   123
31485
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   124
An invalid pager command name is reported sensibly if we don't have to
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   125
use shell=True in the subprocess call:
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   126
  $ hg log --limit 3 --config pager.pager=this-command-better-never-exist
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   127
  missing pager command 'this-command-better-never-exist', skipping pager
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   128
  \x1b[0;33mchangeset:   10:46106edeeb38\x1b[0m (esc)
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   129
  tag:         tip
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   130
  user:        test
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   131
  date:        Thu Jan 01 00:00:00 1970 +0000
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   132
  summary:     modify a 10
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   133
  
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   134
  \x1b[0;33mchangeset:   9:6dd8ea7dd621\x1b[0m (esc)
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   135
  user:        test
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   136
  date:        Thu Jan 01 00:00:00 1970 +0000
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   137
  summary:     modify a 9
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   138
  
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   139
  \x1b[0;33mchangeset:   8:cff05a6312fe\x1b[0m (esc)
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   140
  user:        test
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   141
  date:        Thu Jan 01 00:00:00 1970 +0000
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   142
  summary:     modify a 8
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   143
  
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   144
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   145
A complicated pager command gets worse behavior. Bonus points if you can
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   146
improve this.
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   147
  $ hg log --limit 3 \
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   148
  >   --config pager.pager='this-command-better-never-exist --seriously' \
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   149
  >  2>/dev/null || true
9335dc6b2a9c pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents: 31414
diff changeset
   150
29132
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   151
Pager works with shell aliases.
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   152
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   153
  $ cat >> $HGRCPATH <<EOF
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   154
  > [alias]
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   155
  > echoa = !echo a
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   156
  > EOF
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   157
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   158
  $ hg echoa
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   159
  a
31414
d5eb20934c36 tests: duplicate test for pager for old extension and for in-core pager
Martin von Zweigbergk <martinvonz@google.com>
parents: 31096
diff changeset
   160
BROKEN: should be paged
29132
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   161
  $ hg --config pager.attend-echoa=yes echoa
31414
d5eb20934c36 tests: duplicate test for pager for old extension and for in-core pager
Martin von Zweigbergk <martinvonz@google.com>
parents: 31096
diff changeset
   162
  a
29343
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   163
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   164
Pager works with hg aliases including environment variables.
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   165
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   166
  $ cat >> $HGRCPATH <<'EOF'
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   167
  > [alias]
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   168
  > printa = log -T "$A\n" -r 0
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   169
  > EOF
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   170
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   171
  $ A=1 hg --config pager.attend-printa=yes printa
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   172
  paged! '1\n'
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   173
  $ A=2 hg --config pager.attend-printa=yes printa
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   174
  paged! '2\n'
29344
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   175
30962
65a3b4d67a65 pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents: 30847
diff changeset
   176
Something that's explicitly attended is still not paginated if the
65a3b4d67a65 pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents: 30847
diff changeset
   177
pager is globally set to off using a flag:
65a3b4d67a65 pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents: 30847
diff changeset
   178
  $ A=2 hg --config pager.attend-printa=yes printa --pager=no
65a3b4d67a65 pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents: 30847
diff changeset
   179
  2
65a3b4d67a65 pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents: 30847
diff changeset
   180
29344
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   181
Pager should not override the exit code of other commands
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   182
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   183
  $ cat >> $TESTTMP/fortytwo.py <<'EOF'
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   184
  > from mercurial import cmdutil, commands
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   185
  > cmdtable = {}
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   186
  > command = cmdutil.command(cmdtable)
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   187
  > @command('fortytwo', [], 'fortytwo', norepo=True)
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   188
  > def fortytwo(ui, *opts):
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   189
  >     ui.write('42\n')
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   190
  >     return 42
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   191
  > EOF
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   192
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   193
  $ cat >> $HGRCPATH <<'EOF'
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   194
  > [extensions]
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   195
  > fortytwo = $TESTTMP/fortytwo.py
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   196
  > EOF
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   197
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   198
  $ hg fortytwo --pager=on
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   199
  paged! '42\n'
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   200
  [42]
31019
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   201
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   202
A command that asks for paging using ui.pager() directly works:
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   203
  $ hg blame a
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   204
  paged! ' 0: a\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   205
  paged! ' 1: a 1\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   206
  paged! ' 2: a 2\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   207
  paged! ' 3: a 3\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   208
  paged! ' 4: a 4\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   209
  paged! ' 5: a 5\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   210
  paged! ' 6: a 6\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   211
  paged! ' 7: a 7\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   212
  paged! ' 8: a 8\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   213
  paged! ' 9: a 9\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   214
  paged! '10: a 10\n'
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   215
but not with HGPLAIN
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   216
  $ HGPLAIN=1 hg blame a
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   217
   0: a
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   218
   1: a 1
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   219
   2: a 2
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   220
   3: a 3
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   221
   4: a 4
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   222
   5: a 5
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   223
   6: a 6
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   224
   7: a 7
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   225
   8: a 8
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   226
   9: a 9
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   227
  10: a 10
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   228
explicit flags work too:
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   229
  $ hg blame --pager=no a
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   230
   0: a
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   231
   1: a 1
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   232
   2: a 2
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   233
   3: a 3
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   234
   4: a 4
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   235
   5: a 5
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   236
   6: a 6
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   237
   7: a 7
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   238
   8: a 8
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   239
   9: a 9
334cf948c758 annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents: 31016
diff changeset
   240
  10: a 10
31020
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   241
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   242
Put annotate in the ignore list for pager:
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   243
  $ cat >> $HGRCPATH <<EOF
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   244
  > [pager]
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   245
  > ignore = annotate
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   246
  > EOF
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   247
  $ hg blame a
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   248
   0: a
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   249
   1: a 1
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   250
   2: a 2
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   251
   3: a 3
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   252
   4: a 4
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   253
   5: a 5
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   254
   6: a 6
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   255
   7: a 7
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   256
   8: a 8
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   257
   9: a 9
84ec2d6a2831 tests: prove that ignore works
Augie Fackler <augie@google.com>
parents: 31019
diff changeset
   258
  10: a 10
31954
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   259
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   260
Environment variables like LESS and LV are set automatically:
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   261
  $ cat > $TESTTMP/printlesslv.py <<EOF
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   262
  > import os, sys
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   263
  > sys.stdin.read()
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   264
  > for name in ['LESS', 'LV']:
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   265
  >     sys.stdout.write(('%s=%s\n') % (name, os.environ.get(name, '-')))
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   266
  > sys.stdout.flush()
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   267
  > EOF
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   268
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   269
  $ cat >> $HGRCPATH <<EOF
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   270
  > [alias]
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   271
  > noop = log -r 0 -T ''
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   272
  > [ui]
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   273
  > formatted=1
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   274
  > [pager]
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   275
  > pager = $PYTHON $TESTTMP/printlesslv.py
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   276
  > EOF
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   277
  $ unset LESS
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   278
  $ unset LV
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   279
  $ hg noop --pager=on
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   280
  LESS=FRX
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   281
  LV=-c
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   282
  $ LESS=EFGH hg noop --pager=on
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   283
  LESS=EFGH
e518192d6bac pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents: 31485
diff changeset
   284
  LV=-c