##// END OF EJS Templates
test-chg: stabilize the log checking...
marmoute -
r52392:8b77ad54 stable
parent child Browse files
Show More
@@ -1,572 +1,575 b''
1 #require chg
1 #require chg
2
2
3 Scale the timeout for the chg-server to the test timeout scaling.
3 Scale the timeout for the chg-server to the test timeout scaling.
4 This is done to reduce the flakiness of this test on heavy load.
4 This is done to reduce the flakiness of this test on heavy load.
5
5
6 $ CHGTIMEOUT=`expr $HGTEST_TIMEOUT / 6`
6 $ CHGTIMEOUT=`expr $HGTEST_TIMEOUT / 6`
7 $ export CHGTIMEOUT
7 $ export CHGTIMEOUT
8
8
9 $ mkdir log
9 $ mkdir log
10 $ cp $HGRCPATH $HGRCPATH.unconfigured
10 $ cp $HGRCPATH $HGRCPATH.unconfigured
11 $ cat <<'EOF' >> $HGRCPATH
11 $ cat <<'EOF' >> $HGRCPATH
12 > [cmdserver]
12 > [cmdserver]
13 > log = $TESTTMP/log/server.log
13 > log = $TESTTMP/log/server.log
14 > max-log-files = 1
14 > max-log-files = 1
15 > max-log-size = 10 kB
15 > max-log-size = 10 kB
16 > EOF
16 > EOF
17 $ cp $HGRCPATH $HGRCPATH.orig
17 $ cp $HGRCPATH $HGRCPATH.orig
18
18
19 $ filterlog () {
19 $ filterlog () {
20 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \
20 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \
21 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \
21 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \
22 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \
22 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \
23 > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \
23 > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \
24 > -e 's!\(pid\)=[0-9]*!\1=...!g' \
24 > -e 's!\(pid\)=[0-9]*!\1=...!g' \
25 > -e 's!\(/server-\)[0-9a-f]*!\1...!g'
25 > -e 's!\(/server-\)[0-9a-f]*!\1...!g'
26 > }
26 > }
27
27
28 init repo
28 init repo
29
29
30 $ chg init foo
30 $ chg init foo
31 $ cd foo
31 $ cd foo
32
32
33 ill-formed config
33 ill-formed config
34
34
35 $ chg status
35 $ chg status
36 $ echo '=brokenconfig' >> $HGRCPATH
36 $ echo '=brokenconfig' >> $HGRCPATH
37 $ chg status
37 $ chg status
38 config error at * =brokenconfig (glob)
38 config error at * =brokenconfig (glob)
39 [30]
39 [30]
40
40
41 $ cp $HGRCPATH.orig $HGRCPATH
41 $ cp $HGRCPATH.orig $HGRCPATH
42
42
43 long socket path
43 long socket path
44
44
45 $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket
45 $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket
46 $ mkdir -p $sockpath
46 $ mkdir -p $sockpath
47 $ bakchgsockname=$CHGSOCKNAME
47 $ bakchgsockname=$CHGSOCKNAME
48 $ CHGSOCKNAME=$sockpath/server
48 $ CHGSOCKNAME=$sockpath/server
49 $ export CHGSOCKNAME
49 $ export CHGSOCKNAME
50 $ chg root
50 $ chg root
51 $TESTTMP/foo
51 $TESTTMP/foo
52 $ rm -rf $sockpath
52 $ rm -rf $sockpath
53 $ CHGSOCKNAME=$bakchgsockname
53 $ CHGSOCKNAME=$bakchgsockname
54 $ export CHGSOCKNAME
54 $ export CHGSOCKNAME
55
55
56 $ cd ..
56 $ cd ..
57
57
58 editor
58 editor
59 ------
59 ------
60
60
61 $ cat >> pushbuffer.py <<EOF
61 $ cat >> pushbuffer.py <<EOF
62 > def reposetup(ui, repo):
62 > def reposetup(ui, repo):
63 > repo.ui.pushbuffer(subproc=True)
63 > repo.ui.pushbuffer(subproc=True)
64 > EOF
64 > EOF
65
65
66 $ chg init editor
66 $ chg init editor
67 $ cd editor
67 $ cd editor
68
68
69 by default, system() should be redirected to the client:
69 by default, system() should be redirected to the client:
70
70
71 $ touch foo
71 $ touch foo
72 $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \
72 $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \
73 > | grep -E "HG:|run 'cat"
73 > | grep -E "HG:|run 'cat"
74 chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob)
74 chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob)
75 HG: Enter commit message. Lines beginning with 'HG:' are removed.
75 HG: Enter commit message. Lines beginning with 'HG:' are removed.
76 HG: Leave message empty to abort commit.
76 HG: Leave message empty to abort commit.
77 HG: --
77 HG: --
78 HG: user: test
78 HG: user: test
79 HG: branch 'default'
79 HG: branch 'default'
80 HG: added foo
80 HG: added foo
81
81
82 but no redirection should be made if output is captured:
82 but no redirection should be made if output is captured:
83
83
84 $ touch bar
84 $ touch bar
85 $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \
85 $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \
86 > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \
86 > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \
87 > | grep -E "HG:|run 'cat"
87 > | grep -E "HG:|run 'cat"
88 [1]
88 [1]
89
89
90 check that commit commands succeeded:
90 check that commit commands succeeded:
91
91
92 $ hg log -T '{rev}:{desc}\n'
92 $ hg log -T '{rev}:{desc}\n'
93 1:bufferred
93 1:bufferred
94 0:channeled
94 0:channeled
95
95
96 $ cd ..
96 $ cd ..
97
97
98 pager
98 pager
99 -----
99 -----
100
100
101 $ cat >> fakepager.py <<EOF
101 $ cat >> fakepager.py <<EOF
102 > import sys
102 > import sys
103 > for line in sys.stdin:
103 > for line in sys.stdin:
104 > sys.stdout.write('paged! %r\n' % line)
104 > sys.stdout.write('paged! %r\n' % line)
105 > EOF
105 > EOF
106
106
107 enable pager extension globally, but spawns the master server with no tty:
107 enable pager extension globally, but spawns the master server with no tty:
108
108
109 $ chg init pager
109 $ chg init pager
110 $ cd pager
110 $ cd pager
111 $ cat >> $HGRCPATH <<EOF
111 $ cat >> $HGRCPATH <<EOF
112 > [extensions]
112 > [extensions]
113 > pager =
113 > pager =
114 > [pager]
114 > [pager]
115 > pager = "$PYTHON" $TESTTMP/fakepager.py
115 > pager = "$PYTHON" $TESTTMP/fakepager.py
116 > EOF
116 > EOF
117 $ chg version > /dev/null
117 $ chg version > /dev/null
118 $ touch foo
118 $ touch foo
119 $ chg ci -qAm foo
119 $ chg ci -qAm foo
120
120
121 pager should be enabled if the attached client has a tty:
121 pager should be enabled if the attached client has a tty:
122
122
123 $ chg log -l1 -q --config ui.formatted=True
123 $ chg log -l1 -q --config ui.formatted=True
124 paged! '0:1f7b0de80e11\n'
124 paged! '0:1f7b0de80e11\n'
125 $ chg log -l1 -q --config ui.formatted=False
125 $ chg log -l1 -q --config ui.formatted=False
126 0:1f7b0de80e11
126 0:1f7b0de80e11
127
127
128 chg waits for pager if runcommand raises
128 chg waits for pager if runcommand raises
129
129
130 $ cat > $TESTTMP/crash.py <<EOF
130 $ cat > $TESTTMP/crash.py <<EOF
131 > from mercurial import registrar
131 > from mercurial import registrar
132 > cmdtable = {}
132 > cmdtable = {}
133 > command = registrar.command(cmdtable)
133 > command = registrar.command(cmdtable)
134 > @command(b'crash')
134 > @command(b'crash')
135 > def pagercrash(ui, repo, *pats, **opts):
135 > def pagercrash(ui, repo, *pats, **opts):
136 > ui.write(b'going to crash\n')
136 > ui.write(b'going to crash\n')
137 > raise Exception('.')
137 > raise Exception('.')
138 > EOF
138 > EOF
139
139
140 $ cat > $TESTTMP/fakepager.py <<EOF
140 $ cat > $TESTTMP/fakepager.py <<EOF
141 > import sys
141 > import sys
142 > import time
142 > import time
143 > for line in iter(sys.stdin.readline, ''):
143 > for line in iter(sys.stdin.readline, ''):
144 > if 'crash' in line: # only interested in lines containing 'crash'
144 > if 'crash' in line: # only interested in lines containing 'crash'
145 > # if chg exits when pager is sleeping (incorrectly), the output
145 > # if chg exits when pager is sleeping (incorrectly), the output
146 > # will be captured by the next test case
146 > # will be captured by the next test case
147 > time.sleep(1)
147 > time.sleep(1)
148 > sys.stdout.write('crash-pager: %s' % line)
148 > sys.stdout.write('crash-pager: %s' % line)
149 > EOF
149 > EOF
150
150
151 $ cat >> .hg/hgrc <<EOF
151 $ cat >> .hg/hgrc <<EOF
152 > [extensions]
152 > [extensions]
153 > crash = $TESTTMP/crash.py
153 > crash = $TESTTMP/crash.py
154 > EOF
154 > EOF
155
155
156 $ chg crash --pager=on --config ui.formatted=True 2>/dev/null
156 $ chg crash --pager=on --config ui.formatted=True 2>/dev/null
157 crash-pager: going to crash
157 crash-pager: going to crash
158 [255]
158 [255]
159
159
160 no stdout data should be printed after pager quits, and the buffered data
160 no stdout data should be printed after pager quits, and the buffered data
161 should never persist (issue6207)
161 should never persist (issue6207)
162
162
163 "killed!" may be printed if terminated by SIGPIPE, which isn't important
163 "killed!" may be printed if terminated by SIGPIPE, which isn't important
164 in this test.
164 in this test.
165
165
166 $ cat > $TESTTMP/bulkwrite.py <<'EOF'
166 $ cat > $TESTTMP/bulkwrite.py <<'EOF'
167 > import time
167 > import time
168 > from mercurial import error, registrar
168 > from mercurial import error, registrar
169 > cmdtable = {}
169 > cmdtable = {}
170 > command = registrar.command(cmdtable)
170 > command = registrar.command(cmdtable)
171 > @command(b'bulkwrite')
171 > @command(b'bulkwrite')
172 > def bulkwrite(ui, repo, *pats, **opts):
172 > def bulkwrite(ui, repo, *pats, **opts):
173 > ui.write(b'going to write massive data\n')
173 > ui.write(b'going to write massive data\n')
174 > ui.flush()
174 > ui.flush()
175 > t = time.time()
175 > t = time.time()
176 > while time.time() - t < 2:
176 > while time.time() - t < 2:
177 > ui.write(b'x' * 1023 + b'\n') # will be interrupted by SIGPIPE
177 > ui.write(b'x' * 1023 + b'\n') # will be interrupted by SIGPIPE
178 > raise error.Abort(b"write() doesn't block")
178 > raise error.Abort(b"write() doesn't block")
179 > EOF
179 > EOF
180
180
181 $ cat > $TESTTMP/fakepager.py <<'EOF'
181 $ cat > $TESTTMP/fakepager.py <<'EOF'
182 > import sys
182 > import sys
183 > import time
183 > import time
184 > sys.stdout.write('paged! %r\n' % sys.stdin.readline())
184 > sys.stdout.write('paged! %r\n' % sys.stdin.readline())
185 > time.sleep(1) # new data will be written
185 > time.sleep(1) # new data will be written
186 > EOF
186 > EOF
187
187
188 $ cat >> .hg/hgrc <<EOF
188 $ cat >> .hg/hgrc <<EOF
189 > [extensions]
189 > [extensions]
190 > bulkwrite = $TESTTMP/bulkwrite.py
190 > bulkwrite = $TESTTMP/bulkwrite.py
191 > EOF
191 > EOF
192
192
193 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
193 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
194 paged! 'going to write massive data\n'
194 paged! 'going to write massive data\n'
195 killed! (?)
195 killed! (?)
196 [255]
196 [255]
197
197
198 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
198 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
199 paged! 'going to write massive data\n'
199 paged! 'going to write massive data\n'
200 killed! (?)
200 killed! (?)
201 [255]
201 [255]
202
202
203 $ cd ..
203 $ cd ..
204
204
205 missing stdio
205 missing stdio
206 -------------
206 -------------
207
207
208 $ CHGDEBUG=1 chg version -q 0<&-
208 $ CHGDEBUG=1 chg version -q 0<&-
209 chg: debug: * stdio fds are missing (glob)
209 chg: debug: * stdio fds are missing (glob)
210 chg: debug: * execute original hg (glob)
210 chg: debug: * execute original hg (glob)
211 Mercurial Distributed SCM * (glob)
211 Mercurial Distributed SCM * (glob)
212
212
213 server lifecycle
213 server lifecycle
214 ----------------
214 ----------------
215
215
216 chg server should be restarted on code change, and old server will shut down
216 chg server should be restarted on code change, and old server will shut down
217 automatically. In this test, we use the following time parameters:
217 automatically. In this test, we use the following time parameters:
218
218
219 - "sleep 1" to make mtime different
219 - "sleep 1" to make mtime different
220 - "sleep 2" to notice mtime change (polling interval is 1 sec)
220 - "sleep 2" to notice mtime change (polling interval is 1 sec)
221
221
222 set up repository with an extension:
222 set up repository with an extension:
223
223
224 $ chg init extreload
224 $ chg init extreload
225 $ cd extreload
225 $ cd extreload
226 $ touch dummyext.py
226 $ touch dummyext.py
227 $ cat <<EOF >> .hg/hgrc
227 $ cat <<EOF >> .hg/hgrc
228 > [extensions]
228 > [extensions]
229 > dummyext = dummyext.py
229 > dummyext = dummyext.py
230 > EOF
230 > EOF
231
231
232 isolate socket directory for stable result:
232 isolate socket directory for stable result:
233
233
234 $ OLDCHGSOCKNAME=$CHGSOCKNAME
234 $ OLDCHGSOCKNAME=$CHGSOCKNAME
235 $ mkdir chgsock
235 $ mkdir chgsock
236 $ CHGSOCKNAME=`pwd`/chgsock/server
236 $ CHGSOCKNAME=`pwd`/chgsock/server
237
237
238 warm up server:
238 warm up server:
239
239
240 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
240 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
241 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
241 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
242
242
243 new server should be started if extension modified:
243 new server should be started if extension modified:
244
244
245 $ sleep 1
245 $ sleep 1
246 $ touch dummyext.py
246 $ touch dummyext.py
247 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
247 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
248 chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
248 chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
249 chg: debug: * instruction: reconnect (glob)
249 chg: debug: * instruction: reconnect (glob)
250 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
250 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
251
251
252 old server will shut down, while new server should still be reachable:
252 old server will shut down, while new server should still be reachable:
253
253
254 $ sleep 2
254 $ sleep 2
255 $ CHGDEBUG= chg log 2>&1 | (grep -E 'instruction|start' || true)
255 $ CHGDEBUG= chg log 2>&1 | (grep -E 'instruction|start' || true)
256
256
257 socket file should never be unlinked by old server:
257 socket file should never be unlinked by old server:
258 (simulates unowned socket by updating mtime, which makes sure server exits
258 (simulates unowned socket by updating mtime, which makes sure server exits
259 at polling cycle)
259 at polling cycle)
260
260
261 $ ls chgsock/server-*
261 $ ls chgsock/server-*
262 chgsock/server-* (glob)
262 chgsock/server-* (glob)
263 $ touch chgsock/server-*
263 $ touch chgsock/server-*
264 $ sleep 2
264 $ sleep 2
265 $ ls chgsock/server-*
265 $ ls chgsock/server-*
266 chgsock/server-* (glob)
266 chgsock/server-* (glob)
267
267
268 since no server is reachable from socket file, new server should be started:
268 since no server is reachable from socket file, new server should be started:
269 (this test makes sure that old server shut down automatically)
269 (this test makes sure that old server shut down automatically)
270
270
271 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
271 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
272 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
272 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
273
273
274 shut down servers and restore environment:
274 shut down servers and restore environment:
275
275
276 $ rm -R chgsock
276 $ rm -R chgsock
277 $ sleep 2
277 $ sleep 2
278 $ CHGSOCKNAME=$OLDCHGSOCKNAME
278 $ CHGSOCKNAME=$OLDCHGSOCKNAME
279 $ cd ..
279 $ cd ..
280
280
281 check that server events are recorded:
281 check that server events are recorded:
282
282
283 $ ls log
283 $ ls log
284 server.log
284 server.log
285 server.log.1
285 server.log.1
286
286
287 print only the last 10 lines, since we aren't sure how many records are
287 print only the last 10 lines, since we aren't sure how many records are
288 preserved (since setprocname isn't available on py3 and pure version,
288 preserved (since setprocname isn't available on py3 and pure version,
289 the 10th-most-recent line is different when using py3):
289 the 10th-most-recent line is different when using py3):
290
290
291 $ cat log/server.log.1 log/server.log | tail -10 | filterlog
291 (the "worker process exited" line is matched independently as it order is unstable with the "exiting" line, the worker might exit before the server decide to exit).
292
293 $ cat log/server.log.1 log/server.log | tail -10 | grep -v "worker process exited" | filterlog
292 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... (no-setprocname !)
294 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... (no-setprocname !)
293 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
295 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
294 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... (setprocname !)
296 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... (setprocname !)
295 YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
297 YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
296 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
298 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
297 YYYY/MM/DD HH:MM:SS (PID)> setumask 18
299 YYYY/MM/DD HH:MM:SS (PID)> setumask 18
298 YYYY/MM/DD HH:MM:SS (PID)> setenv: ...
300 YYYY/MM/DD HH:MM:SS (PID)> setenv: ...
299 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
301 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
300 YYYY/MM/DD HH:MM:SS (PID)> validate: []
302 YYYY/MM/DD HH:MM:SS (PID)> validate: []
303 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
304 $ cat log/server.log.1 log/server.log | tail -10 | grep "worker process exited" | filterlog
301 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
305 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
302 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
303
306
304 global data mutated by schems
307 global data mutated by schems
305 -----------------------------
308 -----------------------------
306
309
307 $ hg init schemes
310 $ hg init schemes
308 $ cd schemes
311 $ cd schemes
309
312
310 initial state
313 initial state
311
314
312 $ cat > .hg/hgrc <<'EOF'
315 $ cat > .hg/hgrc <<'EOF'
313 > [extensions]
316 > [extensions]
314 > schemes =
317 > schemes =
315 > [schemes]
318 > [schemes]
316 > foo = https://foo.example.org/
319 > foo = https://foo.example.org/
317 > EOF
320 > EOF
318 $ hg debugexpandscheme foo://expanded
321 $ hg debugexpandscheme foo://expanded
319 https://foo.example.org/expanded
322 https://foo.example.org/expanded
320 $ hg debugexpandscheme bar://unexpanded
323 $ hg debugexpandscheme bar://unexpanded
321 bar://unexpanded
324 bar://unexpanded
322
325
323 add bar
326 add bar
324
327
325 $ cat > .hg/hgrc <<'EOF'
328 $ cat > .hg/hgrc <<'EOF'
326 > [extensions]
329 > [extensions]
327 > schemes =
330 > schemes =
328 > [schemes]
331 > [schemes]
329 > foo = https://foo.example.org/
332 > foo = https://foo.example.org/
330 > bar = https://bar.example.org/
333 > bar = https://bar.example.org/
331 > EOF
334 > EOF
332 $ hg debugexpandscheme foo://expanded
335 $ hg debugexpandscheme foo://expanded
333 https://foo.example.org/expanded
336 https://foo.example.org/expanded
334 $ hg debugexpandscheme bar://expanded
337 $ hg debugexpandscheme bar://expanded
335 https://bar.example.org/expanded
338 https://bar.example.org/expanded
336
339
337 remove foo
340 remove foo
338
341
339 $ cat > .hg/hgrc <<'EOF'
342 $ cat > .hg/hgrc <<'EOF'
340 > [extensions]
343 > [extensions]
341 > schemes =
344 > schemes =
342 > [schemes]
345 > [schemes]
343 > bar = https://bar.example.org/
346 > bar = https://bar.example.org/
344 > EOF
347 > EOF
345 $ hg debugexpandscheme foo://unexpanded
348 $ hg debugexpandscheme foo://unexpanded
346 foo://unexpanded
349 foo://unexpanded
347 $ hg debugexpandscheme bar://expanded
350 $ hg debugexpandscheme bar://expanded
348 https://bar.example.org/expanded
351 https://bar.example.org/expanded
349
352
350 $ cd ..
353 $ cd ..
351
354
352 repository cache
355 repository cache
353 ----------------
356 ----------------
354
357
355 $ cp $HGRCPATH.unconfigured $HGRCPATH
358 $ cp $HGRCPATH.unconfigured $HGRCPATH
356 $ cat <<'EOF' >> $HGRCPATH
359 $ cat <<'EOF' >> $HGRCPATH
357 > [cmdserver]
360 > [cmdserver]
358 > log = $TESTTMP/log/server-cached.log
361 > log = $TESTTMP/log/server-cached.log
359 > max-repo-cache = 1
362 > max-repo-cache = 1
360 > track-log = command, repocache
363 > track-log = command, repocache
361 > EOF
364 > EOF
362
365
363 isolate socket directory for stable result:
366 isolate socket directory for stable result:
364
367
365 $ OLDCHGSOCKNAME=$CHGSOCKNAME
368 $ OLDCHGSOCKNAME=$CHGSOCKNAME
366 $ mkdir chgsock
369 $ mkdir chgsock
367 $ CHGSOCKNAME=`pwd`/chgsock/server
370 $ CHGSOCKNAME=`pwd`/chgsock/server
368
371
369 create empty repo and cache it:
372 create empty repo and cache it:
370
373
371 $ hg init cached
374 $ hg init cached
372 $ hg id -R cached
375 $ hg id -R cached
373 000000000000 tip
376 000000000000 tip
374 $ sleep 1
377 $ sleep 1
375
378
376 modify repo (and cache will be invalidated):
379 modify repo (and cache will be invalidated):
377
380
378 $ touch cached/a
381 $ touch cached/a
379 $ hg ci -R cached -Am 'add a'
382 $ hg ci -R cached -Am 'add a'
380 adding a
383 adding a
381 $ sleep 1
384 $ sleep 1
382
385
383 read cached repo:
386 read cached repo:
384
387
385 $ hg log -R cached
388 $ hg log -R cached
386 changeset: 0:ac82d8b1f7c4
389 changeset: 0:ac82d8b1f7c4
387 tag: tip
390 tag: tip
388 user: test
391 user: test
389 date: Thu Jan 01 00:00:00 1970 +0000
392 date: Thu Jan 01 00:00:00 1970 +0000
390 summary: add a
393 summary: add a
391
394
392 $ sleep 1
395 $ sleep 1
393
396
394 discard cached from LRU cache:
397 discard cached from LRU cache:
395
398
396 $ hg clone cached cached2
399 $ hg clone cached cached2
397 updating to branch default
400 updating to branch default
398 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
401 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
399 $ hg id -R cached2
402 $ hg id -R cached2
400 ac82d8b1f7c4 tip
403 ac82d8b1f7c4 tip
401 $ sleep 1
404 $ sleep 1
402
405
403 read uncached repo:
406 read uncached repo:
404
407
405 $ hg log -R cached
408 $ hg log -R cached
406 changeset: 0:ac82d8b1f7c4
409 changeset: 0:ac82d8b1f7c4
407 tag: tip
410 tag: tip
408 user: test
411 user: test
409 date: Thu Jan 01 00:00:00 1970 +0000
412 date: Thu Jan 01 00:00:00 1970 +0000
410 summary: add a
413 summary: add a
411
414
412 $ sleep 1
415 $ sleep 1
413
416
414 shut down servers and restore environment:
417 shut down servers and restore environment:
415
418
416 $ rm -R chgsock
419 $ rm -R chgsock
417 $ sleep 2
420 $ sleep 2
418 $ CHGSOCKNAME=$OLDCHGSOCKNAME
421 $ CHGSOCKNAME=$OLDCHGSOCKNAME
419
422
420 check server log:
423 check server log:
421
424
422 $ cat log/server-cached.log | filterlog
425 $ cat log/server-cached.log | filterlog
423 YYYY/MM/DD HH:MM:SS (PID)> init cached
426 YYYY/MM/DD HH:MM:SS (PID)> init cached
424 YYYY/MM/DD HH:MM:SS (PID)> id -R cached
427 YYYY/MM/DD HH:MM:SS (PID)> id -R cached
425 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
428 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
426 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
429 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
427 YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am 'add a'
430 YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am 'add a'
428 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
431 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
429 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
432 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
430 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
433 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
431 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
434 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
432 YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2
435 YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2
433 YYYY/MM/DD HH:MM:SS (PID)> id -R cached2
436 YYYY/MM/DD HH:MM:SS (PID)> id -R cached2
434 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s)
437 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s)
435 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
438 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
436 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
439 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
437
440
438 Test that -R is interpreted relative to --cwd.
441 Test that -R is interpreted relative to --cwd.
439
442
440 $ hg init repo1
443 $ hg init repo1
441 $ mkdir -p a/b
444 $ mkdir -p a/b
442 $ hg init a/b/repo2
445 $ hg init a/b/repo2
443 $ printf "[alias]\ntest=repo1\n" >> repo1/.hg/hgrc
446 $ printf "[alias]\ntest=repo1\n" >> repo1/.hg/hgrc
444 $ printf "[alias]\ntest=repo2\n" >> a/b/repo2/.hg/hgrc
447 $ printf "[alias]\ntest=repo2\n" >> a/b/repo2/.hg/hgrc
445 $ cd a
448 $ cd a
446 $ chg --cwd .. -R repo1 show alias.test
449 $ chg --cwd .. -R repo1 show alias.test
447 repo1
450 repo1
448 $ chg --cwd . -R b/repo2 show alias.test
451 $ chg --cwd . -R b/repo2 show alias.test
449 repo2
452 repo2
450 $ cd ..
453 $ cd ..
451
454
452 Test that chg works (sets to the user's actual LC_CTYPE) even when python
455 Test that chg works (sets to the user's actual LC_CTYPE) even when python
453 "coerces" the locale (py3.7+)
456 "coerces" the locale (py3.7+)
454
457
455 $ cat > $TESTTMP/debugenv.py <<EOF
458 $ cat > $TESTTMP/debugenv.py <<EOF
456 > from mercurial import encoding
459 > from mercurial import encoding
457 > from mercurial import registrar
460 > from mercurial import registrar
458 > cmdtable = {}
461 > cmdtable = {}
459 > command = registrar.command(cmdtable)
462 > command = registrar.command(cmdtable)
460 > @command(b'debugenv', [], b'', norepo=True)
463 > @command(b'debugenv', [], b'', norepo=True)
461 > def debugenv(ui):
464 > def debugenv(ui):
462 > for k in [b'LC_ALL', b'LC_CTYPE', b'LANG']:
465 > for k in [b'LC_ALL', b'LC_CTYPE', b'LANG']:
463 > v = encoding.environ.get(k)
466 > v = encoding.environ.get(k)
464 > if v is not None:
467 > if v is not None:
465 > ui.write(b'%s=%s\n' % (k, encoding.environ[k]))
468 > ui.write(b'%s=%s\n' % (k, encoding.environ[k]))
466 > EOF
469 > EOF
467 (hg keeps python's modified LC_CTYPE, chg doesn't)
470 (hg keeps python's modified LC_CTYPE, chg doesn't)
468 $ (unset LC_ALL; unset LANG; LC_CTYPE= "$CHGHG" \
471 $ (unset LC_ALL; unset LANG; LC_CTYPE= "$CHGHG" \
469 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
472 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
470 LC_CTYPE=C.UTF-8 (py37 !)
473 LC_CTYPE=C.UTF-8 (py37 !)
471 LC_CTYPE= (no-py37 !)
474 LC_CTYPE= (no-py37 !)
472 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
475 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
473 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
476 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
474 LC_CTYPE=
477 LC_CTYPE=
475 $ (unset LC_ALL; unset LANG; LC_CTYPE=unsupported_value chg \
478 $ (unset LC_ALL; unset LANG; LC_CTYPE=unsupported_value chg \
476 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
479 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
477 *cannot change locale* (glob) (?)
480 *cannot change locale* (glob) (?)
478 LC_CTYPE=unsupported_value
481 LC_CTYPE=unsupported_value
479 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
482 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
480 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
483 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
481 LC_CTYPE=
484 LC_CTYPE=
482 $ LANG= LC_ALL= LC_CTYPE= chg \
485 $ LANG= LC_ALL= LC_CTYPE= chg \
483 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv
486 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv
484 LC_ALL=
487 LC_ALL=
485 LC_CTYPE=
488 LC_CTYPE=
486 LANG=
489 LANG=
487
490
488 Profiling isn't permanently enabled or carried over between chg invocations that
491 Profiling isn't permanently enabled or carried over between chg invocations that
489 share the same server
492 share the same server
490 $ cp $HGRCPATH.orig $HGRCPATH
493 $ cp $HGRCPATH.orig $HGRCPATH
491 $ hg init $TESTTMP/profiling
494 $ hg init $TESTTMP/profiling
492 $ cd $TESTTMP/profiling
495 $ cd $TESTTMP/profiling
493 $ filteredchg() {
496 $ filteredchg() {
494 > CHGDEBUG=1 chg "$@" 2>&1 | sed -rn 's_^No samples recorded.*$_Sample count: 0_; /Sample count/p; /start cmdserver/p'
497 > CHGDEBUG=1 chg "$@" 2>&1 | sed -rn 's_^No samples recorded.*$_Sample count: 0_; /Sample count/p; /start cmdserver/p'
495 > }
498 > }
496 $ newchg() {
499 $ newchg() {
497 > chg --kill-chg-daemon
500 > chg --kill-chg-daemon
498 > filteredchg "$@" | grep -E -v 'start cmdserver' || true
501 > filteredchg "$@" | grep -E -v 'start cmdserver' || true
499 > }
502 > }
500 (--profile isn't permanently on just because it was specified when chg was
503 (--profile isn't permanently on just because it was specified when chg was
501 started)
504 started)
502 $ newchg log -r . --profile
505 $ newchg log -r . --profile
503 Sample count: * (glob)
506 Sample count: * (glob)
504 $ filteredchg log -r .
507 $ filteredchg log -r .
505 (enabling profiling via config works, even on the first chg command that starts
508 (enabling profiling via config works, even on the first chg command that starts
506 a cmdserver)
509 a cmdserver)
507 $ cat >> $HGRCPATH <<EOF
510 $ cat >> $HGRCPATH <<EOF
508 > [profiling]
511 > [profiling]
509 > type=stat
512 > type=stat
510 > enabled=1
513 > enabled=1
511 > EOF
514 > EOF
512 $ newchg log -r .
515 $ newchg log -r .
513 Sample count: * (glob)
516 Sample count: * (glob)
514 $ filteredchg log -r .
517 $ filteredchg log -r .
515 Sample count: * (glob)
518 Sample count: * (glob)
516 (test that we aren't accumulating more and more samples each run)
519 (test that we aren't accumulating more and more samples each run)
517 $ cat > $TESTTMP/debugsleep.py <<EOF
520 $ cat > $TESTTMP/debugsleep.py <<EOF
518 > import time
521 > import time
519 > from mercurial import registrar
522 > from mercurial import registrar
520 > cmdtable = {}
523 > cmdtable = {}
521 > command = registrar.command(cmdtable)
524 > command = registrar.command(cmdtable)
522 > @command(b'debugsleep', [], b'', norepo=True)
525 > @command(b'debugsleep', [], b'', norepo=True)
523 > def debugsleep(ui):
526 > def debugsleep(ui):
524 > start = time.time()
527 > start = time.time()
525 > x = 0
528 > x = 0
526 > while time.time() < start + 0.5:
529 > while time.time() < start + 0.5:
527 > time.sleep(.1)
530 > time.sleep(.1)
528 > x += 1
531 > x += 1
529 > ui.status(b'%d debugsleep iterations in %.03fs\n' % (x, time.time() - start))
532 > ui.status(b'%d debugsleep iterations in %.03fs\n' % (x, time.time() - start))
530 > EOF
533 > EOF
531 $ cat >> $HGRCPATH <<EOF
534 $ cat >> $HGRCPATH <<EOF
532 > [extensions]
535 > [extensions]
533 > debugsleep = $TESTTMP/debugsleep.py
536 > debugsleep = $TESTTMP/debugsleep.py
534 > EOF
537 > EOF
535 $ newchg debugsleep > run_1
538 $ newchg debugsleep > run_1
536 $ filteredchg debugsleep > run_2
539 $ filteredchg debugsleep > run_2
537 $ filteredchg debugsleep > run_3
540 $ filteredchg debugsleep > run_3
538 $ filteredchg debugsleep > run_4
541 $ filteredchg debugsleep > run_4
539 FIXME: Run 4 should not be >3x Run 1's number of samples.
542 FIXME: Run 4 should not be >3x Run 1's number of samples.
540 $ "$PYTHON" <<EOF
543 $ "$PYTHON" <<EOF
541 > r1 = int(open("run_1", "r").read().split()[-1])
544 > r1 = int(open("run_1", "r").read().split()[-1])
542 > r4 = int(open("run_4", "r").read().split()[-1])
545 > r4 = int(open("run_4", "r").read().split()[-1])
543 > print("Run 1: %d samples\nRun 4: %d samples\nRun 4 > 3 * Run 1: %s" %
546 > print("Run 1: %d samples\nRun 4: %d samples\nRun 4 > 3 * Run 1: %s" %
544 > (r1, r4, r4 > (r1 * 3)))
547 > (r1, r4, r4 > (r1 * 3)))
545 > EOF
548 > EOF
546 Run 1: * samples (glob)
549 Run 1: * samples (glob)
547 Run 4: * samples (glob)
550 Run 4: * samples (glob)
548 Run 4 > 3 * Run 1: False
551 Run 4 > 3 * Run 1: False
549 (Disabling with --no-profile on the commandline still works, but isn't permanent)
552 (Disabling with --no-profile on the commandline still works, but isn't permanent)
550 $ newchg log -r . --no-profile
553 $ newchg log -r . --no-profile
551 $ filteredchg log -r .
554 $ filteredchg log -r .
552 Sample count: * (glob)
555 Sample count: * (glob)
553 $ filteredchg log -r . --no-profile
556 $ filteredchg log -r . --no-profile
554 $ filteredchg log -r .
557 $ filteredchg log -r .
555 Sample count: * (glob)
558 Sample count: * (glob)
556
559
557 chg setting CHGHG itself
560 chg setting CHGHG itself
558 ------------------------
561 ------------------------
559
562
560 If CHGHG is not set, chg will set it before spawning the command server.
563 If CHGHG is not set, chg will set it before spawning the command server.
561 $ hg --kill-chg-daemon
564 $ hg --kill-chg-daemon
562 $ HG=$CHGHG CHGHG= CHGDEBUG= hg debugshell -c \
565 $ HG=$CHGHG CHGHG= CHGDEBUG= hg debugshell -c \
563 > 'ui.write(b"CHGHG=%s\n" % ui.environ.get(b"CHGHG"))' 2>&1 \
566 > 'ui.write(b"CHGHG=%s\n" % ui.environ.get(b"CHGHG"))' 2>&1 \
564 > | grep -E 'CHGHG|start cmdserver'
567 > | grep -E 'CHGHG|start cmdserver'
565 chg: debug: * start cmdserver at * (glob)
568 chg: debug: * start cmdserver at * (glob)
566 CHGHG=/*/install/bin/hg (glob)
569 CHGHG=/*/install/bin/hg (glob)
567
570
568 Running the same command a second time shouldn't spawn a new command server.
571 Running the same command a second time shouldn't spawn a new command server.
569 $ HG=$CHGHG CHGHG= CHGDEBUG= hg debugshell -c \
572 $ HG=$CHGHG CHGHG= CHGDEBUG= hg debugshell -c \
570 > 'ui.write(b"CHGHG=%s\n" % ui.environ.get(b"CHGHG"))' 2>&1 \
573 > 'ui.write(b"CHGHG=%s\n" % ui.environ.get(b"CHGHG"))' 2>&1 \
571 > | grep -E 'CHGHG|start cmdserver'
574 > | grep -E 'CHGHG|start cmdserver'
572 CHGHG=/*/install/bin/hg (glob)
575 CHGHG=/*/install/bin/hg (glob)
General Comments 0
You need to be logged in to leave comments. Login now