##// END OF EJS Templates
tests: switch "this command isn't paged" example to id...
Augie Fackler -
r30944:b7e073ae default
parent child Browse files
Show More
@@ -1,234 +1,224 b''
1 $ cat >> fakepager.py <<EOF
1 $ cat >> fakepager.py <<EOF
2 > import sys
2 > import sys
3 > for line in sys.stdin:
3 > for line in sys.stdin:
4 > sys.stdout.write('paged! %r\n' % line)
4 > sys.stdout.write('paged! %r\n' % line)
5 > EOF
5 > EOF
6
6
7 Enable ui.formatted because pager won't fire without it, and set up
7 Enable ui.formatted because pager won't fire without it, and set up
8 pager and tell it to use our fake pager that lets us see when the
8 pager and tell it to use our fake pager that lets us see when the
9 pager was running.
9 pager was running.
10 $ cat >> $HGRCPATH <<EOF
10 $ cat >> $HGRCPATH <<EOF
11 > [ui]
11 > [ui]
12 > formatted = yes
12 > formatted = yes
13 > [extensions]
13 > [extensions]
14 > pager=
14 > pager=
15 > [pager]
15 > [pager]
16 > pager = python $TESTTMP/fakepager.py
16 > pager = python $TESTTMP/fakepager.py
17 > EOF
17 > EOF
18
18
19 $ hg init repo
19 $ hg init repo
20 $ cd repo
20 $ cd repo
21 $ echo a >> a
21 $ echo a >> a
22 $ hg add a
22 $ hg add a
23 $ hg ci -m 'add a'
23 $ hg ci -m 'add a'
24 $ for x in `python $TESTDIR/seq.py 1 10`; do
24 $ for x in `python $TESTDIR/seq.py 1 10`; do
25 > echo a $x >> a
25 > echo a $x >> a
26 > hg ci -m "modify a $x"
26 > hg ci -m "modify a $x"
27 > done
27 > done
28
28
29 By default diff and log are paged, but summary is not:
29 By default diff and log are paged, but id is not:
30
30
31 $ hg diff -c 2 --pager=yes
31 $ hg diff -c 2 --pager=yes
32 paged! 'diff -r f4be7687d414 -r bce265549556 a\n'
32 paged! 'diff -r f4be7687d414 -r bce265549556 a\n'
33 paged! '--- a/a\tThu Jan 01 00:00:00 1970 +0000\n'
33 paged! '--- a/a\tThu Jan 01 00:00:00 1970 +0000\n'
34 paged! '+++ b/a\tThu Jan 01 00:00:00 1970 +0000\n'
34 paged! '+++ b/a\tThu Jan 01 00:00:00 1970 +0000\n'
35 paged! '@@ -1,2 +1,3 @@\n'
35 paged! '@@ -1,2 +1,3 @@\n'
36 paged! ' a\n'
36 paged! ' a\n'
37 paged! ' a 1\n'
37 paged! ' a 1\n'
38 paged! '+a 2\n'
38 paged! '+a 2\n'
39
39
40 $ hg log --limit 2
40 $ hg log --limit 2
41 paged! 'changeset: 10:46106edeeb38\n'
41 paged! 'changeset: 10:46106edeeb38\n'
42 paged! 'tag: tip\n'
42 paged! 'tag: tip\n'
43 paged! 'user: test\n'
43 paged! 'user: test\n'
44 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
44 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
45 paged! 'summary: modify a 10\n'
45 paged! 'summary: modify a 10\n'
46 paged! '\n'
46 paged! '\n'
47 paged! 'changeset: 9:6dd8ea7dd621\n'
47 paged! 'changeset: 9:6dd8ea7dd621\n'
48 paged! 'user: test\n'
48 paged! 'user: test\n'
49 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
49 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
50 paged! 'summary: modify a 9\n'
50 paged! 'summary: modify a 9\n'
51 paged! '\n'
51 paged! '\n'
52
52
53 $ hg summary
53 $ hg id
54 parent: 10:46106edeeb38 tip
54 46106edeeb38 tip
55 modify a 10
56 branch: default
57 commit: (clean)
58 update: (current)
59 phases: 11 draft
60
55
61 We can enable the pager on summary:
56 We can enable the pager on id:
62
57
63 $ hg --config pager.attend-summary=yes summary
58 $ hg --config pager.attend-id=yes id
64 paged! 'parent: 10:46106edeeb38 tip\n'
59 paged! '46106edeeb38 tip\n'
65 paged! ' modify a 10\n'
66 paged! 'branch: default\n'
67 paged! 'commit: (clean)\n'
68 paged! 'update: (current)\n'
69 paged! 'phases: 11 draft\n'
70
60
71 If we completely change the attend list that's respected:
61 If we completely change the attend list that's respected:
72
62
73 $ hg --config pager.attend-diff=no diff -c 2
63 $ hg --config pager.attend-diff=no diff -c 2
74 diff -r f4be7687d414 -r bce265549556 a
64 diff -r f4be7687d414 -r bce265549556 a
75 --- a/a Thu Jan 01 00:00:00 1970 +0000
65 --- a/a Thu Jan 01 00:00:00 1970 +0000
76 +++ b/a Thu Jan 01 00:00:00 1970 +0000
66 +++ b/a Thu Jan 01 00:00:00 1970 +0000
77 @@ -1,2 +1,3 @@
67 @@ -1,2 +1,3 @@
78 a
68 a
79 a 1
69 a 1
80 +a 2
70 +a 2
81
71
82 $ hg --config pager.attend=summary diff -c 2
72 $ hg --config pager.attend=summary diff -c 2
83 diff -r f4be7687d414 -r bce265549556 a
73 diff -r f4be7687d414 -r bce265549556 a
84 --- a/a Thu Jan 01 00:00:00 1970 +0000
74 --- a/a Thu Jan 01 00:00:00 1970 +0000
85 +++ b/a Thu Jan 01 00:00:00 1970 +0000
75 +++ b/a Thu Jan 01 00:00:00 1970 +0000
86 @@ -1,2 +1,3 @@
76 @@ -1,2 +1,3 @@
87 a
77 a
88 a 1
78 a 1
89 +a 2
79 +a 2
90
80
91 If 'log' is in attend, then 'history' should also be paged:
81 If 'log' is in attend, then 'history' should also be paged:
92 $ hg history --limit 2 --config pager.attend=log
82 $ hg history --limit 2 --config pager.attend=log
93 paged! 'changeset: 10:46106edeeb38\n'
83 paged! 'changeset: 10:46106edeeb38\n'
94 paged! 'tag: tip\n'
84 paged! 'tag: tip\n'
95 paged! 'user: test\n'
85 paged! 'user: test\n'
96 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
86 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
97 paged! 'summary: modify a 10\n'
87 paged! 'summary: modify a 10\n'
98 paged! '\n'
88 paged! '\n'
99 paged! 'changeset: 9:6dd8ea7dd621\n'
89 paged! 'changeset: 9:6dd8ea7dd621\n'
100 paged! 'user: test\n'
90 paged! 'user: test\n'
101 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
91 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
102 paged! 'summary: modify a 9\n'
92 paged! 'summary: modify a 9\n'
103 paged! '\n'
93 paged! '\n'
104
94
105 Possible bug: history is explicitly ignored in pager config, but
95 Possible bug: history is explicitly ignored in pager config, but
106 because log is in the attend list it still gets pager treatment.
96 because log is in the attend list it still gets pager treatment.
107
97
108 $ hg history --limit 2 --config pager.attend=log \
98 $ hg history --limit 2 --config pager.attend=log \
109 > --config pager.ignore=history
99 > --config pager.ignore=history
110 paged! 'changeset: 10:46106edeeb38\n'
100 paged! 'changeset: 10:46106edeeb38\n'
111 paged! 'tag: tip\n'
101 paged! 'tag: tip\n'
112 paged! 'user: test\n'
102 paged! 'user: test\n'
113 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
103 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
114 paged! 'summary: modify a 10\n'
104 paged! 'summary: modify a 10\n'
115 paged! '\n'
105 paged! '\n'
116 paged! 'changeset: 9:6dd8ea7dd621\n'
106 paged! 'changeset: 9:6dd8ea7dd621\n'
117 paged! 'user: test\n'
107 paged! 'user: test\n'
118 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
108 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
119 paged! 'summary: modify a 9\n'
109 paged! 'summary: modify a 9\n'
120 paged! '\n'
110 paged! '\n'
121
111
122 Possible bug: history is explicitly marked as attend-history=no, but
112 Possible bug: history is explicitly marked as attend-history=no, but
123 it doesn't fail to get paged because log is still in the attend list.
113 it doesn't fail to get paged because log is still in the attend list.
124
114
125 $ hg history --limit 2 --config pager.attend-history=no
115 $ hg history --limit 2 --config pager.attend-history=no
126 paged! 'changeset: 10:46106edeeb38\n'
116 paged! 'changeset: 10:46106edeeb38\n'
127 paged! 'tag: tip\n'
117 paged! 'tag: tip\n'
128 paged! 'user: test\n'
118 paged! 'user: test\n'
129 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
119 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
130 paged! 'summary: modify a 10\n'
120 paged! 'summary: modify a 10\n'
131 paged! '\n'
121 paged! '\n'
132 paged! 'changeset: 9:6dd8ea7dd621\n'
122 paged! 'changeset: 9:6dd8ea7dd621\n'
133 paged! 'user: test\n'
123 paged! 'user: test\n'
134 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
124 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
135 paged! 'summary: modify a 9\n'
125 paged! 'summary: modify a 9\n'
136 paged! '\n'
126 paged! '\n'
137
127
138 Possible bug: disabling pager for log but enabling it for history
128 Possible bug: disabling pager for log but enabling it for history
139 doesn't result in history being paged.
129 doesn't result in history being paged.
140
130
141 $ hg history --limit 2 --config pager.attend-log=no \
131 $ hg history --limit 2 --config pager.attend-log=no \
142 > --config pager.attend-history=yes
132 > --config pager.attend-history=yes
143 changeset: 10:46106edeeb38
133 changeset: 10:46106edeeb38
144 tag: tip
134 tag: tip
145 user: test
135 user: test
146 date: Thu Jan 01 00:00:00 1970 +0000
136 date: Thu Jan 01 00:00:00 1970 +0000
147 summary: modify a 10
137 summary: modify a 10
148
138
149 changeset: 9:6dd8ea7dd621
139 changeset: 9:6dd8ea7dd621
150 user: test
140 user: test
151 date: Thu Jan 01 00:00:00 1970 +0000
141 date: Thu Jan 01 00:00:00 1970 +0000
152 summary: modify a 9
142 summary: modify a 9
153
143
154
144
155 Pager should not start if stdout is not a tty.
145 Pager should not start if stdout is not a tty.
156
146
157 $ hg log -l1 -q --config ui.formatted=False
147 $ hg log -l1 -q --config ui.formatted=False
158 10:46106edeeb38
148 10:46106edeeb38
159
149
160 Pager with color enabled allows colors to come through by default,
150 Pager with color enabled allows colors to come through by default,
161 even though stdout is no longer a tty.
151 even though stdout is no longer a tty.
162 $ cat >> $HGRCPATH <<EOF
152 $ cat >> $HGRCPATH <<EOF
163 > [extensions]
153 > [extensions]
164 > color=
154 > color=
165 > [color]
155 > [color]
166 > mode = ansi
156 > mode = ansi
167 > EOF
157 > EOF
168 $ hg log --limit 3
158 $ hg log --limit 3
169 paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n'
159 paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n'
170 paged! 'tag: tip\n'
160 paged! 'tag: tip\n'
171 paged! 'user: test\n'
161 paged! 'user: test\n'
172 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
162 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
173 paged! 'summary: modify a 10\n'
163 paged! 'summary: modify a 10\n'
174 paged! '\n'
164 paged! '\n'
175 paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n'
165 paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n'
176 paged! 'user: test\n'
166 paged! 'user: test\n'
177 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
167 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
178 paged! 'summary: modify a 9\n'
168 paged! 'summary: modify a 9\n'
179 paged! '\n'
169 paged! '\n'
180 paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n'
170 paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n'
181 paged! 'user: test\n'
171 paged! 'user: test\n'
182 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
172 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
183 paged! 'summary: modify a 8\n'
173 paged! 'summary: modify a 8\n'
184 paged! '\n'
174 paged! '\n'
185
175
186 Pager works with shell aliases.
176 Pager works with shell aliases.
187
177
188 $ cat >> $HGRCPATH <<EOF
178 $ cat >> $HGRCPATH <<EOF
189 > [alias]
179 > [alias]
190 > echoa = !echo a
180 > echoa = !echo a
191 > EOF
181 > EOF
192
182
193 $ hg echoa
183 $ hg echoa
194 a
184 a
195 $ hg --config pager.attend-echoa=yes echoa
185 $ hg --config pager.attend-echoa=yes echoa
196 paged! 'a\n'
186 paged! 'a\n'
197
187
198 Pager works with hg aliases including environment variables.
188 Pager works with hg aliases including environment variables.
199
189
200 $ cat >> $HGRCPATH <<'EOF'
190 $ cat >> $HGRCPATH <<'EOF'
201 > [alias]
191 > [alias]
202 > printa = log -T "$A\n" -r 0
192 > printa = log -T "$A\n" -r 0
203 > EOF
193 > EOF
204
194
205 $ A=1 hg --config pager.attend-printa=yes printa
195 $ A=1 hg --config pager.attend-printa=yes printa
206 paged! '1\n'
196 paged! '1\n'
207 $ A=2 hg --config pager.attend-printa=yes printa
197 $ A=2 hg --config pager.attend-printa=yes printa
208 paged! '2\n'
198 paged! '2\n'
209
199
210 Something that's explicitly attended is still not paginated if the
200 Something that's explicitly attended is still not paginated if the
211 pager is globally set to off using a flag:
201 pager is globally set to off using a flag:
212 $ A=2 hg --config pager.attend-printa=yes printa --pager=no
202 $ A=2 hg --config pager.attend-printa=yes printa --pager=no
213 2
203 2
214
204
215 Pager should not override the exit code of other commands
205 Pager should not override the exit code of other commands
216
206
217 $ cat >> $TESTTMP/fortytwo.py <<'EOF'
207 $ cat >> $TESTTMP/fortytwo.py <<'EOF'
218 > from mercurial import cmdutil, commands
208 > from mercurial import cmdutil, commands
219 > cmdtable = {}
209 > cmdtable = {}
220 > command = cmdutil.command(cmdtable)
210 > command = cmdutil.command(cmdtable)
221 > @command('fortytwo', [], 'fortytwo', norepo=True)
211 > @command('fortytwo', [], 'fortytwo', norepo=True)
222 > def fortytwo(ui, *opts):
212 > def fortytwo(ui, *opts):
223 > ui.write('42\n')
213 > ui.write('42\n')
224 > return 42
214 > return 42
225 > EOF
215 > EOF
226
216
227 $ cat >> $HGRCPATH <<'EOF'
217 $ cat >> $HGRCPATH <<'EOF'
228 > [extensions]
218 > [extensions]
229 > fortytwo = $TESTTMP/fortytwo.py
219 > fortytwo = $TESTTMP/fortytwo.py
230 > EOF
220 > EOF
231
221
232 $ hg fortytwo --pager=on
222 $ hg fortytwo --pager=on
233 paged! '42\n'
223 paged! '42\n'
234 [42]
224 [42]
General Comments 0
You need to be logged in to leave comments. Login now