Show More
@@ -1,203 +1,205 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 | $ cp $HGRCPATH.orig $HGRCPATH |
|
18 | $ cp $HGRCPATH.orig $HGRCPATH | |
19 |
|
19 | |||
20 | long socket path |
|
20 | long socket path | |
21 |
|
21 | |||
22 | $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket |
|
22 | $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket | |
23 | $ mkdir -p $sockpath |
|
23 | $ mkdir -p $sockpath | |
24 | $ bakchgsockname=$CHGSOCKNAME |
|
24 | $ bakchgsockname=$CHGSOCKNAME | |
25 | $ CHGSOCKNAME=$sockpath/server |
|
25 | $ CHGSOCKNAME=$sockpath/server | |
26 | $ export CHGSOCKNAME |
|
26 | $ export CHGSOCKNAME | |
27 | $ chg root |
|
27 | $ chg root | |
28 | $TESTTMP/foo |
|
28 | $TESTTMP/foo | |
29 | $ rm -rf $sockpath |
|
29 | $ rm -rf $sockpath | |
30 | $ CHGSOCKNAME=$bakchgsockname |
|
30 | $ CHGSOCKNAME=$bakchgsockname | |
31 | $ export CHGSOCKNAME |
|
31 | $ export CHGSOCKNAME | |
32 |
|
32 | |||
33 | $ cd .. |
|
33 | $ cd .. | |
34 |
|
34 | |||
35 | editor |
|
35 | editor | |
36 | ------ |
|
36 | ------ | |
37 |
|
37 | |||
38 | $ cat >> pushbuffer.py <<EOF |
|
38 | $ cat >> pushbuffer.py <<EOF | |
39 | > def reposetup(ui, repo): |
|
39 | > def reposetup(ui, repo): | |
40 | > repo.ui.pushbuffer(subproc=True) |
|
40 | > repo.ui.pushbuffer(subproc=True) | |
41 | > EOF |
|
41 | > EOF | |
42 |
|
42 | |||
43 | $ chg init editor |
|
43 | $ chg init editor | |
44 | $ cd editor |
|
44 | $ cd editor | |
45 |
|
45 | |||
46 | by default, system() should be redirected to the client: |
|
46 | by default, system() should be redirected to the client: | |
47 |
|
47 | |||
48 | $ touch foo |
|
48 | $ touch foo | |
49 | $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \ |
|
49 | $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \ | |
50 | > | egrep "HG:|run 'cat" |
|
50 | > | egrep "HG:|run 'cat" | |
51 | chg: debug: run 'cat "*"' at '$TESTTMP/editor' (glob) |
|
51 | chg: debug: run 'cat "*"' at '$TESTTMP/editor' (glob) | |
52 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
52 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
53 | HG: Leave message empty to abort commit. |
|
53 | HG: Leave message empty to abort commit. | |
54 | HG: -- |
|
54 | HG: -- | |
55 | HG: user: test |
|
55 | HG: user: test | |
56 | HG: branch 'default' |
|
56 | HG: branch 'default' | |
57 | HG: added foo |
|
57 | HG: added foo | |
58 |
|
58 | |||
59 | but no redirection should be made if output is captured: |
|
59 | but no redirection should be made if output is captured: | |
60 |
|
60 | |||
61 | $ touch bar |
|
61 | $ touch bar | |
62 | $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \ |
|
62 | $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \ | |
63 | > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \ |
|
63 | > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \ | |
64 | > | egrep "HG:|run 'cat" |
|
64 | > | egrep "HG:|run 'cat" | |
65 | [1] |
|
65 | [1] | |
66 |
|
66 | |||
67 | check that commit commands succeeded: |
|
67 | check that commit commands succeeded: | |
68 |
|
68 | |||
69 | $ hg log -T '{rev}:{desc}\n' |
|
69 | $ hg log -T '{rev}:{desc}\n' | |
70 | 1:bufferred |
|
70 | 1:bufferred | |
71 | 0:channeled |
|
71 | 0:channeled | |
72 |
|
72 | |||
73 | $ cd .. |
|
73 | $ cd .. | |
74 |
|
74 | |||
75 | pager |
|
75 | pager | |
76 | ----- |
|
76 | ----- | |
77 |
|
77 | |||
78 | $ cat >> fakepager.py <<EOF |
|
78 | $ cat >> fakepager.py <<EOF | |
79 | > import sys |
|
79 | > import sys | |
80 | > for line in sys.stdin: |
|
80 | > for line in sys.stdin: | |
81 | > sys.stdout.write('paged! %r\n' % line) |
|
81 | > sys.stdout.write('paged! %r\n' % line) | |
82 | > EOF |
|
82 | > EOF | |
83 |
|
83 | |||
84 | enable pager extension globally, but spawns the master server with no tty: |
|
84 | enable pager extension globally, but spawns the master server with no tty: | |
85 |
|
85 | |||
86 | $ chg init pager |
|
86 | $ chg init pager | |
87 | $ cd pager |
|
87 | $ cd pager | |
88 | $ cat >> $HGRCPATH <<EOF |
|
88 | $ cat >> $HGRCPATH <<EOF | |
89 | > [extensions] |
|
89 | > [extensions] | |
90 | > pager = |
|
90 | > pager = | |
91 | > [pager] |
|
91 | > [pager] | |
92 | > pager = $PYTHON $TESTTMP/fakepager.py |
|
92 | > pager = $PYTHON $TESTTMP/fakepager.py | |
93 | > EOF |
|
93 | > EOF | |
94 | $ chg version > /dev/null |
|
94 | $ chg version > /dev/null | |
95 | $ touch foo |
|
95 | $ touch foo | |
96 | $ chg ci -qAm foo |
|
96 | $ chg ci -qAm foo | |
97 |
|
97 | |||
98 | pager should be enabled if the attached client has a tty: |
|
98 | pager should be enabled if the attached client has a tty: | |
99 |
|
99 | |||
100 | $ chg log -l1 -q --config ui.formatted=True |
|
100 | $ chg log -l1 -q --config ui.formatted=True | |
101 | paged! '0:1f7b0de80e11\n' |
|
101 | paged! '0:1f7b0de80e11\n' | |
102 | $ chg log -l1 -q --config ui.formatted=False |
|
102 | $ chg log -l1 -q --config ui.formatted=False | |
103 | 0:1f7b0de80e11 |
|
103 | 0:1f7b0de80e11 | |
104 |
|
104 | |||
105 | chg waits for pager if runcommand raises |
|
105 | chg waits for pager if runcommand raises | |
106 |
|
106 | |||
107 | $ cat > $TESTTMP/crash.py <<EOF |
|
107 | $ cat > $TESTTMP/crash.py <<EOF | |
108 | > from mercurial import registrar |
|
108 | > from mercurial import registrar | |
109 | > cmdtable = {} |
|
109 | > cmdtable = {} | |
110 | > command = registrar.command(cmdtable) |
|
110 | > command = registrar.command(cmdtable) | |
111 | > @command(b'crash') |
|
111 | > @command(b'crash') | |
112 | > def pagercrash(ui, repo, *pats, **opts): |
|
112 | > def pagercrash(ui, repo, *pats, **opts): | |
113 | > ui.write('going to crash\n') |
|
113 | > ui.write('going to crash\n') | |
114 | > raise Exception('.') |
|
114 | > raise Exception('.') | |
115 | > EOF |
|
115 | > EOF | |
116 |
|
116 | |||
117 | $ cat > $TESTTMP/fakepager.py <<EOF |
|
117 | $ cat > $TESTTMP/fakepager.py <<EOF | |
118 | > import sys, time |
|
118 | > from __future__ import absolute_import | |
|
119 | > import sys | |||
|
120 | > import time | |||
119 | > for line in iter(sys.stdin.readline, ''): |
|
121 | > for line in iter(sys.stdin.readline, ''): | |
120 | > if 'crash' in line: # only interested in lines containing 'crash' |
|
122 | > if 'crash' in line: # only interested in lines containing 'crash' | |
121 | > # if chg exits when pager is sleeping (incorrectly), the output |
|
123 | > # if chg exits when pager is sleeping (incorrectly), the output | |
122 | > # will be captured by the next test case |
|
124 | > # will be captured by the next test case | |
123 | > time.sleep(1) |
|
125 | > time.sleep(1) | |
124 | > sys.stdout.write('crash-pager: %s' % line) |
|
126 | > sys.stdout.write('crash-pager: %s' % line) | |
125 | > EOF |
|
127 | > EOF | |
126 |
|
128 | |||
127 | $ cat >> .hg/hgrc <<EOF |
|
129 | $ cat >> .hg/hgrc <<EOF | |
128 | > [extensions] |
|
130 | > [extensions] | |
129 | > crash = $TESTTMP/crash.py |
|
131 | > crash = $TESTTMP/crash.py | |
130 | > EOF |
|
132 | > EOF | |
131 |
|
133 | |||
132 | $ chg crash --pager=on --config ui.formatted=True 2>/dev/null |
|
134 | $ chg crash --pager=on --config ui.formatted=True 2>/dev/null | |
133 | crash-pager: going to crash |
|
135 | crash-pager: going to crash | |
134 | [255] |
|
136 | [255] | |
135 |
|
137 | |||
136 | $ cd .. |
|
138 | $ cd .. | |
137 |
|
139 | |||
138 | server lifecycle |
|
140 | server lifecycle | |
139 | ---------------- |
|
141 | ---------------- | |
140 |
|
142 | |||
141 | chg server should be restarted on code change, and old server will shut down |
|
143 | chg server should be restarted on code change, and old server will shut down | |
142 | automatically. In this test, we use the following time parameters: |
|
144 | automatically. In this test, we use the following time parameters: | |
143 |
|
145 | |||
144 | - "sleep 1" to make mtime different |
|
146 | - "sleep 1" to make mtime different | |
145 | - "sleep 2" to notice mtime change (polling interval is 1 sec) |
|
147 | - "sleep 2" to notice mtime change (polling interval is 1 sec) | |
146 |
|
148 | |||
147 | set up repository with an extension: |
|
149 | set up repository with an extension: | |
148 |
|
150 | |||
149 | $ chg init extreload |
|
151 | $ chg init extreload | |
150 | $ cd extreload |
|
152 | $ cd extreload | |
151 | $ touch dummyext.py |
|
153 | $ touch dummyext.py | |
152 | $ cat <<EOF >> .hg/hgrc |
|
154 | $ cat <<EOF >> .hg/hgrc | |
153 | > [extensions] |
|
155 | > [extensions] | |
154 | > dummyext = dummyext.py |
|
156 | > dummyext = dummyext.py | |
155 | > EOF |
|
157 | > EOF | |
156 |
|
158 | |||
157 | isolate socket directory for stable result: |
|
159 | isolate socket directory for stable result: | |
158 |
|
160 | |||
159 | $ OLDCHGSOCKNAME=$CHGSOCKNAME |
|
161 | $ OLDCHGSOCKNAME=$CHGSOCKNAME | |
160 | $ mkdir chgsock |
|
162 | $ mkdir chgsock | |
161 | $ CHGSOCKNAME=`pwd`/chgsock/server |
|
163 | $ CHGSOCKNAME=`pwd`/chgsock/server | |
162 |
|
164 | |||
163 | warm up server: |
|
165 | warm up server: | |
164 |
|
166 | |||
165 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
167 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' | |
166 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
|
168 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) | |
167 |
|
169 | |||
168 | new server should be started if extension modified: |
|
170 | new server should be started if extension modified: | |
169 |
|
171 | |||
170 | $ sleep 1 |
|
172 | $ sleep 1 | |
171 | $ touch dummyext.py |
|
173 | $ touch dummyext.py | |
172 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
174 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' | |
173 | chg: debug: instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob) |
|
175 | chg: debug: instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob) | |
174 | chg: debug: instruction: reconnect |
|
176 | chg: debug: instruction: reconnect | |
175 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
|
177 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) | |
176 |
|
178 | |||
177 | old server will shut down, while new server should still be reachable: |
|
179 | old server will shut down, while new server should still be reachable: | |
178 |
|
180 | |||
179 | $ sleep 2 |
|
181 | $ sleep 2 | |
180 | $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true) |
|
182 | $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true) | |
181 |
|
183 | |||
182 | socket file should never be unlinked by old server: |
|
184 | socket file should never be unlinked by old server: | |
183 | (simulates unowned socket by updating mtime, which makes sure server exits |
|
185 | (simulates unowned socket by updating mtime, which makes sure server exits | |
184 | at polling cycle) |
|
186 | at polling cycle) | |
185 |
|
187 | |||
186 | $ ls chgsock/server-* |
|
188 | $ ls chgsock/server-* | |
187 | chgsock/server-* (glob) |
|
189 | chgsock/server-* (glob) | |
188 | $ touch chgsock/server-* |
|
190 | $ touch chgsock/server-* | |
189 | $ sleep 2 |
|
191 | $ sleep 2 | |
190 | $ ls chgsock/server-* |
|
192 | $ ls chgsock/server-* | |
191 | chgsock/server-* (glob) |
|
193 | chgsock/server-* (glob) | |
192 |
|
194 | |||
193 | since no server is reachable from socket file, new server should be started: |
|
195 | since no server is reachable from socket file, new server should be started: | |
194 | (this test makes sure that old server shut down automatically) |
|
196 | (this test makes sure that old server shut down automatically) | |
195 |
|
197 | |||
196 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
198 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' | |
197 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
|
199 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) | |
198 |
|
200 | |||
199 | shut down servers and restore environment: |
|
201 | shut down servers and restore environment: | |
200 |
|
202 | |||
201 | $ rm -R chgsock |
|
203 | $ rm -R chgsock | |
202 | $ CHGSOCKNAME=$OLDCHGSOCKNAME |
|
204 | $ CHGSOCKNAME=$OLDCHGSOCKNAME | |
203 | $ cd .. |
|
205 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now