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