tests/test-pager.t
author Yuya Nishihara <yuya@tcha.org>
Wed, 09 Mar 2016 23:57:15 +0900
changeset 28428 6a4a4ca21907
parent 28319 09222d39fa34
child 28531 fe79a5821e5a
permissions -rw-r--r--
graphlog: bring back color to node symbol template Follows up 3356bf61fa25. A ui object is required to render labels.
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
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
By default diff and log are paged, but summary is not:
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
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    53
  $ hg summary
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    54
  parent: 10:46106edeeb38 tip
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    55
   modify a 10
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    56
  branch: default
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    57
  commit: (clean)
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    58
  update: (current)
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    59
  phases: 11 draft
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
We can enable the pager on summary:
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-summary=yes summary
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    64
  paged! 'parent: 10:46106edeeb38 tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    65
  paged! ' modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    66
  paged! 'branch: default\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    67
  paged! 'commit: (clean)\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    68
  paged! 'update: (current)\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    69
  paged! 'phases: 11 draft\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    70
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    71
If we completely change the attend list that's respected:
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    72
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    73
  $ hg --config pager.attend-diff=no diff -c 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    74
  diff -r f4be7687d414 -r bce265549556 a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    75
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    76
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    77
  @@ -1,2 +1,3 @@
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    78
   a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    79
   a 1
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    80
  +a 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    81
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    82
  $ hg --config pager.attend=summary diff -c 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    83
  diff -r f4be7687d414 -r bce265549556 a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    84
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    85
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    86
  @@ -1,2 +1,3 @@
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    87
   a
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    88
   a 1
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    89
  +a 2
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    90
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    91
If 'log' is in attend, then 'history' should also be paged:
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    92
  $ hg history --limit 2 --config pager.attend=log
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    93
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    94
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    95
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    96
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    97
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    98
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
    99
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   100
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   101
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   102
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   103
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   104
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   105
Possible bug: history is explicitly ignored in pager config, but
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   106
because log is in the attend list it still gets pager treatment.
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   107
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   108
  $ hg history --limit 2 --config pager.attend=log \
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   109
  >   --config pager.ignore=history
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   110
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   111
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   112
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   113
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   114
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   115
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   116
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   117
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   118
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   119
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   120
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   121
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   122
Possible bug: history is explicitly marked as attend-history=no, but
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   123
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
   124
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   125
  $ hg history --limit 2 --config pager.attend-history=no
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   126
  paged! 'changeset:   10:46106edeeb38\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   127
  paged! 'tag:         tip\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   128
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   129
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   130
  paged! 'summary:     modify a 10\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   131
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   132
  paged! 'changeset:   9:6dd8ea7dd621\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   133
  paged! 'user:        test\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   134
  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   135
  paged! 'summary:     modify a 9\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   136
  paged! '\n'
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   137
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   138
Possible bug: disabling pager for log but enabling it for history
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   139
doesn't result in history being paged.
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   140
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   141
  $ hg history --limit 2 --config pager.attend-log=no \
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   142
  > --config pager.attend-history=yes
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   143
  changeset:   10:46106edeeb38
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   144
  tag:         tip
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   145
  user:        test
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   146
  date:        Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   147
  summary:     modify a 10
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   148
  
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   149
  changeset:   9:6dd8ea7dd621
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   150
  user:        test
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   151
  date:        Thu Jan 01 00:00:00 1970 +0000
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   152
  summary:     modify a 9
09222d39fa34 pager: add tests
Augie Fackler <augie@google.com>
parents:
diff changeset
   153