##// END OF EJS Templates
tests: add extra output for fsmonitor at showconfig
FUJIWARA Katsunori -
r33426:29653495 default
parent child Browse files
Show More
@@ -1,36 +1,34 b''
1 1 # Blacklist for a full testsuite run with fsmonitor enabled.
2 2 # Used by fsmonitor-run-tests.
3 3 # The following tests all fail because they either use extensions that conflict
4 4 # with fsmonitor, use subrepositories, or don't anticipate the extra file in
5 5 # the .hg directory that fsmonitor adds.
6 test-basic.t
7 test-commandserver.t
8 6 test-debugextensions.t
9 7 test-eol-add.t
10 8 test-eol-clone.t
11 9 test-eol-hook.t
12 10 test-eol-patch.t
13 11 test-eol-tag.t
14 12 test-eol-update.t
15 13 test-eol.t
16 14 test-eolfilename.t
17 15 test-extension.t
18 16 test-fncache.t
19 17 test-hardlinks.t
20 18 test-help.t
21 19 test-inherit-mode.t
22 20 test-issue3084.t
23 21 test-largefiles-cache.t
24 22 test-largefiles-misc.t
25 23 test-largefiles-small-disk.t
26 24 test-largefiles-update.t
27 25 test-largefiles-wireproto.t
28 26 test-largefiles.t
29 27 test-lfconvert.t
30 28 test-nested-repo.t
31 29 test-permissions.t
32 30 test-push-warn.t
33 31 test-subrepo-deep-nested-change.t
34 32 test-subrepo-recursion.t
35 33 test-subrepo.t
36 34 test-tags.t
@@ -1,88 +1,89 b''
1 1 Create a repository:
2 2
3 3 $ hg config
4 4 devel.all-warnings=true
5 5 devel.default-date=0 0
6 extensions.fsmonitor= (fsmonitor !)
6 7 largefiles.usercache=$TESTTMP/.cache/largefiles (glob)
7 8 ui.slash=True
8 9 ui.interactive=False
9 10 ui.mergemarkers=detailed
10 11 ui.promptecho=True
11 12 web.address=localhost
12 13 web\.ipv6=(?:True|False) (re)
13 14 $ hg init t
14 15 $ cd t
15 16
16 17 Prepare a changeset:
17 18
18 19 $ echo a > a
19 20 $ hg add a
20 21
21 22 $ hg status
22 23 A a
23 24
24 25 Writes to stdio succeed and fail appropriately
25 26
26 27 #if devfull
27 28 $ hg status 2>/dev/full
28 29 A a
29 30
30 31 $ hg status >/dev/full
31 32 abort: No space left on device
32 33 [255]
33 34
34 35 $ hg status >/dev/full 2>&1
35 36 [1]
36 37
37 38 $ hg status ENOENT 2>/dev/full
38 39 [1]
39 40 #endif
40 41
41 42 $ hg commit -m test
42 43
43 44 This command is ancient:
44 45
45 46 $ hg history
46 47 changeset: 0:acb14030fe0a
47 48 tag: tip
48 49 user: test
49 50 date: Thu Jan 01 00:00:00 1970 +0000
50 51 summary: test
51 52
52 53
53 54 Verify that updating to revision 0 via commands.update() works properly
54 55
55 56 $ cat <<EOF > update_to_rev0.py
56 57 > from mercurial import ui, hg, commands
57 58 > myui = ui.ui.load()
58 59 > repo = hg.repository(myui, path='.')
59 60 > commands.update(myui, repo, rev=0)
60 61 > EOF
61 62 $ hg up null
62 63 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
63 64 $ $PYTHON ./update_to_rev0.py
64 65 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
65 66 $ hg identify -n
66 67 0
67 68
68 69
69 70 Poke around at hashes:
70 71
71 72 $ hg manifest --debug
72 73 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
73 74
74 75 $ hg cat a
75 76 a
76 77
77 78 Verify should succeed:
78 79
79 80 $ hg verify
80 81 checking changesets
81 82 checking manifests
82 83 crosschecking files in changesets and manifests
83 84 checking files
84 85 1 files, 1 changesets, 1 total revisions
85 86
86 87 At the end...
87 88
88 89 $ cd ..
@@ -1,906 +1,907 b''
1 1 #if windows
2 2 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
3 3 #else
4 4 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
5 5 #endif
6 6 $ export PYTHONPATH
7 7
8 8 typical client does not want echo-back messages, so test without it:
9 9
10 10 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
11 11 $ mv $HGRCPATH.new $HGRCPATH
12 12
13 13 $ hg init repo
14 14 $ cd repo
15 15
16 16 >>> from __future__ import print_function
17 17 >>> from hgclient import readchannel, runcommand, check
18 18 >>> @check
19 19 ... def hellomessage(server):
20 20 ... ch, data = readchannel(server)
21 21 ... print('%c, %r' % (ch, data))
22 22 ... # run an arbitrary command to make sure the next thing the server
23 23 ... # sends isn't part of the hello message
24 24 ... runcommand(server, ['id'])
25 25 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
26 26 *** runcommand id
27 27 000000000000 tip
28 28
29 29 >>> from hgclient import check
30 30 >>> @check
31 31 ... def unknowncommand(server):
32 32 ... server.stdin.write('unknowncommand\n')
33 33 abort: unknown command unknowncommand
34 34
35 35 >>> from hgclient import readchannel, runcommand, check
36 36 >>> @check
37 37 ... def checkruncommand(server):
38 38 ... # hello block
39 39 ... readchannel(server)
40 40 ...
41 41 ... # no args
42 42 ... runcommand(server, [])
43 43 ...
44 44 ... # global options
45 45 ... runcommand(server, ['id', '--quiet'])
46 46 ...
47 47 ... # make sure global options don't stick through requests
48 48 ... runcommand(server, ['id'])
49 49 ...
50 50 ... # --config
51 51 ... runcommand(server, ['id', '--config', 'ui.quiet=True'])
52 52 ...
53 53 ... # make sure --config doesn't stick
54 54 ... runcommand(server, ['id'])
55 55 ...
56 56 ... # negative return code should be masked
57 57 ... runcommand(server, ['id', '-runknown'])
58 58 *** runcommand
59 59 Mercurial Distributed SCM
60 60
61 61 basic commands:
62 62
63 63 add add the specified files on the next commit
64 64 annotate show changeset information by line for each file
65 65 clone make a copy of an existing repository
66 66 commit commit the specified files or all outstanding changes
67 67 diff diff repository (or selected files)
68 68 export dump the header and diffs for one or more changesets
69 69 forget forget the specified files on the next commit
70 70 init create a new repository in the given directory
71 71 log show revision history of entire repository or files
72 72 merge merge another revision into working directory
73 73 pull pull changes from the specified source
74 74 push push changes to the specified destination
75 75 remove remove the specified files on the next commit
76 76 serve start stand-alone webserver
77 77 status show changed files in the working directory
78 78 summary summarize working directory state
79 79 update update working directory (or switch revisions)
80 80
81 81 (use 'hg help' for the full list of commands or 'hg -v' for details)
82 82 *** runcommand id --quiet
83 83 000000000000
84 84 *** runcommand id
85 85 000000000000 tip
86 86 *** runcommand id --config ui.quiet=True
87 87 000000000000
88 88 *** runcommand id
89 89 000000000000 tip
90 90 *** runcommand id -runknown
91 91 abort: unknown revision 'unknown'!
92 92 [255]
93 93
94 94 >>> from hgclient import readchannel, check
95 95 >>> @check
96 96 ... def inputeof(server):
97 97 ... readchannel(server)
98 98 ... server.stdin.write('runcommand\n')
99 99 ... # close stdin while server is waiting for input
100 100 ... server.stdin.close()
101 101 ...
102 102 ... # server exits with 1 if the pipe closed while reading the command
103 103 ... print('server exit code =', server.wait())
104 104 server exit code = 1
105 105
106 106 >>> from hgclient import readchannel, runcommand, check, stringio
107 107 >>> @check
108 108 ... def serverinput(server):
109 109 ... readchannel(server)
110 110 ...
111 111 ... patch = """
112 112 ... # HG changeset patch
113 113 ... # User test
114 114 ... # Date 0 0
115 115 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
116 116 ... # Parent 0000000000000000000000000000000000000000
117 117 ... 1
118 118 ...
119 119 ... diff -r 000000000000 -r c103a3dec114 a
120 120 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
121 121 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
122 122 ... @@ -0,0 +1,1 @@
123 123 ... +1
124 124 ... """
125 125 ...
126 126 ... runcommand(server, ['import', '-'], input=stringio(patch))
127 127 ... runcommand(server, ['log'])
128 128 *** runcommand import -
129 129 applying patch from stdin
130 130 *** runcommand log
131 131 changeset: 0:eff892de26ec
132 132 tag: tip
133 133 user: test
134 134 date: Thu Jan 01 00:00:00 1970 +0000
135 135 summary: 1
136 136
137 137
138 138 check that "histedit --commands=-" can read rules from the input channel:
139 139
140 140 >>> import cStringIO
141 141 >>> from hgclient import readchannel, runcommand, check
142 142 >>> @check
143 143 ... def serverinput(server):
144 144 ... readchannel(server)
145 145 ... rules = 'pick eff892de26ec\n'
146 146 ... runcommand(server, ['histedit', '0', '--commands=-',
147 147 ... '--config', 'extensions.histedit='],
148 148 ... input=cStringIO.StringIO(rules))
149 149 *** runcommand histedit 0 --commands=- --config extensions.histedit=
150 150
151 151 check that --cwd doesn't persist between requests:
152 152
153 153 $ mkdir foo
154 154 $ touch foo/bar
155 155 >>> from hgclient import readchannel, runcommand, check
156 156 >>> @check
157 157 ... def cwd(server):
158 158 ... readchannel(server)
159 159 ... runcommand(server, ['--cwd', 'foo', 'st', 'bar'])
160 160 ... runcommand(server, ['st', 'foo/bar'])
161 161 *** runcommand --cwd foo st bar
162 162 ? bar
163 163 *** runcommand st foo/bar
164 164 ? foo/bar
165 165
166 166 $ rm foo/bar
167 167
168 168
169 169 check that local configs for the cached repo aren't inherited when -R is used:
170 170
171 171 $ cat <<EOF >> .hg/hgrc
172 172 > [ui]
173 173 > foo = bar
174 174 > EOF
175 175
176 176 >>> from hgclient import readchannel, sep, runcommand, check
177 177 >>> @check
178 178 ... def localhgrc(server):
179 179 ... readchannel(server)
180 180 ...
181 181 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
182 182 ... # show it
183 183 ... runcommand(server, ['showconfig'], outfilter=sep)
184 184 ...
185 185 ... # but not for this repo
186 186 ... runcommand(server, ['init', 'foo'])
187 187 ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults'])
188 188 *** runcommand showconfig
189 189 bundle.mainreporoot=$TESTTMP/repo
190 190 devel.all-warnings=true
191 191 devel.default-date=0 0
192 extensions.fsmonitor= (fsmonitor !)
192 193 largefiles.usercache=$TESTTMP/.cache/largefiles
193 194 ui.slash=True
194 195 ui.interactive=False
195 196 ui.mergemarkers=detailed
196 197 ui.usehttp2=true (?)
197 198 ui.foo=bar
198 199 ui.nontty=true
199 200 web.address=localhost
200 201 web\.ipv6=(?:True|False) (re)
201 202 *** runcommand init foo
202 203 *** runcommand -R foo showconfig ui defaults
203 204 ui.slash=True
204 205 ui.interactive=False
205 206 ui.mergemarkers=detailed
206 207 ui.usehttp2=true (?)
207 208 ui.nontty=true
208 209
209 210 $ rm -R foo
210 211
211 212 #if windows
212 213 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
213 214 #else
214 215 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
215 216 #endif
216 217
217 218 $ cat <<EOF > hook.py
218 219 > from __future__ import print_function
219 220 > import sys
220 221 > def hook(**args):
221 222 > print('hook talking')
222 223 > print('now try to read something: %r' % sys.stdin.read())
223 224 > EOF
224 225
225 226 >>> from hgclient import readchannel, runcommand, check, stringio
226 227 >>> @check
227 228 ... def hookoutput(server):
228 229 ... readchannel(server)
229 230 ... runcommand(server, ['--config',
230 231 ... 'hooks.pre-identify=python:hook.hook',
231 232 ... 'id'],
232 233 ... input=stringio('some input'))
233 234 *** runcommand --config hooks.pre-identify=python:hook.hook id
234 235 eff892de26ec tip
235 236
236 237 $ rm hook.py*
237 238
238 239 $ echo a >> a
239 240 >>> import os
240 241 >>> from hgclient import readchannel, runcommand, check
241 242 >>> @check
242 243 ... def outsidechanges(server):
243 244 ... readchannel(server)
244 245 ... runcommand(server, ['status'])
245 246 ... os.system('hg ci -Am2')
246 247 ... runcommand(server, ['tip'])
247 248 ... runcommand(server, ['status'])
248 249 *** runcommand status
249 250 M a
250 251 *** runcommand tip
251 252 changeset: 1:d3a0a68be6de
252 253 tag: tip
253 254 user: test
254 255 date: Thu Jan 01 00:00:00 1970 +0000
255 256 summary: 2
256 257
257 258 *** runcommand status
258 259
259 260 >>> import os
260 261 >>> from hgclient import readchannel, runcommand, check
261 262 >>> @check
262 263 ... def bookmarks(server):
263 264 ... readchannel(server)
264 265 ... runcommand(server, ['bookmarks'])
265 266 ...
266 267 ... # changes .hg/bookmarks
267 268 ... os.system('hg bookmark -i bm1')
268 269 ... os.system('hg bookmark -i bm2')
269 270 ... runcommand(server, ['bookmarks'])
270 271 ...
271 272 ... # changes .hg/bookmarks.current
272 273 ... os.system('hg upd bm1 -q')
273 274 ... runcommand(server, ['bookmarks'])
274 275 ...
275 276 ... runcommand(server, ['bookmarks', 'bm3'])
276 277 ... f = open('a', 'ab')
277 278 ... f.write('a\n')
278 279 ... f.close()
279 280 ... runcommand(server, ['commit', '-Amm'])
280 281 ... runcommand(server, ['bookmarks'])
281 282 *** runcommand bookmarks
282 283 no bookmarks set
283 284 *** runcommand bookmarks
284 285 bm1 1:d3a0a68be6de
285 286 bm2 1:d3a0a68be6de
286 287 *** runcommand bookmarks
287 288 * bm1 1:d3a0a68be6de
288 289 bm2 1:d3a0a68be6de
289 290 *** runcommand bookmarks bm3
290 291 *** runcommand commit -Amm
291 292 *** runcommand bookmarks
292 293 bm1 1:d3a0a68be6de
293 294 bm2 1:d3a0a68be6de
294 295 * bm3 2:aef17e88f5f0
295 296
296 297 >>> import os
297 298 >>> from hgclient import readchannel, runcommand, check
298 299 >>> @check
299 300 ... def tagscache(server):
300 301 ... readchannel(server)
301 302 ... runcommand(server, ['id', '-t', '-r', '0'])
302 303 ... os.system('hg tag -r 0 foo')
303 304 ... runcommand(server, ['id', '-t', '-r', '0'])
304 305 *** runcommand id -t -r 0
305 306
306 307 *** runcommand id -t -r 0
307 308 foo
308 309
309 310 >>> import os
310 311 >>> from hgclient import readchannel, runcommand, check
311 312 >>> @check
312 313 ... def setphase(server):
313 314 ... readchannel(server)
314 315 ... runcommand(server, ['phase', '-r', '.'])
315 316 ... os.system('hg phase -r . -p')
316 317 ... runcommand(server, ['phase', '-r', '.'])
317 318 *** runcommand phase -r .
318 319 3: draft
319 320 *** runcommand phase -r .
320 321 3: public
321 322
322 323 $ echo a >> a
323 324 >>> from hgclient import readchannel, runcommand, check
324 325 >>> @check
325 326 ... def rollback(server):
326 327 ... readchannel(server)
327 328 ... runcommand(server, ['phase', '-r', '.', '-p'])
328 329 ... runcommand(server, ['commit', '-Am.'])
329 330 ... runcommand(server, ['rollback'])
330 331 ... runcommand(server, ['phase', '-r', '.'])
331 332 *** runcommand phase -r . -p
332 333 no phases changed
333 334 *** runcommand commit -Am.
334 335 *** runcommand rollback
335 336 repository tip rolled back to revision 3 (undo commit)
336 337 working directory now based on revision 3
337 338 *** runcommand phase -r .
338 339 3: public
339 340
340 341 >>> import os
341 342 >>> from hgclient import readchannel, runcommand, check
342 343 >>> @check
343 344 ... def branch(server):
344 345 ... readchannel(server)
345 346 ... runcommand(server, ['branch'])
346 347 ... os.system('hg branch foo')
347 348 ... runcommand(server, ['branch'])
348 349 ... os.system('hg branch default')
349 350 *** runcommand branch
350 351 default
351 352 marked working directory as branch foo
352 353 (branches are permanent and global, did you want a bookmark?)
353 354 *** runcommand branch
354 355 foo
355 356 marked working directory as branch default
356 357 (branches are permanent and global, did you want a bookmark?)
357 358
358 359 $ touch .hgignore
359 360 >>> import os
360 361 >>> from hgclient import readchannel, runcommand, check
361 362 >>> @check
362 363 ... def hgignore(server):
363 364 ... readchannel(server)
364 365 ... runcommand(server, ['commit', '-Am.'])
365 366 ... f = open('ignored-file', 'ab')
366 367 ... f.write('')
367 368 ... f.close()
368 369 ... f = open('.hgignore', 'ab')
369 370 ... f.write('ignored-file')
370 371 ... f.close()
371 372 ... runcommand(server, ['status', '-i', '-u'])
372 373 *** runcommand commit -Am.
373 374 adding .hgignore
374 375 *** runcommand status -i -u
375 376 I ignored-file
376 377
377 378 cache of non-public revisions should be invalidated on repository change
378 379 (issue4855):
379 380
380 381 >>> import os
381 382 >>> from hgclient import readchannel, runcommand, check
382 383 >>> @check
383 384 ... def phasesetscacheaftercommit(server):
384 385 ... readchannel(server)
385 386 ... # load _phasecache._phaserevs and _phasesets
386 387 ... runcommand(server, ['log', '-qr', 'draft()'])
387 388 ... # create draft commits by another process
388 389 ... for i in xrange(5, 7):
389 390 ... f = open('a', 'ab')
390 391 ... f.seek(0, os.SEEK_END)
391 392 ... f.write('a\n')
392 393 ... f.close()
393 394 ... os.system('hg commit -Aqm%d' % i)
394 395 ... # new commits should be listed as draft revisions
395 396 ... runcommand(server, ['log', '-qr', 'draft()'])
396 397 *** runcommand log -qr draft()
397 398 4:7966c8e3734d
398 399 *** runcommand log -qr draft()
399 400 4:7966c8e3734d
400 401 5:41f6602d1c4f
401 402 6:10501e202c35
402 403
403 404 >>> import os
404 405 >>> from hgclient import readchannel, runcommand, check
405 406 >>> @check
406 407 ... def phasesetscacheafterstrip(server):
407 408 ... readchannel(server)
408 409 ... # load _phasecache._phaserevs and _phasesets
409 410 ... runcommand(server, ['log', '-qr', 'draft()'])
410 411 ... # strip cached revisions by another process
411 412 ... os.system('hg --config extensions.strip= strip -q 5')
412 413 ... # shouldn't abort by "unknown revision '6'"
413 414 ... runcommand(server, ['log', '-qr', 'draft()'])
414 415 *** runcommand log -qr draft()
415 416 4:7966c8e3734d
416 417 5:41f6602d1c4f
417 418 6:10501e202c35
418 419 *** runcommand log -qr draft()
419 420 4:7966c8e3734d
420 421
421 422 cache of phase roots should be invalidated on strip (issue3827):
422 423
423 424 >>> import os
424 425 >>> from hgclient import readchannel, sep, runcommand, check
425 426 >>> @check
426 427 ... def phasecacheafterstrip(server):
427 428 ... readchannel(server)
428 429 ...
429 430 ... # create new head, 5:731265503d86
430 431 ... runcommand(server, ['update', '-C', '0'])
431 432 ... f = open('a', 'ab')
432 433 ... f.write('a\n')
433 434 ... f.close()
434 435 ... runcommand(server, ['commit', '-Am.', 'a'])
435 436 ... runcommand(server, ['log', '-Gq'])
436 437 ...
437 438 ... # make it public; draft marker moves to 4:7966c8e3734d
438 439 ... runcommand(server, ['phase', '-p', '.'])
439 440 ... # load _phasecache.phaseroots
440 441 ... runcommand(server, ['phase', '.'], outfilter=sep)
441 442 ...
442 443 ... # strip 1::4 outside server
443 444 ... os.system('hg -q --config extensions.mq= strip 1')
444 445 ...
445 446 ... # shouldn't raise "7966c8e3734d: no node!"
446 447 ... runcommand(server, ['branches'])
447 448 *** runcommand update -C 0
448 449 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
449 450 (leaving bookmark bm3)
450 451 *** runcommand commit -Am. a
451 452 created new head
452 453 *** runcommand log -Gq
453 454 @ 5:731265503d86
454 455 |
455 456 | o 4:7966c8e3734d
456 457 | |
457 458 | o 3:b9b85890c400
458 459 | |
459 460 | o 2:aef17e88f5f0
460 461 | |
461 462 | o 1:d3a0a68be6de
462 463 |/
463 464 o 0:eff892de26ec
464 465
465 466 *** runcommand phase -p .
466 467 *** runcommand phase .
467 468 5: public
468 469 *** runcommand branches
469 470 default 1:731265503d86
470 471
471 472 in-memory cache must be reloaded if transaction is aborted. otherwise
472 473 changelog and manifest would have invalid node:
473 474
474 475 $ echo a >> a
475 476 >>> from hgclient import readchannel, runcommand, check
476 477 >>> @check
477 478 ... def txabort(server):
478 479 ... readchannel(server)
479 480 ... runcommand(server, ['commit', '--config', 'hooks.pretxncommit=false',
480 481 ... '-mfoo'])
481 482 ... runcommand(server, ['verify'])
482 483 *** runcommand commit --config hooks.pretxncommit=false -mfoo
483 484 transaction abort!
484 485 rollback completed
485 486 abort: pretxncommit hook exited with status 1
486 487 [255]
487 488 *** runcommand verify
488 489 checking changesets
489 490 checking manifests
490 491 crosschecking files in changesets and manifests
491 492 checking files
492 493 1 files, 2 changesets, 2 total revisions
493 494 $ hg revert --no-backup -aq
494 495
495 496 $ cat >> .hg/hgrc << EOF
496 497 > [experimental]
497 498 > evolution=createmarkers
498 499 > EOF
499 500
500 501 >>> import os
501 502 >>> from hgclient import readchannel, runcommand, check
502 503 >>> @check
503 504 ... def obsolete(server):
504 505 ... readchannel(server)
505 506 ...
506 507 ... runcommand(server, ['up', 'null'])
507 508 ... runcommand(server, ['phase', '-df', 'tip'])
508 509 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
509 510 ... if os.name == 'nt':
510 511 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
511 512 ... os.system(cmd)
512 513 ... runcommand(server, ['log', '--hidden'])
513 514 ... runcommand(server, ['log'])
514 515 *** runcommand up null
515 516 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
516 517 *** runcommand phase -df tip
517 518 *** runcommand log --hidden
518 519 changeset: 1:731265503d86
519 520 tag: tip
520 521 user: test
521 522 date: Thu Jan 01 00:00:00 1970 +0000
522 523 summary: .
523 524
524 525 changeset: 0:eff892de26ec
525 526 bookmark: bm1
526 527 bookmark: bm2
527 528 bookmark: bm3
528 529 user: test
529 530 date: Thu Jan 01 00:00:00 1970 +0000
530 531 summary: 1
531 532
532 533 *** runcommand log
533 534 changeset: 0:eff892de26ec
534 535 bookmark: bm1
535 536 bookmark: bm2
536 537 bookmark: bm3
537 538 tag: tip
538 539 user: test
539 540 date: Thu Jan 01 00:00:00 1970 +0000
540 541 summary: 1
541 542
542 543
543 544 $ cat <<EOF >> .hg/hgrc
544 545 > [extensions]
545 546 > mq =
546 547 > EOF
547 548
548 549 >>> import os
549 550 >>> from hgclient import readchannel, runcommand, check
550 551 >>> @check
551 552 ... def mqoutsidechanges(server):
552 553 ... readchannel(server)
553 554 ...
554 555 ... # load repo.mq
555 556 ... runcommand(server, ['qapplied'])
556 557 ... os.system('hg qnew 0.diff')
557 558 ... # repo.mq should be invalidated
558 559 ... runcommand(server, ['qapplied'])
559 560 ...
560 561 ... runcommand(server, ['qpop', '--all'])
561 562 ... os.system('hg qqueue --create foo')
562 563 ... # repo.mq should be recreated to point to new queue
563 564 ... runcommand(server, ['qqueue', '--active'])
564 565 *** runcommand qapplied
565 566 *** runcommand qapplied
566 567 0.diff
567 568 *** runcommand qpop --all
568 569 popping 0.diff
569 570 patch queue now empty
570 571 *** runcommand qqueue --active
571 572 foo
572 573
573 574 $ cat <<EOF > dbgui.py
574 575 > import os, sys
575 576 > from mercurial import commands, registrar
576 577 > cmdtable = {}
577 578 > command = registrar.command(cmdtable)
578 579 > @command(b"debuggetpass", norepo=True)
579 580 > def debuggetpass(ui):
580 581 > ui.write("%s\\n" % ui.getpass())
581 582 > @command(b"debugprompt", norepo=True)
582 583 > def debugprompt(ui):
583 584 > ui.write("%s\\n" % ui.prompt("prompt:"))
584 585 > @command(b"debugreadstdin", norepo=True)
585 586 > def debugreadstdin(ui):
586 587 > ui.write("read: %r\n" % sys.stdin.read(1))
587 588 > @command(b"debugwritestdout", norepo=True)
588 589 > def debugwritestdout(ui):
589 590 > os.write(1, "low-level stdout fd and\n")
590 591 > sys.stdout.write("stdout should be redirected to /dev/null\n")
591 592 > sys.stdout.flush()
592 593 > EOF
593 594 $ cat <<EOF >> .hg/hgrc
594 595 > [extensions]
595 596 > dbgui = dbgui.py
596 597 > EOF
597 598
598 599 >>> from hgclient import readchannel, runcommand, check, stringio
599 600 >>> @check
600 601 ... def getpass(server):
601 602 ... readchannel(server)
602 603 ... runcommand(server, ['debuggetpass', '--config',
603 604 ... 'ui.interactive=True'],
604 605 ... input=stringio('1234\n'))
605 606 ... runcommand(server, ['debuggetpass', '--config',
606 607 ... 'ui.interactive=True'],
607 608 ... input=stringio('\n'))
608 609 ... runcommand(server, ['debuggetpass', '--config',
609 610 ... 'ui.interactive=True'],
610 611 ... input=stringio(''))
611 612 ... runcommand(server, ['debugprompt', '--config',
612 613 ... 'ui.interactive=True'],
613 614 ... input=stringio('5678\n'))
614 615 ... runcommand(server, ['debugreadstdin'])
615 616 ... runcommand(server, ['debugwritestdout'])
616 617 *** runcommand debuggetpass --config ui.interactive=True
617 618 password: 1234
618 619 *** runcommand debuggetpass --config ui.interactive=True
619 620 password:
620 621 *** runcommand debuggetpass --config ui.interactive=True
621 622 password: abort: response expected
622 623 [255]
623 624 *** runcommand debugprompt --config ui.interactive=True
624 625 prompt: 5678
625 626 *** runcommand debugreadstdin
626 627 read: ''
627 628 *** runcommand debugwritestdout
628 629
629 630
630 631 run commandserver in commandserver, which is silly but should work:
631 632
632 633 >>> from __future__ import print_function
633 634 >>> from hgclient import readchannel, runcommand, check, stringio
634 635 >>> @check
635 636 ... def nested(server):
636 637 ... print('%c, %r' % readchannel(server))
637 638 ... class nestedserver(object):
638 639 ... stdin = stringio('getencoding\n')
639 640 ... stdout = stringio()
640 641 ... runcommand(server, ['serve', '--cmdserver', 'pipe'],
641 642 ... output=nestedserver.stdout, input=nestedserver.stdin)
642 643 ... nestedserver.stdout.seek(0)
643 644 ... print('%c, %r' % readchannel(nestedserver)) # hello
644 645 ... print('%c, %r' % readchannel(nestedserver)) # getencoding
645 646 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
646 647 *** runcommand serve --cmdserver pipe
647 648 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
648 649 r, '*' (glob)
649 650
650 651
651 652 start without repository:
652 653
653 654 $ cd ..
654 655
655 656 >>> from __future__ import print_function
656 657 >>> from hgclient import readchannel, runcommand, check
657 658 >>> @check
658 659 ... def hellomessage(server):
659 660 ... ch, data = readchannel(server)
660 661 ... print('%c, %r' % (ch, data))
661 662 ... # run an arbitrary command to make sure the next thing the server
662 663 ... # sends isn't part of the hello message
663 664 ... runcommand(server, ['id'])
664 665 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
665 666 *** runcommand id
666 667 abort: there is no Mercurial repository here (.hg not found)
667 668 [255]
668 669
669 670 >>> from hgclient import readchannel, runcommand, check
670 671 >>> @check
671 672 ... def startwithoutrepo(server):
672 673 ... readchannel(server)
673 674 ... runcommand(server, ['init', 'repo2'])
674 675 ... runcommand(server, ['id', '-R', 'repo2'])
675 676 *** runcommand init repo2
676 677 *** runcommand id -R repo2
677 678 000000000000 tip
678 679
679 680
680 681 don't fall back to cwd if invalid -R path is specified (issue4805):
681 682
682 683 $ cd repo
683 684 $ hg serve --cmdserver pipe -R ../nonexistent
684 685 abort: repository ../nonexistent not found!
685 686 [255]
686 687 $ cd ..
687 688
688 689
689 690 unix domain socket:
690 691
691 692 $ cd repo
692 693 $ hg update -q
693 694
694 695 #if unix-socket unix-permissions
695 696
696 697 >>> from __future__ import print_function
697 698 >>> from hgclient import unixserver, readchannel, runcommand, check, stringio
698 699 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
699 700 >>> def hellomessage(conn):
700 701 ... ch, data = readchannel(conn)
701 702 ... print('%c, %r' % (ch, data))
702 703 ... runcommand(conn, ['id'])
703 704 >>> check(hellomessage, server.connect)
704 705 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
705 706 *** runcommand id
706 707 eff892de26ec tip bm1/bm2/bm3
707 708 >>> def unknowncommand(conn):
708 709 ... readchannel(conn)
709 710 ... conn.stdin.write('unknowncommand\n')
710 711 >>> check(unknowncommand, server.connect) # error sent to server.log
711 712 >>> def serverinput(conn):
712 713 ... readchannel(conn)
713 714 ... patch = """
714 715 ... # HG changeset patch
715 716 ... # User test
716 717 ... # Date 0 0
717 718 ... 2
718 719 ...
719 720 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
720 721 ... --- a/a
721 722 ... +++ b/a
722 723 ... @@ -1,1 +1,2 @@
723 724 ... 1
724 725 ... +2
725 726 ... """
726 727 ... runcommand(conn, ['import', '-'], input=stringio(patch))
727 728 ... runcommand(conn, ['log', '-rtip', '-q'])
728 729 >>> check(serverinput, server.connect)
729 730 *** runcommand import -
730 731 applying patch from stdin
731 732 *** runcommand log -rtip -q
732 733 2:1ed24be7e7a0
733 734 >>> server.shutdown()
734 735
735 736 $ cat .hg/server.log
736 737 listening at .hg/server.sock
737 738 abort: unknown command unknowncommand
738 739 killed!
739 740 $ rm .hg/server.log
740 741
741 742 if server crashed before hello, traceback will be sent to 'e' channel as
742 743 last ditch:
743 744
744 745 $ cat <<EOF >> .hg/hgrc
745 746 > [cmdserver]
746 747 > log = inexistent/path.log
747 748 > EOF
748 749 >>> from __future__ import print_function
749 750 >>> from hgclient import unixserver, readchannel, check
750 751 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
751 752 >>> def earlycrash(conn):
752 753 ... while True:
753 754 ... try:
754 755 ... ch, data = readchannel(conn)
755 756 ... if not data.startswith(' '):
756 757 ... print('%c, %r' % (ch, data))
757 758 ... except EOFError:
758 759 ... break
759 760 >>> check(earlycrash, server.connect)
760 761 e, 'Traceback (most recent call last):\n'
761 762 e, "IOError: *" (glob)
762 763 >>> server.shutdown()
763 764
764 765 $ cat .hg/server.log | grep -v '^ '
765 766 listening at .hg/server.sock
766 767 Traceback (most recent call last):
767 768 IOError: * (glob)
768 769 killed!
769 770 #endif
770 771 #if no-unix-socket
771 772
772 773 $ hg serve --cmdserver unix -a .hg/server.sock
773 774 abort: unsupported platform
774 775 [255]
775 776
776 777 #endif
777 778
778 779 $ cd ..
779 780
780 781 Test that accessing to invalid changelog cache is avoided at
781 782 subsequent operations even if repo object is reused even after failure
782 783 of transaction (see 0a7610758c42 also)
783 784
784 785 "hg log" after failure of transaction is needed to detect invalid
785 786 cache in repoview: this can't detect by "hg verify" only.
786 787
787 788 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
788 789 4) are tested, because '00changelog.i' are differently changed in each
789 790 cases.
790 791
791 792 $ cat > $TESTTMP/failafterfinalize.py <<EOF
792 793 > # extension to abort transaction after finalization forcibly
793 794 > from mercurial import commands, error, extensions, lock as lockmod
794 795 > def fail(tr):
795 796 > raise error.Abort('fail after finalization')
796 797 > def reposetup(ui, repo):
797 798 > class failrepo(repo.__class__):
798 799 > def commitctx(self, ctx, error=False):
799 800 > if self.ui.configbool('failafterfinalize', 'fail'):
800 801 > # 'sorted()' by ASCII code on category names causes
801 802 > # invoking 'fail' after finalization of changelog
802 803 > # using "'cl-%i' % id(self)" as category name
803 804 > self.currenttransaction().addfinalize('zzzzzzzz', fail)
804 805 > return super(failrepo, self).commitctx(ctx, error)
805 806 > repo.__class__ = failrepo
806 807 > EOF
807 808
808 809 $ hg init repo3
809 810 $ cd repo3
810 811
811 812 $ cat <<EOF >> $HGRCPATH
812 813 > [ui]
813 814 > logtemplate = {rev} {desc|firstline} ({files})\n
814 815 >
815 816 > [extensions]
816 817 > failafterfinalize = $TESTTMP/failafterfinalize.py
817 818 > EOF
818 819
819 820 - test failure with "empty changelog"
820 821
821 822 $ echo foo > foo
822 823 $ hg add foo
823 824
824 825 (failure before finalization)
825 826
826 827 >>> from hgclient import readchannel, runcommand, check
827 828 >>> @check
828 829 ... def abort(server):
829 830 ... readchannel(server)
830 831 ... runcommand(server, ['commit',
831 832 ... '--config', 'hooks.pretxncommit=false',
832 833 ... '-mfoo'])
833 834 ... runcommand(server, ['log'])
834 835 ... runcommand(server, ['verify', '-q'])
835 836 *** runcommand commit --config hooks.pretxncommit=false -mfoo
836 837 transaction abort!
837 838 rollback completed
838 839 abort: pretxncommit hook exited with status 1
839 840 [255]
840 841 *** runcommand log
841 842 *** runcommand verify -q
842 843
843 844 (failure after finalization)
844 845
845 846 >>> from hgclient import readchannel, runcommand, check
846 847 >>> @check
847 848 ... def abort(server):
848 849 ... readchannel(server)
849 850 ... runcommand(server, ['commit',
850 851 ... '--config', 'failafterfinalize.fail=true',
851 852 ... '-mfoo'])
852 853 ... runcommand(server, ['log'])
853 854 ... runcommand(server, ['verify', '-q'])
854 855 *** runcommand commit --config failafterfinalize.fail=true -mfoo
855 856 transaction abort!
856 857 rollback completed
857 858 abort: fail after finalization
858 859 [255]
859 860 *** runcommand log
860 861 *** runcommand verify -q
861 862
862 863 - test failure with "not-empty changelog"
863 864
864 865 $ echo bar > bar
865 866 $ hg add bar
866 867 $ hg commit -mbar bar
867 868
868 869 (failure before finalization)
869 870
870 871 >>> from hgclient import readchannel, runcommand, check
871 872 >>> @check
872 873 ... def abort(server):
873 874 ... readchannel(server)
874 875 ... runcommand(server, ['commit',
875 876 ... '--config', 'hooks.pretxncommit=false',
876 877 ... '-mfoo', 'foo'])
877 878 ... runcommand(server, ['log'])
878 879 ... runcommand(server, ['verify', '-q'])
879 880 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
880 881 transaction abort!
881 882 rollback completed
882 883 abort: pretxncommit hook exited with status 1
883 884 [255]
884 885 *** runcommand log
885 886 0 bar (bar)
886 887 *** runcommand verify -q
887 888
888 889 (failure after finalization)
889 890
890 891 >>> from hgclient import readchannel, runcommand, check
891 892 >>> @check
892 893 ... def abort(server):
893 894 ... readchannel(server)
894 895 ... runcommand(server, ['commit',
895 896 ... '--config', 'failafterfinalize.fail=true',
896 897 ... '-mfoo', 'foo'])
897 898 ... runcommand(server, ['log'])
898 899 ... runcommand(server, ['verify', '-q'])
899 900 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
900 901 transaction abort!
901 902 rollback completed
902 903 abort: fail after finalization
903 904 [255]
904 905 *** runcommand log
905 906 0 bar (bar)
906 907 *** runcommand verify -q
General Comments 0
You need to be logged in to leave comments. Login now