Show More
@@ -1,383 +1,395 b'' | |||||
1 | $ cat >> fakepager.py <<EOF |
|
1 | $ cat >> fakepager.py <<EOF | |
2 | > import sys |
|
2 | > import sys | |
3 | > printed = False |
|
3 | > printed = False | |
4 | > for line in sys.stdin: |
|
4 | > for line in sys.stdin: | |
5 | > sys.stdout.write('paged! %r\n' % line) |
|
5 | > sys.stdout.write('paged! %r\n' % line) | |
6 | > printed = True |
|
6 | > printed = True | |
7 | > if not printed: |
|
7 | > if not printed: | |
8 | > sys.stdout.write('paged empty output!\n') |
|
8 | > sys.stdout.write('paged empty output!\n') | |
9 | > EOF |
|
9 | > EOF | |
10 |
|
10 | |||
11 | Enable ui.formatted because pager won't fire without it, and set up |
|
11 | Enable ui.formatted because pager won't fire without it, and set up | |
12 | pager and tell it to use our fake pager that lets us see when the |
|
12 | pager and tell it to use our fake pager that lets us see when the | |
13 | pager was running. |
|
13 | pager was running. | |
14 | $ cat >> $HGRCPATH <<EOF |
|
14 | $ cat >> $HGRCPATH <<EOF | |
15 | > [ui] |
|
15 | > [ui] | |
16 | > formatted = yes |
|
16 | > formatted = yes | |
17 | > color = no |
|
17 | > color = no | |
18 | > [pager] |
|
18 | > [pager] | |
19 | > pager = $PYTHON $TESTTMP/fakepager.py |
|
19 | > pager = $PYTHON $TESTTMP/fakepager.py | |
20 | > EOF |
|
20 | > EOF | |
21 |
|
21 | |||
22 | $ hg init repo |
|
22 | $ hg init repo | |
23 | $ cd repo |
|
23 | $ cd repo | |
24 | $ echo a >> a |
|
24 | $ echo a >> a | |
25 | $ hg add a |
|
25 | $ hg add a | |
26 | $ hg ci -m 'add a' |
|
26 | $ hg ci -m 'add a' | |
27 | $ for x in `$PYTHON $TESTDIR/seq.py 1 10`; do |
|
27 | $ for x in `$PYTHON $TESTDIR/seq.py 1 10`; do | |
28 | > echo a $x >> a |
|
28 | > echo a $x >> a | |
29 | > hg ci -m "modify a $x" |
|
29 | > hg ci -m "modify a $x" | |
30 | > done |
|
30 | > done | |
31 |
|
31 | |||
32 | By default diff and log are paged, but id is not: |
|
32 | By default diff and log are paged, but id is not: | |
33 |
|
33 | |||
34 | $ hg diff -c 2 --pager=yes |
|
34 | $ hg diff -c 2 --pager=yes | |
35 | paged! 'diff -r f4be7687d414 -r bce265549556 a\n' |
|
35 | paged! 'diff -r f4be7687d414 -r bce265549556 a\n' | |
36 | paged! '--- a/a\tThu Jan 01 00:00:00 1970 +0000\n' |
|
36 | paged! '--- a/a\tThu Jan 01 00:00:00 1970 +0000\n' | |
37 | paged! '+++ b/a\tThu Jan 01 00:00:00 1970 +0000\n' |
|
37 | paged! '+++ b/a\tThu Jan 01 00:00:00 1970 +0000\n' | |
38 | paged! '@@ -1,2 +1,3 @@\n' |
|
38 | paged! '@@ -1,2 +1,3 @@\n' | |
39 | paged! ' a\n' |
|
39 | paged! ' a\n' | |
40 | paged! ' a 1\n' |
|
40 | paged! ' a 1\n' | |
41 | paged! '+a 2\n' |
|
41 | paged! '+a 2\n' | |
42 |
|
42 | |||
43 | $ hg log --limit 2 |
|
43 | $ hg log --limit 2 | |
44 | paged! 'changeset: 10:46106edeeb38\n' |
|
44 | paged! 'changeset: 10:46106edeeb38\n' | |
45 | paged! 'tag: tip\n' |
|
45 | paged! 'tag: tip\n' | |
46 | paged! 'user: test\n' |
|
46 | paged! 'user: test\n' | |
47 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
47 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
48 | paged! 'summary: modify a 10\n' |
|
48 | paged! 'summary: modify a 10\n' | |
49 | paged! '\n' |
|
49 | paged! '\n' | |
50 | paged! 'changeset: 9:6dd8ea7dd621\n' |
|
50 | paged! 'changeset: 9:6dd8ea7dd621\n' | |
51 | paged! 'user: test\n' |
|
51 | paged! 'user: test\n' | |
52 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
52 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
53 | paged! 'summary: modify a 9\n' |
|
53 | paged! 'summary: modify a 9\n' | |
54 | paged! '\n' |
|
54 | paged! '\n' | |
55 |
|
55 | |||
56 | $ hg id |
|
56 | $ hg id | |
57 | 46106edeeb38 tip |
|
57 | 46106edeeb38 tip | |
58 |
|
58 | |||
59 | We can control the pager from the config |
|
59 | We can control the pager from the config | |
60 |
|
60 | |||
61 | $ hg log --limit 1 --config 'ui.paginate=False' |
|
61 | $ hg log --limit 1 --config 'ui.paginate=False' | |
62 | changeset: 10:46106edeeb38 |
|
62 | changeset: 10:46106edeeb38 | |
63 | tag: tip |
|
63 | tag: tip | |
64 | user: test |
|
64 | user: test | |
65 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
65 | date: Thu Jan 01 00:00:00 1970 +0000 | |
66 | summary: modify a 10 |
|
66 | summary: modify a 10 | |
67 |
|
67 | |||
68 | $ hg log --limit 1 --config 'ui.paginate=0' |
|
68 | $ hg log --limit 1 --config 'ui.paginate=0' | |
69 | changeset: 10:46106edeeb38 |
|
69 | changeset: 10:46106edeeb38 | |
70 | tag: tip |
|
70 | tag: tip | |
71 | user: test |
|
71 | user: test | |
72 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
72 | date: Thu Jan 01 00:00:00 1970 +0000 | |
73 | summary: modify a 10 |
|
73 | summary: modify a 10 | |
74 |
|
74 | |||
75 | $ hg log --limit 1 --config 'ui.paginate=1' |
|
75 | $ hg log --limit 1 --config 'ui.paginate=1' | |
76 | paged! 'changeset: 10:46106edeeb38\n' |
|
76 | paged! 'changeset: 10:46106edeeb38\n' | |
77 | paged! 'tag: tip\n' |
|
77 | paged! 'tag: tip\n' | |
78 | paged! 'user: test\n' |
|
78 | paged! 'user: test\n' | |
79 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
79 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
80 | paged! 'summary: modify a 10\n' |
|
80 | paged! 'summary: modify a 10\n' | |
81 | paged! '\n' |
|
81 | paged! '\n' | |
82 |
|
82 | |||
83 | explicit --pager=on should take precedence over other configurations |
|
83 | explicit --pager=on should take precedence over other configurations | |
84 | (issue5580) |
|
84 | (issue5580) | |
85 |
|
85 | |||
86 | $ cat >> $HGRCPATH <<EOF |
|
86 | $ cat >> $HGRCPATH <<EOF | |
87 | > [ui] |
|
87 | > [ui] | |
88 | > paginate = false |
|
88 | > paginate = false | |
89 | > EOF |
|
89 | > EOF | |
90 | $ hg log --limit 1 --pager=on |
|
90 | $ hg log --limit 1 --pager=on | |
91 | paged! 'changeset: 10:46106edeeb38\n' |
|
91 | paged! 'changeset: 10:46106edeeb38\n' | |
92 | paged! 'tag: tip\n' |
|
92 | paged! 'tag: tip\n' | |
93 | paged! 'user: test\n' |
|
93 | paged! 'user: test\n' | |
94 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
94 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
95 | paged! 'summary: modify a 10\n' |
|
95 | paged! 'summary: modify a 10\n' | |
96 | paged! '\n' |
|
96 | paged! '\n' | |
97 |
|
97 | |||
98 | $ cat >> $HGRCPATH <<EOF |
|
98 | $ cat >> $HGRCPATH <<EOF | |
99 | > [ui] |
|
99 | > [ui] | |
100 | > # true is default value of ui.paginate |
|
100 | > # true is default value of ui.paginate | |
101 | > paginate = true |
|
101 | > paginate = true | |
102 | > EOF |
|
102 | > EOF | |
103 | $ hg log --limit 1 --pager=off |
|
103 | $ hg log --limit 1 --pager=off | |
104 | changeset: 10:46106edeeb38 |
|
104 | changeset: 10:46106edeeb38 | |
105 | tag: tip |
|
105 | tag: tip | |
106 | user: test |
|
106 | user: test | |
107 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
107 | date: Thu Jan 01 00:00:00 1970 +0000 | |
108 | summary: modify a 10 |
|
108 | summary: modify a 10 | |
109 |
|
109 | |||
110 |
|
110 | |||
111 | We can enable the pager on id: |
|
111 | We can enable the pager on id: | |
112 |
|
112 | |||
113 | BROKEN: should be paged |
|
113 | BROKEN: should be paged | |
114 | $ hg --config pager.attend-id=yes id |
|
114 | $ hg --config pager.attend-id=yes id | |
115 | 46106edeeb38 tip |
|
115 | 46106edeeb38 tip | |
116 |
|
116 | |||
117 | Setting attend-$COMMAND to a false value works, even with pager in |
|
117 | Setting attend-$COMMAND to a false value works, even with pager in | |
118 | core: |
|
118 | core: | |
119 | $ hg --config pager.attend-diff=no diff -c 2 |
|
119 | $ hg --config pager.attend-diff=no diff -c 2 | |
120 | diff -r f4be7687d414 -r bce265549556 a |
|
120 | diff -r f4be7687d414 -r bce265549556 a | |
121 | --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
121 | --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
122 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
122 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
123 | @@ -1,2 +1,3 @@ |
|
123 | @@ -1,2 +1,3 @@ | |
124 | a |
|
124 | a | |
125 | a 1 |
|
125 | a 1 | |
126 | +a 2 |
|
126 | +a 2 | |
127 |
|
127 | |||
128 | Command aliases should have same behavior as main command |
|
128 | Command aliases should have same behavior as main command | |
129 |
|
129 | |||
130 | $ hg history --limit 2 |
|
130 | $ hg history --limit 2 | |
131 | paged! 'changeset: 10:46106edeeb38\n' |
|
131 | paged! 'changeset: 10:46106edeeb38\n' | |
132 | paged! 'tag: tip\n' |
|
132 | paged! 'tag: tip\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 10\n' |
|
135 | paged! 'summary: modify a 10\n' | |
136 | paged! '\n' |
|
136 | paged! '\n' | |
137 | paged! 'changeset: 9:6dd8ea7dd621\n' |
|
137 | paged! 'changeset: 9:6dd8ea7dd621\n' | |
138 | paged! 'user: test\n' |
|
138 | paged! 'user: test\n' | |
139 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
139 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
140 | paged! 'summary: modify a 9\n' |
|
140 | paged! 'summary: modify a 9\n' | |
141 | paged! '\n' |
|
141 | paged! '\n' | |
142 |
|
142 | |||
143 | Abbreviated command alias should also be paged |
|
143 | Abbreviated command alias should also be paged | |
144 |
|
144 | |||
145 | $ hg hist -l 1 |
|
145 | $ hg hist -l 1 | |
146 | paged! 'changeset: 10:46106edeeb38\n' |
|
146 | paged! 'changeset: 10:46106edeeb38\n' | |
147 | paged! 'tag: tip\n' |
|
147 | paged! 'tag: tip\n' | |
148 | paged! 'user: test\n' |
|
148 | paged! 'user: test\n' | |
149 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
149 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
150 | paged! 'summary: modify a 10\n' |
|
150 | paged! 'summary: modify a 10\n' | |
151 | paged! '\n' |
|
151 | paged! '\n' | |
152 |
|
152 | |||
153 | Attend for an abbreviated command does not work |
|
153 | Attend for an abbreviated command does not work | |
154 |
|
154 | |||
155 | $ hg --config pager.attend-ident=true ident |
|
155 | $ hg --config pager.attend-ident=true ident | |
156 | 46106edeeb38 tip |
|
156 | 46106edeeb38 tip | |
157 |
|
157 | |||
158 | $ hg --config extensions.pager= --config pager.attend-ident=true ident |
|
158 | $ hg --config extensions.pager= --config pager.attend-ident=true ident | |
159 | 46106edeeb38 tip |
|
159 | 46106edeeb38 tip | |
160 |
|
160 | |||
161 | Pager should not start if stdout is not a tty. |
|
161 | Pager should not start if stdout is not a tty. | |
162 |
|
162 | |||
163 | $ hg log -l1 -q --config ui.formatted=False |
|
163 | $ hg log -l1 -q --config ui.formatted=False | |
164 | 10:46106edeeb38 |
|
164 | 10:46106edeeb38 | |
165 |
|
165 | |||
166 | Pager should be disabled if pager.pager is empty (otherwise the output would |
|
166 | Pager should be disabled if pager.pager is empty (otherwise the output would | |
167 | be silently lost.) |
|
167 | be silently lost.) | |
168 |
|
168 | |||
169 | $ hg log -l1 -q --config pager.pager= |
|
169 | $ hg log -l1 -q --config pager.pager= | |
170 | 10:46106edeeb38 |
|
170 | 10:46106edeeb38 | |
171 |
|
171 | |||
172 | Pager with color enabled allows colors to come through by default, |
|
172 | Pager with color enabled allows colors to come through by default, | |
173 | even though stdout is no longer a tty. |
|
173 | even though stdout is no longer a tty. | |
174 | $ cat >> $HGRCPATH <<EOF |
|
174 | $ cat >> $HGRCPATH <<EOF | |
175 | > [ui] |
|
175 | > [ui] | |
176 | > color = always |
|
176 | > color = always | |
177 | > [color] |
|
177 | > [color] | |
178 | > mode = ansi |
|
178 | > mode = ansi | |
179 | > EOF |
|
179 | > EOF | |
180 | $ hg log --limit 3 |
|
180 | $ hg log --limit 3 | |
181 | paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n' |
|
181 | paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n' | |
182 | paged! 'tag: tip\n' |
|
182 | paged! 'tag: tip\n' | |
183 | paged! 'user: test\n' |
|
183 | paged! 'user: test\n' | |
184 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
184 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
185 | paged! 'summary: modify a 10\n' |
|
185 | paged! 'summary: modify a 10\n' | |
186 | paged! '\n' |
|
186 | paged! '\n' | |
187 | paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n' |
|
187 | paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n' | |
188 | paged! 'user: test\n' |
|
188 | paged! 'user: test\n' | |
189 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
189 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
190 | paged! 'summary: modify a 9\n' |
|
190 | paged! 'summary: modify a 9\n' | |
191 | paged! '\n' |
|
191 | paged! '\n' | |
192 | paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n' |
|
192 | paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n' | |
193 | paged! 'user: test\n' |
|
193 | paged! 'user: test\n' | |
194 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
|
194 | paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
195 | paged! 'summary: modify a 8\n' |
|
195 | paged! 'summary: modify a 8\n' | |
196 | paged! '\n' |
|
196 | paged! '\n' | |
197 |
|
197 | |||
|
198 | #if no-chg | |||
198 | An invalid pager command name is reported sensibly if we don't have to |
|
199 | An invalid pager command name is reported sensibly if we don't have to | |
199 | use shell=True in the subprocess call: |
|
200 | use shell=True in the subprocess call: | |
200 | $ hg log --limit 3 --config pager.pager=this-command-better-never-exist |
|
201 | $ hg log --limit 3 --config pager.pager=this-command-better-never-exist | |
201 | missing pager command 'this-command-better-never-exist', skipping pager |
|
202 | missing pager command 'this-command-better-never-exist', skipping pager | |
202 | \x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m (esc) |
|
203 | \x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m (esc) | |
203 | tag: tip |
|
204 | tag: tip | |
204 | user: test |
|
205 | user: test | |
205 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
206 | date: Thu Jan 01 00:00:00 1970 +0000 | |
206 | summary: modify a 10 |
|
207 | summary: modify a 10 | |
207 |
|
208 | |||
208 | \x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m (esc) |
|
209 | \x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m (esc) | |
209 | user: test |
|
210 | user: test | |
210 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
211 | date: Thu Jan 01 00:00:00 1970 +0000 | |
211 | summary: modify a 9 |
|
212 | summary: modify a 9 | |
212 |
|
213 | |||
213 | \x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m (esc) |
|
214 | \x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m (esc) | |
214 | user: test |
|
215 | user: test | |
215 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
216 | date: Thu Jan 01 00:00:00 1970 +0000 | |
216 | summary: modify a 8 |
|
217 | summary: modify a 8 | |
217 |
|
218 | |||
|
219 | #else | |||
|
220 | Currently, chg has its own runpager implementation, which does not show the | |||
|
221 | "missing pager" message. The error message is globed out since the shell could | |||
|
222 | print different message. | |||
|
223 | $ hg log --limit 3 --config pager.pager=this-command-better-never-exist | |||
|
224 | /bin/sh: this-command-better-never-exist: command not found (?) | |||
|
225 | * (glob) (?) | |||
|
226 | killed! | |||
|
227 | [255] | |||
|
228 | ||||
|
229 | #endif | |||
218 |
|
230 | |||
219 | A complicated pager command gets worse behavior. Bonus points if you can |
|
231 | A complicated pager command gets worse behavior. Bonus points if you can | |
220 | improve this. |
|
232 | improve this. | |
221 | $ hg log --limit 3 \ |
|
233 | $ hg log --limit 3 \ | |
222 | > --config pager.pager='this-command-better-never-exist --seriously' \ |
|
234 | > --config pager.pager='this-command-better-never-exist --seriously' \ | |
223 | > 2>/dev/null || true |
|
235 | > 2>/dev/null || true | |
224 |
|
236 | |||
225 | Pager works with shell aliases. |
|
237 | Pager works with shell aliases. | |
226 |
|
238 | |||
227 | $ cat >> $HGRCPATH <<EOF |
|
239 | $ cat >> $HGRCPATH <<EOF | |
228 | > [alias] |
|
240 | > [alias] | |
229 | > echoa = !echo a |
|
241 | > echoa = !echo a | |
230 | > EOF |
|
242 | > EOF | |
231 |
|
243 | |||
232 | $ hg echoa |
|
244 | $ hg echoa | |
233 | a |
|
245 | a | |
234 | BROKEN: should be paged |
|
246 | BROKEN: should be paged | |
235 | $ hg --config pager.attend-echoa=yes echoa |
|
247 | $ hg --config pager.attend-echoa=yes echoa | |
236 | a |
|
248 | a | |
237 |
|
249 | |||
238 | Pager works with hg aliases including environment variables. |
|
250 | Pager works with hg aliases including environment variables. | |
239 |
|
251 | |||
240 | $ cat >> $HGRCPATH <<'EOF' |
|
252 | $ cat >> $HGRCPATH <<'EOF' | |
241 | > [alias] |
|
253 | > [alias] | |
242 | > printa = log -T "$A\n" -r 0 |
|
254 | > printa = log -T "$A\n" -r 0 | |
243 | > EOF |
|
255 | > EOF | |
244 |
|
256 | |||
245 | $ A=1 hg --config pager.attend-printa=yes printa |
|
257 | $ A=1 hg --config pager.attend-printa=yes printa | |
246 | paged! '1\n' |
|
258 | paged! '1\n' | |
247 | $ A=2 hg --config pager.attend-printa=yes printa |
|
259 | $ A=2 hg --config pager.attend-printa=yes printa | |
248 | paged! '2\n' |
|
260 | paged! '2\n' | |
249 |
|
261 | |||
250 | Something that's explicitly attended is still not paginated if the |
|
262 | Something that's explicitly attended is still not paginated if the | |
251 | pager is globally set to off using a flag: |
|
263 | pager is globally set to off using a flag: | |
252 | $ A=2 hg --config pager.attend-printa=yes printa --pager=no |
|
264 | $ A=2 hg --config pager.attend-printa=yes printa --pager=no | |
253 | 2 |
|
265 | 2 | |
254 |
|
266 | |||
255 | Pager should not override the exit code of other commands |
|
267 | Pager should not override the exit code of other commands | |
256 |
|
268 | |||
257 | $ cat >> $TESTTMP/fortytwo.py <<'EOF' |
|
269 | $ cat >> $TESTTMP/fortytwo.py <<'EOF' | |
258 | > from mercurial import commands, registrar |
|
270 | > from mercurial import commands, registrar | |
259 | > cmdtable = {} |
|
271 | > cmdtable = {} | |
260 | > command = registrar.command(cmdtable) |
|
272 | > command = registrar.command(cmdtable) | |
261 | > @command(b'fortytwo', [], 'fortytwo', norepo=True) |
|
273 | > @command(b'fortytwo', [], 'fortytwo', norepo=True) | |
262 | > def fortytwo(ui, *opts): |
|
274 | > def fortytwo(ui, *opts): | |
263 | > ui.write('42\n') |
|
275 | > ui.write('42\n') | |
264 | > return 42 |
|
276 | > return 42 | |
265 | > EOF |
|
277 | > EOF | |
266 |
|
278 | |||
267 | $ cat >> $HGRCPATH <<'EOF' |
|
279 | $ cat >> $HGRCPATH <<'EOF' | |
268 | > [extensions] |
|
280 | > [extensions] | |
269 | > fortytwo = $TESTTMP/fortytwo.py |
|
281 | > fortytwo = $TESTTMP/fortytwo.py | |
270 | > EOF |
|
282 | > EOF | |
271 |
|
283 | |||
272 | $ hg fortytwo --pager=on |
|
284 | $ hg fortytwo --pager=on | |
273 | paged! '42\n' |
|
285 | paged! '42\n' | |
274 | [42] |
|
286 | [42] | |
275 |
|
287 | |||
276 | A command that asks for paging using ui.pager() directly works: |
|
288 | A command that asks for paging using ui.pager() directly works: | |
277 | $ hg blame a |
|
289 | $ hg blame a | |
278 | paged! ' 0: a\n' |
|
290 | paged! ' 0: a\n' | |
279 | paged! ' 1: a 1\n' |
|
291 | paged! ' 1: a 1\n' | |
280 | paged! ' 2: a 2\n' |
|
292 | paged! ' 2: a 2\n' | |
281 | paged! ' 3: a 3\n' |
|
293 | paged! ' 3: a 3\n' | |
282 | paged! ' 4: a 4\n' |
|
294 | paged! ' 4: a 4\n' | |
283 | paged! ' 5: a 5\n' |
|
295 | paged! ' 5: a 5\n' | |
284 | paged! ' 6: a 6\n' |
|
296 | paged! ' 6: a 6\n' | |
285 | paged! ' 7: a 7\n' |
|
297 | paged! ' 7: a 7\n' | |
286 | paged! ' 8: a 8\n' |
|
298 | paged! ' 8: a 8\n' | |
287 | paged! ' 9: a 9\n' |
|
299 | paged! ' 9: a 9\n' | |
288 | paged! '10: a 10\n' |
|
300 | paged! '10: a 10\n' | |
289 | but not with HGPLAIN |
|
301 | but not with HGPLAIN | |
290 | $ HGPLAIN=1 hg blame a |
|
302 | $ HGPLAIN=1 hg blame a | |
291 | 0: a |
|
303 | 0: a | |
292 | 1: a 1 |
|
304 | 1: a 1 | |
293 | 2: a 2 |
|
305 | 2: a 2 | |
294 | 3: a 3 |
|
306 | 3: a 3 | |
295 | 4: a 4 |
|
307 | 4: a 4 | |
296 | 5: a 5 |
|
308 | 5: a 5 | |
297 | 6: a 6 |
|
309 | 6: a 6 | |
298 | 7: a 7 |
|
310 | 7: a 7 | |
299 | 8: a 8 |
|
311 | 8: a 8 | |
300 | 9: a 9 |
|
312 | 9: a 9 | |
301 | 10: a 10 |
|
313 | 10: a 10 | |
302 | explicit flags work too: |
|
314 | explicit flags work too: | |
303 | $ hg blame --pager=no a |
|
315 | $ hg blame --pager=no a | |
304 | 0: a |
|
316 | 0: a | |
305 | 1: a 1 |
|
317 | 1: a 1 | |
306 | 2: a 2 |
|
318 | 2: a 2 | |
307 | 3: a 3 |
|
319 | 3: a 3 | |
308 | 4: a 4 |
|
320 | 4: a 4 | |
309 | 5: a 5 |
|
321 | 5: a 5 | |
310 | 6: a 6 |
|
322 | 6: a 6 | |
311 | 7: a 7 |
|
323 | 7: a 7 | |
312 | 8: a 8 |
|
324 | 8: a 8 | |
313 | 9: a 9 |
|
325 | 9: a 9 | |
314 | 10: a 10 |
|
326 | 10: a 10 | |
315 |
|
327 | |||
316 | A command with --output option: |
|
328 | A command with --output option: | |
317 |
|
329 | |||
318 | $ hg cat -r0 a |
|
330 | $ hg cat -r0 a | |
319 | paged! 'a\n' |
|
331 | paged! 'a\n' | |
320 | $ hg cat -r0 a --output=- |
|
332 | $ hg cat -r0 a --output=- | |
321 | paged! 'a\n' |
|
333 | paged! 'a\n' | |
322 | $ hg cat -r0 a --output=out |
|
334 | $ hg cat -r0 a --output=out | |
323 | $ rm out |
|
335 | $ rm out | |
324 |
|
336 | |||
325 | Put annotate in the ignore list for pager: |
|
337 | Put annotate in the ignore list for pager: | |
326 | $ cat >> $HGRCPATH <<EOF |
|
338 | $ cat >> $HGRCPATH <<EOF | |
327 | > [pager] |
|
339 | > [pager] | |
328 | > ignore = annotate |
|
340 | > ignore = annotate | |
329 | > EOF |
|
341 | > EOF | |
330 | $ hg blame a |
|
342 | $ hg blame a | |
331 | 0: a |
|
343 | 0: a | |
332 | 1: a 1 |
|
344 | 1: a 1 | |
333 | 2: a 2 |
|
345 | 2: a 2 | |
334 | 3: a 3 |
|
346 | 3: a 3 | |
335 | 4: a 4 |
|
347 | 4: a 4 | |
336 | 5: a 5 |
|
348 | 5: a 5 | |
337 | 6: a 6 |
|
349 | 6: a 6 | |
338 | 7: a 7 |
|
350 | 7: a 7 | |
339 | 8: a 8 |
|
351 | 8: a 8 | |
340 | 9: a 9 |
|
352 | 9: a 9 | |
341 | 10: a 10 |
|
353 | 10: a 10 | |
342 |
|
354 | |||
343 | During pushbuffer, pager should not start: |
|
355 | During pushbuffer, pager should not start: | |
344 | $ cat > $TESTTMP/pushbufferpager.py <<EOF |
|
356 | $ cat > $TESTTMP/pushbufferpager.py <<EOF | |
345 | > def uisetup(ui): |
|
357 | > def uisetup(ui): | |
346 | > ui.pushbuffer() |
|
358 | > ui.pushbuffer() | |
347 | > ui.pager('mycmd') |
|
359 | > ui.pager('mycmd') | |
348 | > ui.write('content\n') |
|
360 | > ui.write('content\n') | |
349 | > ui.write(ui.popbuffer()) |
|
361 | > ui.write(ui.popbuffer()) | |
350 | > EOF |
|
362 | > EOF | |
351 |
|
363 | |||
352 | $ echo append >> a |
|
364 | $ echo append >> a | |
353 | $ hg --config extensions.pushbuffer=$TESTTMP/pushbufferpager.py status --color=off |
|
365 | $ hg --config extensions.pushbuffer=$TESTTMP/pushbufferpager.py status --color=off | |
354 | content |
|
366 | content | |
355 | paged! 'M a\n' |
|
367 | paged! 'M a\n' | |
356 |
|
368 | |||
357 | Environment variables like LESS and LV are set automatically: |
|
369 | Environment variables like LESS and LV are set automatically: | |
358 | $ cat > $TESTTMP/printlesslv.py <<EOF |
|
370 | $ cat > $TESTTMP/printlesslv.py <<EOF | |
359 | > from __future__ import absolute_import |
|
371 | > from __future__ import absolute_import | |
360 | > import os |
|
372 | > import os | |
361 | > import sys |
|
373 | > import sys | |
362 | > sys.stdin.read() |
|
374 | > sys.stdin.read() | |
363 | > for name in ['LESS', 'LV']: |
|
375 | > for name in ['LESS', 'LV']: | |
364 | > sys.stdout.write(('%s=%s\n') % (name, os.environ.get(name, '-'))) |
|
376 | > sys.stdout.write(('%s=%s\n') % (name, os.environ.get(name, '-'))) | |
365 | > sys.stdout.flush() |
|
377 | > sys.stdout.flush() | |
366 | > EOF |
|
378 | > EOF | |
367 |
|
379 | |||
368 | $ cat >> $HGRCPATH <<EOF |
|
380 | $ cat >> $HGRCPATH <<EOF | |
369 | > [alias] |
|
381 | > [alias] | |
370 | > noop = log -r 0 -T '' |
|
382 | > noop = log -r 0 -T '' | |
371 | > [ui] |
|
383 | > [ui] | |
372 | > formatted=1 |
|
384 | > formatted=1 | |
373 | > [pager] |
|
385 | > [pager] | |
374 | > pager = $PYTHON $TESTTMP/printlesslv.py |
|
386 | > pager = $PYTHON $TESTTMP/printlesslv.py | |
375 | > EOF |
|
387 | > EOF | |
376 | $ unset LESS |
|
388 | $ unset LESS | |
377 | $ unset LV |
|
389 | $ unset LV | |
378 | $ hg noop --pager=on |
|
390 | $ hg noop --pager=on | |
379 | LESS=FRX |
|
391 | LESS=FRX | |
380 | LV=-c |
|
392 | LV=-c | |
381 | $ LESS=EFGH hg noop --pager=on |
|
393 | $ LESS=EFGH hg noop --pager=on | |
382 | LESS=EFGH |
|
394 | LESS=EFGH | |
383 | LV=-c |
|
395 | LV=-c |
General Comments 0
You need to be logged in to leave comments.
Login now