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