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