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