Show More
@@ -1,263 +1,614 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 |
|
|
5 | 26 |
o, |
|
6 | 27 | runcommand id |
|
7 | 28 | 000000000000 tip |
|
29 | ||
|
30 | >>> from hgclient import check | |
|
31 | >>> @check | |
|
32 | ... def unknowncommand(server): | |
|
33 | ... server.stdin.write('unknowncommand\n') | |
|
8 | 34 |
|
|
9 | 35 | testing unknowncommand: |
|
10 | 36 |
|
|
11 | 37 | abort: unknown command unknowncommand |
|
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']) | |
|
12 | 62 |
|
|
13 | 63 | testing checkruncommand: |
|
14 | 64 |
|
|
15 | 65 | runcommand |
|
16 | 66 | Mercurial Distributed SCM |
|
17 | 67 |
|
|
18 | 68 | basic commands: |
|
19 | 69 |
|
|
20 | 70 | add add the specified files on the next commit |
|
21 | 71 | annotate show changeset information by line for each file |
|
22 | 72 | clone make a copy of an existing repository |
|
23 | 73 | commit commit the specified files or all outstanding changes |
|
24 | 74 | diff diff repository (or selected files) |
|
25 | 75 | export dump the header and diffs for one or more changesets |
|
26 | 76 | forget forget the specified files on the next commit |
|
27 | 77 | init create a new repository in the given directory |
|
28 | 78 | log show revision history of entire repository or files |
|
29 | 79 | merge merge working directory with another revision |
|
30 | 80 | pull pull changes from the specified source |
|
31 | 81 | push push changes to the specified destination |
|
32 | 82 | remove remove the specified files on the next commit |
|
33 | 83 | serve start stand-alone webserver |
|
34 | 84 | status show changed files in the working directory |
|
35 | 85 | summary summarize working directory state |
|
36 | 86 | update update working directory (or switch revisions) |
|
37 | 87 |
|
|
38 | 88 | (use "hg help" for the full list of commands or "hg -v" for details) |
|
39 | 89 | runcommand id --quiet |
|
40 | 90 | 000000000000 |
|
41 | 91 | runcommand id |
|
42 | 92 | 000000000000 tip |
|
43 | 93 | runcommand id --config ui.quiet=True |
|
44 | 94 | 000000000000 |
|
45 | 95 | runcommand id |
|
46 | 96 | 000000000000 tip |
|
47 | 97 | runcommand id -runknown |
|
48 | 98 |
abort: unknown revision 'unknown'! |
|
49 | 99 | [255] |
|
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() | |
|
50 | 111 |
|
|
51 | 112 | testing inputeof: |
|
52 | 113 |
|
|
53 | 114 | server exit code = 1 |
|
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']) | |
|
54 | 139 |
|
|
55 | 140 | testing serverinput: |
|
56 | 141 |
|
|
57 | 142 | runcommand import - |
|
58 | 143 | applying patch from stdin |
|
59 | 144 | runcommand log |
|
60 | 145 | changeset: 0:eff892de26ec |
|
61 | 146 | tag: tip |
|
62 | 147 | user: test |
|
63 | 148 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
64 | 149 | summary: 1 |
|
65 | 150 |
|
|
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']) | |
|
66 | 162 | |
|
67 | 163 | testing cwd: |
|
68 | 164 | |
|
69 | 165 | runcommand --cwd foo st bar |
|
70 | 166 | ? bar |
|
71 | 167 | runcommand st foo/bar |
|
72 | 168 | ? foo/bar |
|
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']) | |
|
73 | 192 |
|
|
74 | 193 | testing localhgrc: |
|
75 | 194 |
|
|
76 | 195 | runcommand showconfig |
|
77 | 196 | bundle.mainreporoot=$TESTTMP/repo |
|
78 | 197 | defaults.backout=-d "0 0" |
|
79 | 198 | defaults.commit=-d "0 0" |
|
80 | 199 | defaults.shelve=--date "0 0" |
|
81 | 200 | defaults.tag=-d "0 0" |
|
82 | 201 | ui.slash=True |
|
83 | 202 | ui.interactive=False |
|
84 | 203 | ui.mergemarkers=detailed |
|
85 | 204 | ui.foo=bar |
|
86 | 205 | ui.nontty=true |
|
87 | 206 | runcommand init foo |
|
88 | 207 | runcommand -R foo showconfig ui defaults |
|
89 | 208 | defaults.backout=-d "0 0" |
|
90 | 209 | defaults.commit=-d "0 0" |
|
91 | 210 | defaults.shelve=--date "0 0" |
|
92 | 211 | defaults.tag=-d "0 0" |
|
93 | 212 | ui.slash=True |
|
94 | 213 | ui.interactive=False |
|
95 | 214 | ui.mergemarkers=detailed |
|
96 | 215 | ui.nontty=true |
|
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')) | |
|
97 | 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 |
|
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']) | |
|
104 | 261 |
|
|
105 | 262 | testing outsidechanges: |
|
106 | 263 |
|
|
107 | 264 | runcommand status |
|
108 | 265 | M a |
|
109 | 266 | runcommand tip |
|
110 | 267 | changeset: 1:d3a0a68be6de |
|
111 | 268 | tag: tip |
|
112 | 269 | user: test |
|
113 | 270 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
114 | 271 | summary: 2 |
|
115 | 272 |
|
|
116 | 273 | runcommand status |
|
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']) | |
|
117 | 297 |
|
|
118 | 298 | testing bookmarks: |
|
119 | 299 |
|
|
120 | 300 | runcommand bookmarks |
|
121 | 301 | no bookmarks set |
|
122 | 302 | runcommand bookmarks |
|
123 | 303 | bm1 1:d3a0a68be6de |
|
124 | 304 | bm2 1:d3a0a68be6de |
|
125 | 305 | runcommand bookmarks |
|
126 | 306 | * bm1 1:d3a0a68be6de |
|
127 | 307 | bm2 1:d3a0a68be6de |
|
128 | 308 | runcommand bookmarks bm3 |
|
129 | 309 | runcommand commit -Amm |
|
130 | 310 | runcommand bookmarks |
|
131 | 311 | bm1 1:d3a0a68be6de |
|
132 | 312 | bm2 1:d3a0a68be6de |
|
133 | 313 | * bm3 2:aef17e88f5f0 |
|
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']) | |
|
134 | 323 |
|
|
135 | 324 | testing tagscache: |
|
136 | 325 |
|
|
137 | 326 | runcommand id -t -r 0 |
|
138 | 327 |
|
|
139 | 328 | runcommand id -t -r 0 |
|
140 | 329 | foo |
|
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', '.']) | |
|
141 | 339 |
|
|
142 | 340 | testing setphase: |
|
143 | 341 |
|
|
144 | 342 | runcommand phase -r . |
|
145 | 343 | 3: draft |
|
146 | 344 | runcommand phase -r . |
|
147 | 345 | 3: public |
|
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', '.']) | |
|
148 | 356 |
|
|
149 | 357 | testing rollback: |
|
150 | 358 |
|
|
151 | 359 | runcommand phase -r . -p |
|
152 | 360 | no phases changed |
|
153 | 361 | [1] |
|
154 | 362 | runcommand commit -Am. |
|
155 | 363 | runcommand rollback |
|
156 | 364 | repository tip rolled back to revision 3 (undo commit) |
|
157 | 365 | working directory now based on revision 3 |
|
158 | 366 | runcommand phase -r . |
|
159 | 367 | 3: public |
|
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') | |
|
160 | 378 |
|
|
161 | 379 | testing branch: |
|
162 | 380 |
|
|
163 | 381 | runcommand branch |
|
164 | 382 | default |
|
165 | 383 | marked working directory as branch foo |
|
166 | 384 | (branches are permanent and global, did you want a bookmark?) |
|
167 | 385 | runcommand branch |
|
168 | 386 | foo |
|
169 | 387 | marked working directory as branch default |
|
170 | 388 | (branches are permanent and global, did you want a bookmark?) |
|
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']) | |
|
171 | 404 |
|
|
172 | 405 | testing hgignore: |
|
173 | 406 |
|
|
174 | 407 | runcommand commit -Am. |
|
175 | 408 | adding .hgignore |
|
176 | 409 | runcommand status -i -u |
|
177 | 410 | I ignored-file |
|
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']) | |
|
178 | 436 | |
|
179 | 437 | testing phasecacheafterstrip: |
|
180 | 438 | |
|
181 | 439 | runcommand update -C 0 |
|
182 | 440 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
183 | 441 | (leaving bookmark bm3) |
|
184 | 442 | runcommand commit -Am. a |
|
185 | 443 | created new head |
|
186 | 444 | runcommand log -Gq |
|
187 | 445 | @ 5:731265503d86 |
|
188 | 446 | | |
|
189 | 447 | | o 4:7966c8e3734d |
|
190 | 448 | | | |
|
191 | 449 | | o 3:b9b85890c400 |
|
192 | 450 | | | |
|
193 | 451 | | o 2:aef17e88f5f0 |
|
194 | 452 | | | |
|
195 | 453 | | o 1:d3a0a68be6de |
|
196 | 454 | |/ |
|
197 | 455 | o 0:eff892de26ec |
|
198 | 456 | |
|
199 | 457 | runcommand phase -p . |
|
200 | 458 | runcommand phase . |
|
201 | 459 | 5: public |
|
202 | 460 | runcommand branches |
|
203 | 461 | default 1:731265503d86 |
|
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']) | |
|
204 | 486 | |
|
205 | 487 | testing obsolete: |
|
206 | 488 | |
|
207 | 489 | runcommand up null |
|
208 | 490 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
209 | 491 | runcommand phase -df tip |
|
210 | 492 | runcommand log --hidden |
|
211 | 493 | changeset: 1:731265503d86 |
|
212 | 494 | tag: tip |
|
213 | 495 | user: test |
|
214 | 496 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
215 | 497 | summary: . |
|
216 | 498 | |
|
217 | 499 | changeset: 0:eff892de26ec |
|
218 | 500 | bookmark: bm1 |
|
219 | 501 | bookmark: bm2 |
|
220 | 502 | bookmark: bm3 |
|
221 | 503 | user: test |
|
222 | 504 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
223 | 505 | summary: 1 |
|
224 | 506 | |
|
225 | 507 | runcommand log |
|
226 | 508 | changeset: 0:eff892de26ec |
|
227 | 509 | bookmark: bm1 |
|
228 | 510 | bookmark: bm2 |
|
229 | 511 | bookmark: bm3 |
|
230 | 512 | tag: tip |
|
231 | 513 | user: test |
|
232 | 514 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
233 | 515 | summary: 1 |
|
234 | 516 | |
|
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']) | |
|
235 | 539 | |
|
236 | 540 | testing mqoutsidechanges: |
|
237 | 541 | |
|
238 | 542 | runcommand qapplied |
|
239 | 543 | runcommand qapplied |
|
240 | 544 | 0.diff |
|
241 | 545 | runcommand qpop --all |
|
242 | 546 | popping 0.diff |
|
243 | 547 | patch queue now empty |
|
244 | 548 | runcommand qqueue --active |
|
245 | 549 | foo |
|
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')) | |
|
246 | 572 | |
|
247 | 573 | testing getpass: |
|
248 | 574 | |
|
249 | 575 | runcommand debuggetpass --config ui.interactive=True |
|
250 | 576 | password: 1234 |
|
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']) | |
|
251 | 595 |
|
|
252 | 596 | testing hellomessage: |
|
253 | 597 |
|
|
254 | 598 |
o, |
|
255 | 599 | runcommand id |
|
256 | 600 | abort: there is no Mercurial repository here (.hg not found) |
|
257 | 601 | [255] |
|
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']) | |
|
258 | 609 |
|
|
259 | 610 | testing startwithoutrepo: |
|
260 | 611 |
|
|
261 | 612 | runcommand init repo2 |
|
262 | 613 | runcommand id -R repo2 |
|
263 | 614 | 000000000000 tip |
General Comments 0
You need to be logged in to leave comments.
Login now