Show More
@@ -1,229 +1,234 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 | 29 | By default diff and log are paged, but summary 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 | 53 | $ hg summary |
|
54 | 54 | parent: 10:46106edeeb38 tip |
|
55 | 55 | modify a 10 |
|
56 | 56 | branch: default |
|
57 | 57 | commit: (clean) |
|
58 | 58 | update: (current) |
|
59 | 59 | phases: 11 draft |
|
60 | 60 | |
|
61 | 61 | We can enable the pager on summary: |
|
62 | 62 | |
|
63 | 63 | $ hg --config pager.attend-summary=yes summary |
|
64 | 64 | paged! 'parent: 10:46106edeeb38 tip\n' |
|
65 | 65 | paged! ' modify a 10\n' |
|
66 | 66 | paged! 'branch: default\n' |
|
67 | 67 | paged! 'commit: (clean)\n' |
|
68 | 68 | paged! 'update: (current)\n' |
|
69 | 69 | paged! 'phases: 11 draft\n' |
|
70 | 70 | |
|
71 | 71 | If we completely change the attend list that's respected: |
|
72 | 72 | |
|
73 | 73 | $ hg --config pager.attend-diff=no diff -c 2 |
|
74 | 74 | diff -r f4be7687d414 -r bce265549556 a |
|
75 | 75 | --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
76 | 76 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
77 | 77 | @@ -1,2 +1,3 @@ |
|
78 | 78 | a |
|
79 | 79 | a 1 |
|
80 | 80 | +a 2 |
|
81 | 81 | |
|
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 | |
|
155 | 155 | Pager should not start if stdout is not a tty. |
|
156 | 156 | |
|
157 | 157 | $ hg log -l1 -q --config ui.formatted=False |
|
158 | 158 | 10:46106edeeb38 |
|
159 | 159 | |
|
160 | 160 | Pager with color enabled allows colors to come through by default, |
|
161 | 161 | even though stdout is no longer a tty. |
|
162 | 162 | $ cat >> $HGRCPATH <<EOF |
|
163 | 163 | > [extensions] |
|
164 | 164 | > color= |
|
165 | 165 | > [color] |
|
166 | 166 | > mode = ansi |
|
167 | 167 | > EOF |
|
168 | 168 | $ hg log --limit 3 |
|
169 | 169 | paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n' |
|
170 | 170 | paged! 'tag: tip\n' |
|
171 | 171 | paged! 'user: test\n' |
|
172 | 172 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
173 | 173 | paged! 'summary: modify a 10\n' |
|
174 | 174 | paged! '\n' |
|
175 | 175 | paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n' |
|
176 | 176 | paged! 'user: test\n' |
|
177 | 177 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
178 | 178 | paged! 'summary: modify a 9\n' |
|
179 | 179 | paged! '\n' |
|
180 | 180 | paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n' |
|
181 | 181 | paged! 'user: test\n' |
|
182 | 182 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
183 | 183 | paged! 'summary: modify a 8\n' |
|
184 | 184 | paged! '\n' |
|
185 | 185 | |
|
186 | 186 | Pager works with shell aliases. |
|
187 | 187 | |
|
188 | 188 | $ cat >> $HGRCPATH <<EOF |
|
189 | 189 | > [alias] |
|
190 | 190 | > echoa = !echo a |
|
191 | 191 | > EOF |
|
192 | 192 | |
|
193 | 193 | $ hg echoa |
|
194 | 194 | a |
|
195 | 195 | $ hg --config pager.attend-echoa=yes echoa |
|
196 | 196 | paged! 'a\n' |
|
197 | 197 | |
|
198 | 198 | Pager works with hg aliases including environment variables. |
|
199 | 199 | |
|
200 | 200 | $ cat >> $HGRCPATH <<'EOF' |
|
201 | 201 | > [alias] |
|
202 | 202 | > printa = log -T "$A\n" -r 0 |
|
203 | 203 | > EOF |
|
204 | 204 | |
|
205 | 205 | $ A=1 hg --config pager.attend-printa=yes printa |
|
206 | 206 | paged! '1\n' |
|
207 | 207 | $ A=2 hg --config pager.attend-printa=yes printa |
|
208 | 208 | paged! '2\n' |
|
209 | 209 | |
|
210 | Something that's explicitly attended is still not paginated if the | |
|
211 | pager is globally set to off using a flag: | |
|
212 | $ A=2 hg --config pager.attend-printa=yes printa --pager=no | |
|
213 | 2 | |
|
214 | ||
|
210 | 215 | Pager should not override the exit code of other commands |
|
211 | 216 | |
|
212 | 217 | $ cat >> $TESTTMP/fortytwo.py <<'EOF' |
|
213 | 218 | > from mercurial import cmdutil, commands |
|
214 | 219 | > cmdtable = {} |
|
215 | 220 | > command = cmdutil.command(cmdtable) |
|
216 | 221 | > @command('fortytwo', [], 'fortytwo', norepo=True) |
|
217 | 222 | > def fortytwo(ui, *opts): |
|
218 | 223 | > ui.write('42\n') |
|
219 | 224 | > return 42 |
|
220 | 225 | > EOF |
|
221 | 226 | |
|
222 | 227 | $ cat >> $HGRCPATH <<'EOF' |
|
223 | 228 | > [extensions] |
|
224 | 229 | > fortytwo = $TESTTMP/fortytwo.py |
|
225 | 230 | > EOF |
|
226 | 231 | |
|
227 | 232 | $ hg fortytwo --pager=on |
|
228 | 233 | paged! '42\n' |
|
229 | 234 | [42] |
General Comments 0
You need to be logged in to leave comments.
Login now