Show More
@@ -1,206 +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 | 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 | 53 | $ hg id |
|
54 | 54 | 46106edeeb38 tip |
|
55 | 55 | |
|
56 | 56 | We can enable the pager on id: |
|
57 | 57 | |
|
58 | 58 | $ hg --config pager.attend-id=yes id |
|
59 | 59 | paged! '46106edeeb38 tip\n' |
|
60 | 60 | |
|
61 | 61 | Setting attend-$COMMAND to a false value works, even with pager in |
|
62 | 62 | core: |
|
63 | 63 | |
|
64 | 64 | $ hg --config pager.attend-diff=no diff -c 2 |
|
65 | 65 | diff -r f4be7687d414 -r bce265549556 a |
|
66 | 66 | --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
67 | 67 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
68 | 68 | @@ -1,2 +1,3 @@ |
|
69 | 69 | a |
|
70 | 70 | a 1 |
|
71 | 71 | +a 2 |
|
72 | 72 | |
|
73 | 73 | If 'log' is in attend, then 'history' should also be paged: |
|
74 | 74 | $ hg history --limit 2 --config pager.attend=log |
|
75 | 75 | paged! 'changeset: 10:46106edeeb38\n' |
|
76 | 76 | paged! 'tag: tip\n' |
|
77 | 77 | paged! 'user: test\n' |
|
78 | 78 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
79 | 79 | paged! 'summary: modify a 10\n' |
|
80 | 80 | paged! '\n' |
|
81 | 81 | paged! 'changeset: 9:6dd8ea7dd621\n' |
|
82 | 82 | paged! 'user: test\n' |
|
83 | 83 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
84 | 84 | paged! 'summary: modify a 9\n' |
|
85 | 85 | paged! '\n' |
|
86 | 86 | |
|
87 | 87 | Pager should not start if stdout is not a tty. |
|
88 | 88 | |
|
89 | 89 | $ hg log -l1 -q --config ui.formatted=False |
|
90 | 90 | 10:46106edeeb38 |
|
91 | 91 | |
|
92 | 92 | Pager with color enabled allows colors to come through by default, |
|
93 | 93 | even though stdout is no longer a tty. |
|
94 | 94 | $ cat >> $HGRCPATH <<EOF |
|
95 | 95 | > [extensions] |
|
96 | 96 | > color= |
|
97 | 97 | > [color] |
|
98 | 98 | > mode = ansi |
|
99 | 99 | > EOF |
|
100 | 100 | $ hg log --limit 3 |
|
101 | 101 | paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n' |
|
102 | 102 | paged! 'tag: tip\n' |
|
103 | 103 | paged! 'user: test\n' |
|
104 | 104 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
105 | 105 | paged! 'summary: modify a 10\n' |
|
106 | 106 | paged! '\n' |
|
107 | 107 | paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n' |
|
108 | 108 | paged! 'user: test\n' |
|
109 | 109 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
110 | 110 | paged! 'summary: modify a 9\n' |
|
111 | 111 | paged! '\n' |
|
112 | 112 | paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n' |
|
113 | 113 | paged! 'user: test\n' |
|
114 | 114 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
115 | 115 | paged! 'summary: modify a 8\n' |
|
116 | 116 | paged! '\n' |
|
117 | 117 | |
|
118 | 118 | Pager works with shell aliases. |
|
119 | 119 | |
|
120 | 120 | $ cat >> $HGRCPATH <<EOF |
|
121 | 121 | > [alias] |
|
122 | 122 | > echoa = !echo a |
|
123 | 123 | > EOF |
|
124 | 124 | |
|
125 | 125 | $ hg echoa |
|
126 | 126 | a |
|
127 | 127 | $ hg --config pager.attend-echoa=yes echoa |
|
128 | 128 | paged! 'a\n' |
|
129 | 129 | |
|
130 | 130 | Pager works with hg aliases including environment variables. |
|
131 | 131 | |
|
132 | 132 | $ cat >> $HGRCPATH <<'EOF' |
|
133 | 133 | > [alias] |
|
134 | 134 | > printa = log -T "$A\n" -r 0 |
|
135 | 135 | > EOF |
|
136 | 136 | |
|
137 | 137 | $ A=1 hg --config pager.attend-printa=yes printa |
|
138 | 138 | paged! '1\n' |
|
139 | 139 | $ A=2 hg --config pager.attend-printa=yes printa |
|
140 | 140 | paged! '2\n' |
|
141 | 141 | |
|
142 | 142 | Something that's explicitly attended is still not paginated if the |
|
143 | 143 | pager is globally set to off using a flag: |
|
144 | 144 | $ A=2 hg --config pager.attend-printa=yes printa --pager=no |
|
145 | 145 | 2 |
|
146 | 146 | |
|
147 | 147 | Pager should not override the exit code of other commands |
|
148 | 148 | |
|
149 | 149 | $ cat >> $TESTTMP/fortytwo.py <<'EOF' |
|
150 | 150 | > from mercurial import cmdutil, commands |
|
151 | 151 | > cmdtable = {} |
|
152 | 152 | > command = cmdutil.command(cmdtable) |
|
153 | 153 | > @command('fortytwo', [], 'fortytwo', norepo=True) |
|
154 | 154 | > def fortytwo(ui, *opts): |
|
155 | 155 | > ui.write('42\n') |
|
156 | 156 | > return 42 |
|
157 | 157 | > EOF |
|
158 | 158 | |
|
159 | 159 | $ cat >> $HGRCPATH <<'EOF' |
|
160 | 160 | > [extensions] |
|
161 | 161 | > fortytwo = $TESTTMP/fortytwo.py |
|
162 | 162 | > EOF |
|
163 | 163 | |
|
164 | 164 | $ hg fortytwo --pager=on |
|
165 | 165 | paged! '42\n' |
|
166 | 166 | [42] |
|
167 | 167 | |
|
168 | 168 | A command that asks for paging using ui.pager() directly works: |
|
169 | 169 | $ hg blame a |
|
170 | 170 | paged! ' 0: a\n' |
|
171 | 171 | paged! ' 1: a 1\n' |
|
172 | 172 | paged! ' 2: a 2\n' |
|
173 | 173 | paged! ' 3: a 3\n' |
|
174 | 174 | paged! ' 4: a 4\n' |
|
175 | 175 | paged! ' 5: a 5\n' |
|
176 | 176 | paged! ' 6: a 6\n' |
|
177 | 177 | paged! ' 7: a 7\n' |
|
178 | 178 | paged! ' 8: a 8\n' |
|
179 | 179 | paged! ' 9: a 9\n' |
|
180 | 180 | paged! '10: a 10\n' |
|
181 | 181 | but not with HGPLAIN |
|
182 | 182 | $ HGPLAIN=1 hg blame a |
|
183 | 183 | 0: a |
|
184 | 184 | 1: a 1 |
|
185 | 185 | 2: a 2 |
|
186 | 186 | 3: a 3 |
|
187 | 187 | 4: a 4 |
|
188 | 188 | 5: a 5 |
|
189 | 189 | 6: a 6 |
|
190 | 190 | 7: a 7 |
|
191 | 191 | 8: a 8 |
|
192 | 192 | 9: a 9 |
|
193 | 193 | 10: a 10 |
|
194 | 194 | explicit flags work too: |
|
195 | 195 | $ hg blame --pager=no a |
|
196 | 196 | 0: a |
|
197 | 197 | 1: a 1 |
|
198 | 198 | 2: a 2 |
|
199 | 199 | 3: a 3 |
|
200 | 200 | 4: a 4 |
|
201 | 201 | 5: a 5 |
|
202 | 202 | 6: a 6 |
|
203 | 203 | 7: a 7 |
|
204 | 204 | 8: a 8 |
|
205 | 205 | 9: a 9 |
|
206 | 206 | 10: a 10 |
|
207 | ||
|
208 | Put annotate in the ignore list for pager: | |
|
209 | $ cat >> $HGRCPATH <<EOF | |
|
210 | > [pager] | |
|
211 | > ignore = annotate | |
|
212 | > EOF | |
|
213 | $ hg blame a | |
|
214 | 0: a | |
|
215 | 1: a 1 | |
|
216 | 2: a 2 | |
|
217 | 3: a 3 | |
|
218 | 4: a 4 | |
|
219 | 5: a 5 | |
|
220 | 6: a 6 | |
|
221 | 7: a 7 | |
|
222 | 8: a 8 | |
|
223 | 9: a 9 | |
|
224 | 10: a 10 |
General Comments 0
You need to be logged in to leave comments.
Login now