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