Show More
@@ -1,4 +1,25 b'' | |||
|
1 | #require false | |
|
1 | #if windows | |
|
2 | $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH" | |
|
3 | #else | |
|
4 | $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH" | |
|
5 | #endif | |
|
6 | $ export PYTHONPATH | |
|
7 | ||
|
8 | $ hg init repo | |
|
9 | $ cd repo | |
|
10 | ||
|
11 | >>> import re | |
|
12 | >>> from hgclient import readchannel, runcommand, check | |
|
13 | >>> @check | |
|
14 | ... def hellomessage(server): | |
|
15 | ... ch, data = readchannel(server) | |
|
16 | ... # escaping python tests output not supported | |
|
17 | ... print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', | |
|
18 | ... 'encoding: ***', data)) | |
|
19 | ... | |
|
20 | ... # run an arbitrary command to make sure the next thing the server | |
|
21 | ... # sends isn't part of the hello message | |
|
22 | ... runcommand(server, ['id']) | |
|
2 | 23 |
|
|
3 | 24 | testing hellomessage: |
|
4 | 25 |
|
@@ -6,10 +27,39 b'' | |||
|
6 | 27 | runcommand id |
|
7 | 28 | 000000000000 tip |
|
8 | 29 | |
|
30 | >>> from hgclient import check | |
|
31 | >>> @check | |
|
32 | ... def unknowncommand(server): | |
|
33 | ... server.stdin.write('unknowncommand\n') | |
|
34 | ||
|
9 | 35 | testing unknowncommand: |
|
10 | 36 |
|
|
11 | 37 | abort: unknown command unknowncommand |
|
12 | 38 | |
|
39 | >>> from hgclient import readchannel, runcommand, check | |
|
40 | >>> @check | |
|
41 | ... def checkruncommand(server): | |
|
42 | ... # hello block | |
|
43 | ... readchannel(server) | |
|
44 | ... | |
|
45 | ... # no args | |
|
46 | ... runcommand(server, []) | |
|
47 | ... | |
|
48 | ... # global options | |
|
49 | ... runcommand(server, ['id', '--quiet']) | |
|
50 | ... | |
|
51 | ... # make sure global options don't stick through requests | |
|
52 | ... runcommand(server, ['id']) | |
|
53 | ... | |
|
54 | ... # --config | |
|
55 | ... runcommand(server, ['id', '--config', 'ui.quiet=True']) | |
|
56 | ... | |
|
57 | ... # make sure --config doesn't stick | |
|
58 | ... runcommand(server, ['id']) | |
|
59 | ... | |
|
60 | ... # negative return code should be masked | |
|
61 | ... runcommand(server, ['id', '-runknown']) | |
|
62 | ||
|
13 | 63 | testing checkruncommand: |
|
14 | 64 |
|
|
15 | 65 | runcommand |
@@ -48,10 +98,45 b'' | |||
|
48 | 98 |
abort: unknown revision 'unknown'! |
|
49 | 99 | [255] |
|
50 | 100 | |
|
101 | >>> from hgclient import readchannel, check | |
|
102 | >>> @check | |
|
103 | ... def inputeof(server): | |
|
104 | ... readchannel(server) | |
|
105 | ... server.stdin.write('runcommand\n') | |
|
106 | ... # close stdin while server is waiting for input | |
|
107 | ... server.stdin.close() | |
|
108 | ... | |
|
109 | ... # server exits with 1 if the pipe closed while reading the command | |
|
110 | ... print 'server exit code =', server.wait() | |
|
111 | ||
|
51 | 112 | testing inputeof: |
|
52 | 113 |
|
|
53 | 114 | server exit code = 1 |
|
54 | 115 | |
|
116 | >>> import cStringIO | |
|
117 | >>> from hgclient import readchannel, runcommand, check | |
|
118 | >>> @check | |
|
119 | ... def serverinput(server): | |
|
120 | ... readchannel(server) | |
|
121 | ... | |
|
122 | ... patch = """ | |
|
123 | ... # HG changeset patch | |
|
124 | ... # User test | |
|
125 | ... # Date 0 0 | |
|
126 | ... # Node ID c103a3dec114d882c98382d684d8af798d09d857 | |
|
127 | ... # Parent 0000000000000000000000000000000000000000 | |
|
128 | ... 1 | |
|
129 | ... | |
|
130 | ... diff -r 000000000000 -r c103a3dec114 a | |
|
131 | ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
|
132 | ... +++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
|
133 | ... @@ -0,0 +1,1 @@ | |
|
134 | ... +1 | |
|
135 | ... """ | |
|
136 | ... | |
|
137 | ... runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch)) | |
|
138 | ... runcommand(server, ['log']) | |
|
139 | ||
|
55 | 140 | testing serverinput: |
|
56 | 141 |
|
|
57 | 142 | runcommand import - |
@@ -64,6 +149,17 b'' | |||
|
64 | 149 | summary: 1 |
|
65 | 150 |
|
|
66 | 151 | |
|
152 | check that --cwd doesn't persist between requests: | |
|
153 | ||
|
154 | $ mkdir foo | |
|
155 | $ touch foo/bar | |
|
156 | >>> from hgclient import readchannel, runcommand, check | |
|
157 | >>> @check | |
|
158 | ... def cwd(server): | |
|
159 | ... readchannel(server) | |
|
160 | ... runcommand(server, ['--cwd', 'foo', 'st', 'bar']) | |
|
161 | ... runcommand(server, ['st', 'foo/bar']) | |
|
162 | ||
|
67 | 163 | testing cwd: |
|
68 | 164 | |
|
69 | 165 | runcommand --cwd foo st bar |
@@ -71,6 +167,29 b'' | |||
|
71 | 167 | runcommand st foo/bar |
|
72 | 168 | ? foo/bar |
|
73 | 169 | |
|
170 | $ rm foo/bar | |
|
171 | ||
|
172 | ||
|
173 | check that local configs for the cached repo aren't inherited when -R is used: | |
|
174 | ||
|
175 | $ cat <<EOF >> .hg/hgrc | |
|
176 | > [ui] | |
|
177 | > foo = bar | |
|
178 | > EOF | |
|
179 | ||
|
180 | >>> from hgclient import readchannel, sep, runcommand, check | |
|
181 | >>> @check | |
|
182 | ... def localhgrc(server): | |
|
183 | ... readchannel(server) | |
|
184 | ... | |
|
185 | ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should | |
|
186 | ... # show it | |
|
187 | ... runcommand(server, ['showconfig'], outfilter=sep) | |
|
188 | ... | |
|
189 | ... # but not for this repo | |
|
190 | ... runcommand(server, ['init', 'foo']) | |
|
191 | ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults']) | |
|
192 | ||
|
74 | 193 | testing localhgrc: |
|
75 | 194 |
|
|
76 | 195 | runcommand showconfig |
@@ -95,13 +214,51 b'' | |||
|
95 | 214 | ui.mergemarkers=detailed |
|
96 | 215 | ui.nontty=true |
|
97 | 216 | |
|
217 | $ rm -R foo | |
|
218 | ||
|
219 | #if windows | |
|
220 | $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH" | |
|
221 | #else | |
|
222 | $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH" | |
|
223 | #endif | |
|
224 | ||
|
225 | $ cat <<EOF > hook.py | |
|
226 | > import sys | |
|
227 | > def hook(**args): | |
|
228 | > print 'hook talking' | |
|
229 | > print 'now try to read something: %r' % sys.stdin.read() | |
|
230 | > EOF | |
|
231 | ||
|
232 | >>> import cStringIO | |
|
233 | >>> from hgclient import readchannel, runcommand, check | |
|
234 | >>> @check | |
|
235 | ... def hookoutput(server): | |
|
236 | ... readchannel(server) | |
|
237 | ... runcommand(server, ['--config', | |
|
238 | ... 'hooks.pre-identify=python:hook.hook', | |
|
239 | ... 'id'], | |
|
240 | ... input=cStringIO.StringIO('some input')) | |
|
241 | ||
|
98 | 242 | testing hookoutput: |
|
99 | 243 |
|
|
100 |
runcommand --config hooks.pre-identify=python: |
|
|
244 | runcommand --config hooks.pre-identify=python:hook.hook id | |
|
101 | 245 | hook talking |
|
102 | 246 |
now |
|
103 | 247 | eff892de26ec tip |
|
104 | 248 | |
|
249 | $ rm hook.py* | |
|
250 | ||
|
251 | $ echo a >> a | |
|
252 | >>> import os | |
|
253 | >>> from hgclient import readchannel, runcommand, check | |
|
254 | >>> @check | |
|
255 | ... def outsidechanges(server): | |
|
256 | ... readchannel(server) | |
|
257 | ... runcommand(server, ['status']) | |
|
258 | ... os.system('hg ci -Am2') | |
|
259 | ... runcommand(server, ['tip']) | |
|
260 | ... runcommand(server, ['status']) | |
|
261 | ||
|
105 | 262 | testing outsidechanges: |
|
106 | 263 |
|
|
107 | 264 | runcommand status |
@@ -115,6 +272,29 b'' | |||
|
115 | 272 |
|
|
116 | 273 | runcommand status |
|
117 | 274 | |
|
275 | >>> import os | |
|
276 | >>> from hgclient import readchannel, runcommand, check | |
|
277 | >>> @check | |
|
278 | ... def bookmarks(server): | |
|
279 | ... readchannel(server) | |
|
280 | ... runcommand(server, ['bookmarks']) | |
|
281 | ... | |
|
282 | ... # changes .hg/bookmarks | |
|
283 | ... os.system('hg bookmark -i bm1') | |
|
284 | ... os.system('hg bookmark -i bm2') | |
|
285 | ... runcommand(server, ['bookmarks']) | |
|
286 | ... | |
|
287 | ... # changes .hg/bookmarks.current | |
|
288 | ... os.system('hg upd bm1 -q') | |
|
289 | ... runcommand(server, ['bookmarks']) | |
|
290 | ... | |
|
291 | ... runcommand(server, ['bookmarks', 'bm3']) | |
|
292 | ... f = open('a', 'ab') | |
|
293 | ... f.write('a\n') | |
|
294 | ... f.close() | |
|
295 | ... runcommand(server, ['commit', '-Amm']) | |
|
296 | ... runcommand(server, ['bookmarks']) | |
|
297 | ||
|
118 | 298 | testing bookmarks: |
|
119 | 299 |
|
|
120 | 300 | runcommand bookmarks |
@@ -132,6 +312,15 b'' | |||
|
132 | 312 | bm2 1:d3a0a68be6de |
|
133 | 313 | * bm3 2:aef17e88f5f0 |
|
134 | 314 | |
|
315 | >>> import os | |
|
316 | >>> from hgclient import readchannel, runcommand, check | |
|
317 | >>> @check | |
|
318 | ... def tagscache(server): | |
|
319 | ... readchannel(server) | |
|
320 | ... runcommand(server, ['id', '-t', '-r', '0']) | |
|
321 | ... os.system('hg tag -r 0 foo') | |
|
322 | ... runcommand(server, ['id', '-t', '-r', '0']) | |
|
323 | ||
|
135 | 324 | testing tagscache: |
|
136 | 325 |
|
|
137 | 326 | runcommand id -t -r 0 |
@@ -139,6 +328,15 b'' | |||
|
139 | 328 | runcommand id -t -r 0 |
|
140 | 329 | foo |
|
141 | 330 | |
|
331 | >>> import os | |
|
332 | >>> from hgclient import readchannel, runcommand, check | |
|
333 | >>> @check | |
|
334 | ... def setphase(server): | |
|
335 | ... readchannel(server) | |
|
336 | ... runcommand(server, ['phase', '-r', '.']) | |
|
337 | ... os.system('hg phase -r . -p') | |
|
338 | ... runcommand(server, ['phase', '-r', '.']) | |
|
339 | ||
|
142 | 340 | testing setphase: |
|
143 | 341 |
|
|
144 | 342 | runcommand phase -r . |
@@ -146,6 +344,16 b'' | |||
|
146 | 344 | runcommand phase -r . |
|
147 | 345 | 3: public |
|
148 | 346 | |
|
347 | $ echo a >> a | |
|
348 | >>> from hgclient import readchannel, runcommand, check | |
|
349 | >>> @check | |
|
350 | ... def rollback(server): | |
|
351 | ... readchannel(server) | |
|
352 | ... runcommand(server, ['phase', '-r', '.', '-p']) | |
|
353 | ... runcommand(server, ['commit', '-Am.']) | |
|
354 | ... runcommand(server, ['rollback']) | |
|
355 | ... runcommand(server, ['phase', '-r', '.']) | |
|
356 | ||
|
149 | 357 | testing rollback: |
|
150 | 358 |
|
|
151 | 359 | runcommand phase -r . -p |
@@ -158,6 +366,16 b'' | |||
|
158 | 366 | runcommand phase -r . |
|
159 | 367 | 3: public |
|
160 | 368 | |
|
369 | >>> import os | |
|
370 | >>> from hgclient import readchannel, runcommand, check | |
|
371 | >>> @check | |
|
372 | ... def branch(server): | |
|
373 | ... readchannel(server) | |
|
374 | ... runcommand(server, ['branch']) | |
|
375 | ... os.system('hg branch foo') | |
|
376 | ... runcommand(server, ['branch']) | |
|
377 | ... os.system('hg branch default') | |
|
378 | ||
|
161 | 379 | testing branch: |
|
162 | 380 |
|
|
163 | 381 | runcommand branch |
@@ -169,6 +387,21 b'' | |||
|
169 | 387 | marked working directory as branch default |
|
170 | 388 | (branches are permanent and global, did you want a bookmark?) |
|
171 | 389 | |
|
390 | $ touch .hgignore | |
|
391 | >>> import os | |
|
392 | >>> from hgclient import readchannel, runcommand, check | |
|
393 | >>> @check | |
|
394 | ... def hgignore(server): | |
|
395 | ... readchannel(server) | |
|
396 | ... runcommand(server, ['commit', '-Am.']) | |
|
397 | ... f = open('ignored-file', 'ab') | |
|
398 | ... f.write('') | |
|
399 | ... f.close() | |
|
400 | ... f = open('.hgignore', 'ab') | |
|
401 | ... f.write('ignored-file') | |
|
402 | ... f.close() | |
|
403 | ... runcommand(server, ['status', '-i', '-u']) | |
|
404 | ||
|
172 | 405 | testing hgignore: |
|
173 | 406 |
|
|
174 | 407 | runcommand commit -Am. |
@@ -176,6 +409,31 b'' | |||
|
176 | 409 | runcommand status -i -u |
|
177 | 410 | I ignored-file |
|
178 | 411 | |
|
412 | >>> import os | |
|
413 | >>> from hgclient import readchannel, sep, runcommand, check | |
|
414 | >>> @check | |
|
415 | ... def phasecacheafterstrip(server): | |
|
416 | ... readchannel(server) | |
|
417 | ... | |
|
418 | ... # create new head, 5:731265503d86 | |
|
419 | ... runcommand(server, ['update', '-C', '0']) | |
|
420 | ... f = open('a', 'ab') | |
|
421 | ... f.write('a\n') | |
|
422 | ... f.close() | |
|
423 | ... runcommand(server, ['commit', '-Am.', 'a']) | |
|
424 | ... runcommand(server, ['log', '-Gq']) | |
|
425 | ... | |
|
426 | ... # make it public; draft marker moves to 4:7966c8e3734d | |
|
427 | ... runcommand(server, ['phase', '-p', '.']) | |
|
428 | ... # load _phasecache.phaseroots | |
|
429 | ... runcommand(server, ['phase', '.'], outfilter=sep) | |
|
430 | ... | |
|
431 | ... # strip 1::4 outside server | |
|
432 | ... os.system('hg -q --config extensions.mq= strip 1') | |
|
433 | ... | |
|
434 | ... # shouldn't raise "7966c8e3734d: no node!" | |
|
435 | ... runcommand(server, ['branches']) | |
|
436 | ||
|
179 | 437 | testing phasecacheafterstrip: |
|
180 | 438 | |
|
181 | 439 | runcommand update -C 0 |
@@ -202,6 +460,30 b'' | |||
|
202 | 460 | runcommand branches |
|
203 | 461 | default 1:731265503d86 |
|
204 | 462 | |
|
463 | $ cat <<EOF > obs.py | |
|
464 | > import mercurial.obsolete | |
|
465 | > mercurial.obsolete._enabled = True | |
|
466 | > EOF | |
|
467 | $ cat <<EOF >> .hg/hgrc | |
|
468 | > [extensions] | |
|
469 | > obs = obs.py | |
|
470 | > EOF | |
|
471 | ||
|
472 | >>> import os | |
|
473 | >>> from hgclient import readchannel, runcommand, check | |
|
474 | >>> @check | |
|
475 | ... def obsolete(server): | |
|
476 | ... readchannel(server) | |
|
477 | ... | |
|
478 | ... runcommand(server, ['up', 'null']) | |
|
479 | ... runcommand(server, ['phase', '-df', 'tip']) | |
|
480 | ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`' | |
|
481 | ... if os.name == 'nt': | |
|
482 | ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe | |
|
483 | ... os.system(cmd) | |
|
484 | ... runcommand(server, ['log', '--hidden']) | |
|
485 | ... runcommand(server, ['log']) | |
|
486 | ||
|
205 | 487 | testing obsolete: |
|
206 | 488 | |
|
207 | 489 | runcommand up null |
@@ -233,6 +515,28 b'' | |||
|
233 | 515 | summary: 1 |
|
234 | 516 | |
|
235 | 517 | |
|
518 | $ cat <<EOF >> .hg/hgrc | |
|
519 | > [extensions] | |
|
520 | > mq = | |
|
521 | > EOF | |
|
522 | ||
|
523 | >>> import os | |
|
524 | >>> from hgclient import readchannel, runcommand, check | |
|
525 | >>> @check | |
|
526 | ... def mqoutsidechanges(server): | |
|
527 | ... readchannel(server) | |
|
528 | ... | |
|
529 | ... # load repo.mq | |
|
530 | ... runcommand(server, ['qapplied']) | |
|
531 | ... os.system('hg qnew 0.diff') | |
|
532 | ... # repo.mq should be invalidated | |
|
533 | ... runcommand(server, ['qapplied']) | |
|
534 | ... | |
|
535 | ... runcommand(server, ['qpop', '--all']) | |
|
536 | ... os.system('hg qqueue --create foo') | |
|
537 | ... # repo.mq should be recreated to point to new queue | |
|
538 | ... runcommand(server, ['qqueue', '--active']) | |
|
539 | ||
|
236 | 540 | testing mqoutsidechanges: |
|
237 | 541 | |
|
238 | 542 | runcommand qapplied |
@@ -244,11 +548,51 b'' | |||
|
244 | 548 | runcommand qqueue --active |
|
245 | 549 | foo |
|
246 | 550 | |
|
551 | $ cat <<EOF > dbgui.py | |
|
552 | > from mercurial import cmdutil, commands | |
|
553 | > cmdtable = {} | |
|
554 | > command = cmdutil.command(cmdtable) | |
|
555 | > @command("debuggetpass", norepo=True) | |
|
556 | > def debuggetpass(ui): | |
|
557 | > ui.write("%s\\n" % ui.getpass()) | |
|
558 | > EOF | |
|
559 | $ cat <<EOF >> .hg/hgrc | |
|
560 | > [extensions] | |
|
561 | > dbgui = dbgui.py | |
|
562 | > EOF | |
|
563 | ||
|
564 | >>> import cStringIO | |
|
565 | >>> from hgclient import readchannel, runcommand, check | |
|
566 | >>> @check | |
|
567 | ... def getpass(server): | |
|
568 | ... readchannel(server) | |
|
569 | ... runcommand(server, ['debuggetpass', '--config', | |
|
570 | ... 'ui.interactive=True'], | |
|
571 | ... input=cStringIO.StringIO('1234\n')) | |
|
572 | ||
|
247 | 573 | testing getpass: |
|
248 | 574 | |
|
249 | 575 | runcommand debuggetpass --config ui.interactive=True |
|
250 | 576 | password: 1234 |
|
251 | 577 | |
|
578 | ||
|
579 | start without repository: | |
|
580 | ||
|
581 | $ cd .. | |
|
582 | ||
|
583 | >>> import re | |
|
584 | >>> from hgclient import readchannel, runcommand, check | |
|
585 | >>> @check | |
|
586 | ... def hellomessage(server): | |
|
587 | ... ch, data = readchannel(server) | |
|
588 | ... # escaping python tests output not supported | |
|
589 | ... print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', | |
|
590 | ... 'encoding: ***', data)) | |
|
591 | ... | |
|
592 | ... # run an arbitrary command to make sure the next thing the server | |
|
593 | ... # sends isn't part of the hello message | |
|
594 | ... runcommand(server, ['id']) | |
|
595 | ||
|
252 | 596 | testing hellomessage: |
|
253 | 597 |
|
|
254 | 598 |
o, |
@@ -256,6 +600,13 b'' | |||
|
256 | 600 | abort: there is no Mercurial repository here (.hg not found) |
|
257 | 601 | [255] |
|
258 | 602 | |
|
603 | >>> from hgclient import readchannel, runcommand, check | |
|
604 | >>> @check | |
|
605 | ... def startwithoutrepo(server): | |
|
606 | ... readchannel(server) | |
|
607 | ... runcommand(server, ['init', 'repo2']) | |
|
608 | ... runcommand(server, ['id', '-R', 'repo2']) | |
|
609 | ||
|
259 | 610 | testing startwithoutrepo: |
|
260 | 611 |
|
|
261 | 612 | runcommand init repo2 |
General Comments 0
You need to be logged in to leave comments.
Login now