tests/test-pager.t
author Anton Shestakov <av6@dwimlabs.net>
Wed, 15 Feb 2017 14:49:33 +0800
changeset 30960 e4492d55fb66
parent 30944 b7e073ae44c4
child 30996 cc3c9b6f1e09
permissions -rw-r--r--
make: update .PHONY targets
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
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    13
  > [extensions]
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]
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
  > pager = python $TESTTMP/fakepager.py
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
  > EOF
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    18
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
  $ hg init repo
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
  $ cd repo
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    21
  $ echo a >> a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
  $ hg add a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    23
  $ hg ci -m 'add a'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
  $ for x in `python $TESTDIR/seq.py 1 10`; do
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    25
  >   echo a $x >> a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    26
  >   hg ci -m "modify a $x"
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    27
  > done
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    28
30944
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30942
diff changeset
    29
By default diff and log are paged, but id is not:
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    30
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    31
  $ hg diff -c 2 --pager=yes
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    32
  paged! 'diff -r f4be7687d414 -r bce265549556 a\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    33
  paged! '--- a/a\tThu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    34
  paged! '+++ b/a\tThu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    35
  paged! '@@ -1,2 +1,3 @@\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    36
  paged! ' a\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    37
  paged! ' a 1\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    38
  paged! '+a 2\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    39
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    40
  $ hg log --limit 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    41
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    42
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    43
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    44
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    45
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    46
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    47
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    48
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    49
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    50
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    51
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    52
30944
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30942
diff changeset
    53
  $ hg id
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30942
diff changeset
    54
  46106edeeb38 tip
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    55
30944
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30942
diff changeset
    56
We can enable the pager on id:
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    57
30944
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30942
diff changeset
    58
  $ hg --config pager.attend-id=yes id
b7e073ae44c4 tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents: 30942
diff changeset
    59
  paged! '46106edeeb38 tip\n'
28319
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    60
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    61
If we completely change the attend list that's respected:
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    62
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
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    72
  $ hg --config pager.attend=summary diff -c 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    73
  diff -r f4be7687d414 -r bce265549556 a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    74
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    75
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    76
  @@ -1,2 +1,3 @@
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    77
   a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    78
   a 1
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    79
  +a 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    80
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    81
If 'log' is in attend, then 'history' should also be paged:
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    82
  $ hg history --limit 2 --config pager.attend=log
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    83
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    84
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    85
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    86
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    87
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    88
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    89
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    90
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    91
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    92
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    93
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    94
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    95
Possible bug: history is explicitly ignored in pager config, but
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    96
because log is in the attend list it still gets pager treatment.
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    97
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    98
  $ hg history --limit 2 --config pager.attend=log \
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    99
  >   --config pager.ignore=history
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   100
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   101
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   102
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   103
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   104
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   105
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   106
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   107
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   108
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   109
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   110
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   111
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   112
Possible bug: history is explicitly marked as attend-history=no, but
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   113
it doesn't fail to get paged because log is still in the attend list.
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   114
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   115
  $ hg history --limit 2 --config pager.attend-history=no
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   116
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   117
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   118
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   119
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   120
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   121
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   122
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   123
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   124
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   125
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   126
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   127
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   128
Possible bug: disabling pager for log but enabling it for history
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   129
doesn't result in history being paged.
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   130
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   131
  $ hg history --limit 2 --config pager.attend-log=no \
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   132
  > --config pager.attend-history=yes
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   133
  changeset:   10:46106edeeb38
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   134
  tag:         tip
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   135
  user:        test
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   136
  date:        Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   137
  summary:     modify a 10
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   138
  
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   139
  changeset:   9:6dd8ea7dd621
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   140
  user:        test
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   141
  date:        Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   142
  summary:     modify a 9
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   143
  
28531
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   144
30847
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 29344
diff changeset
   145
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
   146
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 29344
diff changeset
   147
  $ 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
   148
  10:46106edeeb38
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 29344
diff changeset
   149
28531
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   150
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
   151
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
   152
  $ cat >> $HGRCPATH <<EOF
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   153
  > [extensions]
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   154
  > color=
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   155
  > [color]
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   156
  > mode = ansi
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   157
  > EOF
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   158
  $ hg log --limit 3
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   159
  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
   160
  paged! 'tag:         tip\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   161
  paged! 'user:        test\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   162
  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
   163
  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
   164
  paged! '\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   165
  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
   166
  paged! 'user:        test\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   167
  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
   168
  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
   169
  paged! '\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   170
  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
   171
  paged! 'user:        test\n'
fe79a5821e5a test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents: 28319
diff changeset
   172
  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
   173
  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
   174
  paged! '\n'
29132
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   175
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   176
Pager works with shell aliases.
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   177
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   178
  $ cat >> $HGRCPATH <<EOF
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   179
  > [alias]
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   180
  > echoa = !echo a
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   181
  > EOF
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   182
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   183
  $ hg echoa
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   184
  a
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   185
  $ hg --config pager.attend-echoa=yes echoa
12769703d4ba dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents: 28531
diff changeset
   186
  paged! 'a\n'
29343
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   187
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   188
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
   189
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   190
  $ cat >> $HGRCPATH <<'EOF'
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   191
  > [alias]
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   192
  > 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
   193
  > EOF
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   194
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   195
  $ 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
   196
  paged! '1\n'
e095b9e753f7 tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents: 29132
diff changeset
   197
  $ 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
   198
  paged! '2\n'
29344
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   199
30942
65a3b4d67a65 pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents: 30847
diff changeset
   200
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
   201
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
   202
  $ 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
   203
  2
65a3b4d67a65 pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents: 30847
diff changeset
   204
29344
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   205
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
   206
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   207
  $ cat >> $TESTTMP/fortytwo.py <<'EOF'
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   208
  > from mercurial import cmdutil, commands
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   209
  > cmdtable = {}
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   210
  > command = cmdutil.command(cmdtable)
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   211
  > @command('fortytwo', [], 'fortytwo', norepo=True)
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   212
  > def fortytwo(ui, *opts):
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   213
  >     ui.write('42\n')
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   214
  >     return 42
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   215
  > EOF
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   216
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   217
  $ cat >> $HGRCPATH <<'EOF'
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   218
  > [extensions]
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   219
  > fortytwo = $TESTTMP/fortytwo.py
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   220
  > EOF
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   221
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   222
  $ hg fortytwo --pager=on
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   223
  paged! '42\n'
bb3d5c20eaf6 chg: exec pager in child process
Jun Wu <quark@fb.com>
parents: 29343
diff changeset
   224
  [42]