##// END OF EJS Templates
tests: move chg pager test to test-pager.t...
Jun Wu -
r29343:e095b9e7 default
parent child Browse files
Show More
@@ -1,106 +1,86 b''
1 #require chg
1 #require chg
2
2
3 $ cp $HGRCPATH $HGRCPATH.orig
3 $ cp $HGRCPATH $HGRCPATH.orig
4
4
5 init repo
5 init repo
6
6
7 $ chg init foo
7 $ chg init foo
8 $ cd foo
8 $ cd foo
9
9
10 ill-formed config
10 ill-formed config
11
11
12 $ chg status
12 $ chg status
13 $ echo '=brokenconfig' >> $HGRCPATH
13 $ echo '=brokenconfig' >> $HGRCPATH
14 $ chg status
14 $ chg status
15 hg: parse error at * (glob)
15 hg: parse error at * (glob)
16 [255]
16 [255]
17
17
18 alias having an environment variable and set to use pager
19
20 $ rm $HGRCPATH
21 $ cat >> $HGRCPATH <<'EOF'
22 > [ui]
23 > formatted = yes
24 > [extensions]
25 > pager =
26 > [pager]
27 > pager = sed -e 's/^/P/'
28 > attend = printa
29 > [alias]
30 > printa = log -T "$A\n" -r 0
31 > EOF
32
33 $ A=1 chg printa
34 P1
35 $ A=2 chg printa
36 P2
37
38 $ cp $HGRCPATH.orig $HGRCPATH
18 $ cp $HGRCPATH.orig $HGRCPATH
39 $ cd ..
19 $ cd ..
40
20
41 server lifecycle
21 server lifecycle
42 ----------------
22 ----------------
43
23
44 chg server should be restarted on code change, and old server will shut down
24 chg server should be restarted on code change, and old server will shut down
45 automatically. In this test, we use the following time parameters:
25 automatically. In this test, we use the following time parameters:
46
26
47 - "sleep 1" to make mtime different
27 - "sleep 1" to make mtime different
48 - "sleep 2" to notice mtime change (polling interval is 1 sec)
28 - "sleep 2" to notice mtime change (polling interval is 1 sec)
49
29
50 set up repository with an extension:
30 set up repository with an extension:
51
31
52 $ chg init extreload
32 $ chg init extreload
53 $ cd extreload
33 $ cd extreload
54 $ touch dummyext.py
34 $ touch dummyext.py
55 $ cat <<EOF >> .hg/hgrc
35 $ cat <<EOF >> .hg/hgrc
56 > [extensions]
36 > [extensions]
57 > dummyext = dummyext.py
37 > dummyext = dummyext.py
58 > EOF
38 > EOF
59
39
60 isolate socket directory for stable result:
40 isolate socket directory for stable result:
61
41
62 $ OLDCHGSOCKNAME=$CHGSOCKNAME
42 $ OLDCHGSOCKNAME=$CHGSOCKNAME
63 $ mkdir chgsock
43 $ mkdir chgsock
64 $ CHGSOCKNAME=`pwd`/chgsock/server
44 $ CHGSOCKNAME=`pwd`/chgsock/server
65
45
66 warm up server:
46 warm up server:
67
47
68 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
48 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
69 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
49 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
70
50
71 new server should be started if extension modified:
51 new server should be started if extension modified:
72
52
73 $ sleep 1
53 $ sleep 1
74 $ touch dummyext.py
54 $ touch dummyext.py
75 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
55 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
76 chg: debug: instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
56 chg: debug: instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
77 chg: debug: instruction: reconnect
57 chg: debug: instruction: reconnect
78 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
58 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
79
59
80 old server will shut down, while new server should still be reachable:
60 old server will shut down, while new server should still be reachable:
81
61
82 $ sleep 2
62 $ sleep 2
83 $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true)
63 $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true)
84
64
85 socket file should never be unlinked by old server:
65 socket file should never be unlinked by old server:
86 (simulates unowned socket by updating mtime, which makes sure server exits
66 (simulates unowned socket by updating mtime, which makes sure server exits
87 at polling cycle)
67 at polling cycle)
88
68
89 $ ls chgsock/server-*
69 $ ls chgsock/server-*
90 chgsock/server-* (glob)
70 chgsock/server-* (glob)
91 $ touch chgsock/server-*
71 $ touch chgsock/server-*
92 $ sleep 2
72 $ sleep 2
93 $ ls chgsock/server-*
73 $ ls chgsock/server-*
94 chgsock/server-* (glob)
74 chgsock/server-* (glob)
95
75
96 since no server is reachable from socket file, new server should be started:
76 since no server is reachable from socket file, new server should be started:
97 (this test makes sure that old server shut down automatically)
77 (this test makes sure that old server shut down automatically)
98
78
99 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
79 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
100 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
80 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
101
81
102 shut down servers and restore environment:
82 shut down servers and restore environment:
103
83
104 $ rm -R chgsock
84 $ rm -R chgsock
105 $ CHGSOCKNAME=$OLDCHGSOCKNAME
85 $ CHGSOCKNAME=$OLDCHGSOCKNAME
106 $ cd ..
86 $ cd ..
@@ -1,191 +1,203 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 If we completely change the attend list that's respected:
71 If we completely change the attend list that's respected:
72
72
73 $ hg --config pager.attend-diff=no diff -c 2
73 $ hg --config pager.attend-diff=no diff -c 2
74 diff -r f4be7687d414 -r bce265549556 a
74 diff -r f4be7687d414 -r bce265549556 a
75 --- a/a Thu Jan 01 00:00:00 1970 +0000
75 --- a/a Thu Jan 01 00:00:00 1970 +0000
76 +++ b/a Thu Jan 01 00:00:00 1970 +0000
76 +++ b/a Thu Jan 01 00:00:00 1970 +0000
77 @@ -1,2 +1,3 @@
77 @@ -1,2 +1,3 @@
78 a
78 a
79 a 1
79 a 1
80 +a 2
80 +a 2
81
81
82 $ hg --config pager.attend=summary diff -c 2
82 $ hg --config pager.attend=summary diff -c 2
83 diff -r f4be7687d414 -r bce265549556 a
83 diff -r f4be7687d414 -r bce265549556 a
84 --- a/a Thu Jan 01 00:00:00 1970 +0000
84 --- a/a Thu Jan 01 00:00:00 1970 +0000
85 +++ b/a Thu Jan 01 00:00:00 1970 +0000
85 +++ b/a Thu Jan 01 00:00:00 1970 +0000
86 @@ -1,2 +1,3 @@
86 @@ -1,2 +1,3 @@
87 a
87 a
88 a 1
88 a 1
89 +a 2
89 +a 2
90
90
91 If 'log' is in attend, then 'history' should also be paged:
91 If 'log' is in attend, then 'history' should also be paged:
92 $ hg history --limit 2 --config pager.attend=log
92 $ hg history --limit 2 --config pager.attend=log
93 paged! 'changeset: 10:46106edeeb38\n'
93 paged! 'changeset: 10:46106edeeb38\n'
94 paged! 'tag: tip\n'
94 paged! 'tag: tip\n'
95 paged! 'user: test\n'
95 paged! 'user: test\n'
96 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
96 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
97 paged! 'summary: modify a 10\n'
97 paged! 'summary: modify a 10\n'
98 paged! '\n'
98 paged! '\n'
99 paged! 'changeset: 9:6dd8ea7dd621\n'
99 paged! 'changeset: 9:6dd8ea7dd621\n'
100 paged! 'user: test\n'
100 paged! 'user: test\n'
101 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
101 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
102 paged! 'summary: modify a 9\n'
102 paged! 'summary: modify a 9\n'
103 paged! '\n'
103 paged! '\n'
104
104
105 Possible bug: history is explicitly ignored in pager config, but
105 Possible bug: history is explicitly ignored in pager config, but
106 because log is in the attend list it still gets pager treatment.
106 because log is in the attend list it still gets pager treatment.
107
107
108 $ hg history --limit 2 --config pager.attend=log \
108 $ hg history --limit 2 --config pager.attend=log \
109 > --config pager.ignore=history
109 > --config pager.ignore=history
110 paged! 'changeset: 10:46106edeeb38\n'
110 paged! 'changeset: 10:46106edeeb38\n'
111 paged! 'tag: tip\n'
111 paged! 'tag: tip\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 10\n'
114 paged! 'summary: modify a 10\n'
115 paged! '\n'
115 paged! '\n'
116 paged! 'changeset: 9:6dd8ea7dd621\n'
116 paged! 'changeset: 9:6dd8ea7dd621\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 9\n'
119 paged! 'summary: modify a 9\n'
120 paged! '\n'
120 paged! '\n'
121
121
122 Possible bug: history is explicitly marked as attend-history=no, but
122 Possible bug: history is explicitly marked as attend-history=no, but
123 it doesn't fail to get paged because log is still in the attend list.
123 it doesn't fail to get paged because log is still in the attend list.
124
124
125 $ hg history --limit 2 --config pager.attend-history=no
125 $ hg history --limit 2 --config pager.attend-history=no
126 paged! 'changeset: 10:46106edeeb38\n'
126 paged! 'changeset: 10:46106edeeb38\n'
127 paged! 'tag: tip\n'
127 paged! 'tag: tip\n'
128 paged! 'user: test\n'
128 paged! 'user: test\n'
129 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
129 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
130 paged! 'summary: modify a 10\n'
130 paged! 'summary: modify a 10\n'
131 paged! '\n'
131 paged! '\n'
132 paged! 'changeset: 9:6dd8ea7dd621\n'
132 paged! 'changeset: 9:6dd8ea7dd621\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 9\n'
135 paged! 'summary: modify a 9\n'
136 paged! '\n'
136 paged! '\n'
137
137
138 Possible bug: disabling pager for log but enabling it for history
138 Possible bug: disabling pager for log but enabling it for history
139 doesn't result in history being paged.
139 doesn't result in history being paged.
140
140
141 $ hg history --limit 2 --config pager.attend-log=no \
141 $ hg history --limit 2 --config pager.attend-log=no \
142 > --config pager.attend-history=yes
142 > --config pager.attend-history=yes
143 changeset: 10:46106edeeb38
143 changeset: 10:46106edeeb38
144 tag: tip
144 tag: tip
145 user: test
145 user: test
146 date: Thu Jan 01 00:00:00 1970 +0000
146 date: Thu Jan 01 00:00:00 1970 +0000
147 summary: modify a 10
147 summary: modify a 10
148
148
149 changeset: 9:6dd8ea7dd621
149 changeset: 9:6dd8ea7dd621
150 user: test
150 user: test
151 date: Thu Jan 01 00:00:00 1970 +0000
151 date: Thu Jan 01 00:00:00 1970 +0000
152 summary: modify a 9
152 summary: modify a 9
153
153
154
154
155 Pager with color enabled allows colors to come through by default,
155 Pager with color enabled allows colors to come through by default,
156 even though stdout is no longer a tty.
156 even though stdout is no longer a tty.
157 $ cat >> $HGRCPATH <<EOF
157 $ cat >> $HGRCPATH <<EOF
158 > [extensions]
158 > [extensions]
159 > color=
159 > color=
160 > [color]
160 > [color]
161 > mode = ansi
161 > mode = ansi
162 > EOF
162 > EOF
163 $ hg log --limit 3
163 $ hg log --limit 3
164 paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n'
164 paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n'
165 paged! 'tag: tip\n'
165 paged! 'tag: tip\n'
166 paged! 'user: test\n'
166 paged! 'user: test\n'
167 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
167 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
168 paged! 'summary: modify a 10\n'
168 paged! 'summary: modify a 10\n'
169 paged! '\n'
169 paged! '\n'
170 paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n'
170 paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n'
171 paged! 'user: test\n'
171 paged! 'user: test\n'
172 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
172 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
173 paged! 'summary: modify a 9\n'
173 paged! 'summary: modify a 9\n'
174 paged! '\n'
174 paged! '\n'
175 paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n'
175 paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n'
176 paged! 'user: test\n'
176 paged! 'user: test\n'
177 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
177 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n'
178 paged! 'summary: modify a 8\n'
178 paged! 'summary: modify a 8\n'
179 paged! '\n'
179 paged! '\n'
180
180
181 Pager works with shell aliases.
181 Pager works with shell aliases.
182
182
183 $ cat >> $HGRCPATH <<EOF
183 $ cat >> $HGRCPATH <<EOF
184 > [alias]
184 > [alias]
185 > echoa = !echo a
185 > echoa = !echo a
186 > EOF
186 > EOF
187
187
188 $ hg echoa
188 $ hg echoa
189 a
189 a
190 $ hg --config pager.attend-echoa=yes echoa
190 $ hg --config pager.attend-echoa=yes echoa
191 paged! 'a\n'
191 paged! 'a\n'
192
193 Pager works with hg aliases including environment variables.
194
195 $ cat >> $HGRCPATH <<'EOF'
196 > [alias]
197 > printa = log -T "$A\n" -r 0
198 > EOF
199
200 $ A=1 hg --config pager.attend-printa=yes printa
201 paged! '1\n'
202 $ A=2 hg --config pager.attend-printa=yes printa
203 paged! '2\n'
General Comments 0
You need to be logged in to leave comments. Login now