##// END OF EJS Templates
bundle2: use a smarter template for test...
Pierre-Yves David -
r21647:1a6909f4 default
parent child Browse files
Show More
@@ -1,1121 +1,1051 b''
1 1
2 2 Create an extension to test bundle2 API
3 3
4 4 $ cat > bundle2.py << EOF
5 5 > """A small extension to test bundle2 implementation
6 6 >
7 7 > Current bundle2 implementation is far too limited to be used in any core
8 8 > code. We still need to be able to test it while it grow up.
9 9 > """
10 10 >
11 11 > try:
12 12 > import msvcrt
13 13 > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
14 14 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
15 15 > msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
16 16 > except ImportError:
17 17 > pass
18 18 >
19 19 > import sys
20 20 > from mercurial import cmdutil
21 21 > from mercurial import util
22 22 > from mercurial import bundle2
23 23 > from mercurial import scmutil
24 24 > from mercurial import discovery
25 25 > from mercurial import changegroup
26 26 > from mercurial import error
27 27 > cmdtable = {}
28 28 > command = cmdutil.command(cmdtable)
29 29 >
30 30 > ELEPHANTSSONG = """Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
31 31 > Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
32 32 > Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko."""
33 33 > assert len(ELEPHANTSSONG) == 178 # future test say 178 bytes, trust it.
34 34 >
35 35 > @bundle2.parthandler('test:song')
36 36 > def songhandler(op, part):
37 37 > """handle a "test:song" bundle2 part, printing the lyrics on stdin"""
38 38 > op.ui.write('The choir starts singing:\n')
39 39 > verses = 0
40 40 > for line in part.read().split('\n'):
41 41 > op.ui.write(' %s\n' % line)
42 42 > verses += 1
43 43 > op.records.add('song', {'verses': verses})
44 44 >
45 45 > @bundle2.parthandler('test:ping')
46 46 > def pinghandler(op, part):
47 47 > op.ui.write('received ping request (id %i)\n' % part.id)
48 48 > if op.reply is not None and 'ping-pong' in op.reply.capabilities:
49 49 > op.ui.write_err('replying to ping request (id %i)\n' % part.id)
50 50 > op.reply.newpart('test:pong', [('in-reply-to', str(part.id))])
51 51 >
52 52 > @bundle2.parthandler('test:debugreply')
53 53 > def debugreply(op, part):
54 54 > """print data about the capacity of the bundle reply"""
55 55 > if op.reply is None:
56 56 > op.ui.write('debugreply: no reply\n')
57 57 > else:
58 58 > op.ui.write('debugreply: capabilities:\n')
59 59 > for cap in sorted(op.reply.capabilities):
60 60 > op.ui.write('debugreply: %r\n' % cap)
61 61 > for val in op.reply.capabilities[cap]:
62 62 > op.ui.write('debugreply: %r\n' % val)
63 63 >
64 64 > @command('bundle2',
65 65 > [('', 'param', [], 'stream level parameter'),
66 66 > ('', 'unknown', False, 'include an unknown mandatory part in the bundle'),
67 67 > ('', 'unknownparams', False, 'include an unknown part parameters in the bundle'),
68 68 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),
69 69 > ('', 'reply', False, 'produce a reply bundle'),
70 70 > ('', 'pushrace', False, 'includes a check:head part with unknown nodes'),
71 71 > ('r', 'rev', [], 'includes those changeset in the bundle'),],
72 72 > '[OUTPUTFILE]')
73 73 > def cmdbundle2(ui, repo, path=None, **opts):
74 74 > """write a bundle2 container on standard ouput"""
75 75 > bundler = bundle2.bundle20(ui)
76 76 > for p in opts['param']:
77 77 > p = p.split('=', 1)
78 78 > try:
79 79 > bundler.addparam(*p)
80 80 > except ValueError, exc:
81 81 > raise util.Abort('%s' % exc)
82 82 >
83 83 > if opts['reply']:
84 84 > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville'
85 85 > bundler.newpart('b2x:replycaps', data=capsstring)
86 86 >
87 87 > if opts['pushrace']:
88 88 > # also serve to test the assignement of data outside of init
89 89 > part = bundler.newpart('b2x:check:heads')
90 90 > part.data = '01234567890123456789'
91 91 >
92 92 > revs = opts['rev']
93 93 > if 'rev' in opts:
94 94 > revs = scmutil.revrange(repo, opts['rev'])
95 95 > if revs:
96 96 > # very crude version of a changegroup part creation
97 97 > bundled = repo.revs('%ld::%ld', revs, revs)
98 98 > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)]
99 99 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
100 100 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
101 101 > cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None)
102 102 > bundler.newpart('b2x:changegroup', data=cg.getchunks())
103 103 >
104 104 > if opts['parts']:
105 105 > bundler.newpart('test:empty')
106 106 > # add a second one to make sure we handle multiple parts
107 107 > bundler.newpart('test:empty')
108 108 > bundler.newpart('test:song', data=ELEPHANTSSONG)
109 109 > bundler.newpart('test:debugreply')
110 110 > mathpart = bundler.newpart('test:math')
111 111 > mathpart.addparam('pi', '3.14')
112 112 > mathpart.addparam('e', '2.72')
113 113 > mathpart.addparam('cooking', 'raw', mandatory=False)
114 114 > mathpart.data = '42'
115 115 > # advisory known part with unknown mandatory param
116 116 > bundler.newpart('test:song', [('randomparam','')])
117 117 > if opts['unknown']:
118 118 > bundler.newpart('test:UNKNOWN', data='some random content')
119 119 > if opts['unknownparams']:
120 120 > bundler.newpart('test:SONG', [('randomparams', '')])
121 121 > if opts['parts']:
122 122 > bundler.newpart('test:ping')
123 123 >
124 124 > if path is None:
125 125 > file = sys.stdout
126 126 > else:
127 127 > file = open(path, 'w')
128 128 >
129 129 > for chunk in bundler.getchunks():
130 130 > file.write(chunk)
131 131 >
132 132 > @command('unbundle2', [], '')
133 133 > def cmdunbundle2(ui, repo, replypath=None):
134 134 > """process a bundle2 stream from stdin on the current repo"""
135 135 > try:
136 136 > tr = None
137 137 > lock = repo.lock()
138 138 > tr = repo.transaction('processbundle')
139 139 > try:
140 140 > unbundler = bundle2.unbundle20(ui, sys.stdin)
141 141 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
142 142 > tr.close()
143 143 > except error.BundleValueError, exc:
144 144 > raise util.Abort('missing support for %s' % exc)
145 145 > except error.PushRaced, exc:
146 146 > raise util.Abort('push race: %s' % exc)
147 147 > finally:
148 148 > if tr is not None:
149 149 > tr.release()
150 150 > lock.release()
151 151 > remains = sys.stdin.read()
152 152 > ui.write('%i unread bytes\n' % len(remains))
153 153 > if op.records['song']:
154 154 > totalverses = sum(r['verses'] for r in op.records['song'])
155 155 > ui.write('%i total verses sung\n' % totalverses)
156 156 > for rec in op.records['changegroup']:
157 157 > ui.write('addchangegroup return: %i\n' % rec['return'])
158 158 > if op.reply is not None and replypath is not None:
159 159 > file = open(replypath, 'w')
160 160 > for chunk in op.reply.getchunks():
161 161 > file.write(chunk)
162 162 >
163 163 > @command('statbundle2', [], '')
164 164 > def cmdstatbundle2(ui, repo):
165 165 > """print statistic on the bundle2 container read from stdin"""
166 166 > unbundler = bundle2.unbundle20(ui, sys.stdin)
167 167 > try:
168 168 > params = unbundler.params
169 169 > except error.BundleValueError, exc:
170 170 > raise util.Abort('unknown parameters: %s' % exc)
171 171 > ui.write('options count: %i\n' % len(params))
172 172 > for key in sorted(params):
173 173 > ui.write('- %s\n' % key)
174 174 > value = params[key]
175 175 > if value is not None:
176 176 > ui.write(' %s\n' % value)
177 177 > count = 0
178 178 > for p in unbundler.iterparts():
179 179 > count += 1
180 180 > ui.write(' :%s:\n' % p.type)
181 181 > ui.write(' mandatory: %i\n' % len(p.mandatoryparams))
182 182 > ui.write(' advisory: %i\n' % len(p.advisoryparams))
183 183 > ui.write(' payload: %i bytes\n' % len(p.read()))
184 184 > ui.write('parts count: %i\n' % count)
185 185 > EOF
186 186 $ cat >> $HGRCPATH << EOF
187 187 > [extensions]
188 188 > bundle2=$TESTTMP/bundle2.py
189 189 > [experimental]
190 190 > bundle2-exp=True
191 191 > [ui]
192 192 > ssh=python "$TESTDIR/dummyssh"
193 > logtemplate={rev}:{node|short} {phase} {author} {desc|firstline}
193 194 > [web]
194 195 > push_ssl = false
195 196 > allow_push = *
196 197 > EOF
197 198
198 199 The extension requires a repo (currently unused)
199 200
200 201 $ hg init main
201 202 $ cd main
202 203 $ touch a
203 204 $ hg add a
204 205 $ hg commit -m 'a'
205 206
206 207
207 208 Empty bundle
208 209 =================
209 210
210 211 - no option
211 212 - no parts
212 213
213 214 Test bundling
214 215
215 216 $ hg bundle2
216 217 HG2X\x00\x00\x00\x00 (no-eol) (esc)
217 218
218 219 Test unbundling
219 220
220 221 $ hg bundle2 | hg statbundle2
221 222 options count: 0
222 223 parts count: 0
223 224
224 225 Test old style bundle are detected and refused
225 226
226 227 $ hg bundle --all ../bundle.hg
227 228 1 changesets found
228 229 $ hg statbundle2 < ../bundle.hg
229 230 abort: unknown bundle version 10
230 231 [255]
231 232
232 233 Test parameters
233 234 =================
234 235
235 236 - some options
236 237 - no parts
237 238
238 239 advisory parameters, no value
239 240 -------------------------------
240 241
241 242 Simplest possible parameters form
242 243
243 244 Test generation simple option
244 245
245 246 $ hg bundle2 --param 'caution'
246 247 HG2X\x00\x07caution\x00\x00 (no-eol) (esc)
247 248
248 249 Test unbundling
249 250
250 251 $ hg bundle2 --param 'caution' | hg statbundle2
251 252 options count: 1
252 253 - caution
253 254 parts count: 0
254 255
255 256 Test generation multiple option
256 257
257 258 $ hg bundle2 --param 'caution' --param 'meal'
258 259 HG2X\x00\x0ccaution meal\x00\x00 (no-eol) (esc)
259 260
260 261 Test unbundling
261 262
262 263 $ hg bundle2 --param 'caution' --param 'meal' | hg statbundle2
263 264 options count: 2
264 265 - caution
265 266 - meal
266 267 parts count: 0
267 268
268 269 advisory parameters, with value
269 270 -------------------------------
270 271
271 272 Test generation
272 273
273 274 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants'
274 275 HG2X\x00\x1ccaution meal=vegan elephants\x00\x00 (no-eol) (esc)
275 276
276 277 Test unbundling
277 278
278 279 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | hg statbundle2
279 280 options count: 3
280 281 - caution
281 282 - elephants
282 283 - meal
283 284 vegan
284 285 parts count: 0
285 286
286 287 parameter with special char in value
287 288 ---------------------------------------------------
288 289
289 290 Test generation
290 291
291 292 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple
292 293 HG2X\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
293 294
294 295 Test unbundling
295 296
296 297 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple | hg statbundle2
297 298 options count: 2
298 299 - e|! 7/
299 300 babar%#==tutu
300 301 - simple
301 302 parts count: 0
302 303
303 304 Test unknown mandatory option
304 305 ---------------------------------------------------
305 306
306 307 $ hg bundle2 --param 'Gravity' | hg statbundle2
307 308 abort: unknown parameters: Stream Parameter - Gravity
308 309 [255]
309 310
310 311 Test debug output
311 312 ---------------------------------------------------
312 313
313 314 bundling debug
314 315
315 316 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
316 317 start emission of HG2X stream
317 318 bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
318 319 start of parts
319 320 end of bundle
320 321
321 322 file content is ok
322 323
323 324 $ cat ../out.hg2
324 325 HG2X\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
325 326
326 327 unbundling debug
327 328
328 329 $ hg statbundle2 --debug < ../out.hg2
329 330 start processing of HG2X stream
330 331 reading bundle2 stream parameters
331 332 ignoring unknown parameter 'e|! 7/'
332 333 ignoring unknown parameter 'simple'
333 334 options count: 2
334 335 - e|! 7/
335 336 babar%#==tutu
336 337 - simple
337 338 start extraction of bundle2 parts
338 339 part header size: 0
339 340 end of bundle2 stream
340 341 parts count: 0
341 342
342 343
343 344 Test buggy input
344 345 ---------------------------------------------------
345 346
346 347 empty parameter name
347 348
348 349 $ hg bundle2 --param '' --quiet
349 350 abort: empty parameter name
350 351 [255]
351 352
352 353 bad parameter name
353 354
354 355 $ hg bundle2 --param 42babar
355 356 abort: non letter first character: '42babar'
356 357 [255]
357 358
358 359
359 360 Test part
360 361 =================
361 362
362 363 $ hg bundle2 --parts ../parts.hg2 --debug
363 364 start emission of HG2X stream
364 365 bundle parameter:
365 366 start of parts
366 367 bundle part: "test:empty"
367 368 bundle part: "test:empty"
368 369 bundle part: "test:song"
369 370 bundle part: "test:debugreply"
370 371 bundle part: "test:math"
371 372 bundle part: "test:song"
372 373 bundle part: "test:ping"
373 374 end of bundle
374 375
375 376 $ cat ../parts.hg2
376 377 HG2X\x00\x00\x00\x11 (esc)
377 378 test:empty\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11 (esc)
378 379 test:empty\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x10 test:song\x00\x00\x00\x02\x00\x00\x00\x00\x00\xb2Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko (esc)
379 380 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
380 381 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.\x00\x00\x00\x00\x00\x16\x0ftest:debugreply\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00+ test:math\x00\x00\x00\x04\x02\x01\x02\x04\x01\x04\x07\x03pi3.14e2.72cookingraw\x00\x00\x00\x0242\x00\x00\x00\x00\x00\x1d test:song\x00\x00\x00\x05\x01\x00\x0b\x00randomparam\x00\x00\x00\x00\x00\x10 test:ping\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
381 382
382 383
383 384 $ hg statbundle2 < ../parts.hg2
384 385 options count: 0
385 386 :test:empty:
386 387 mandatory: 0
387 388 advisory: 0
388 389 payload: 0 bytes
389 390 :test:empty:
390 391 mandatory: 0
391 392 advisory: 0
392 393 payload: 0 bytes
393 394 :test:song:
394 395 mandatory: 0
395 396 advisory: 0
396 397 payload: 178 bytes
397 398 :test:debugreply:
398 399 mandatory: 0
399 400 advisory: 0
400 401 payload: 0 bytes
401 402 :test:math:
402 403 mandatory: 2
403 404 advisory: 1
404 405 payload: 2 bytes
405 406 :test:song:
406 407 mandatory: 1
407 408 advisory: 0
408 409 payload: 0 bytes
409 410 :test:ping:
410 411 mandatory: 0
411 412 advisory: 0
412 413 payload: 0 bytes
413 414 parts count: 7
414 415
415 416 $ hg statbundle2 --debug < ../parts.hg2
416 417 start processing of HG2X stream
417 418 reading bundle2 stream parameters
418 419 options count: 0
419 420 start extraction of bundle2 parts
420 421 part header size: 17
421 422 part type: "test:empty"
422 423 part id: "0"
423 424 part parameters: 0
424 425 :test:empty:
425 426 mandatory: 0
426 427 advisory: 0
427 428 payload chunk size: 0
428 429 payload: 0 bytes
429 430 part header size: 17
430 431 part type: "test:empty"
431 432 part id: "1"
432 433 part parameters: 0
433 434 :test:empty:
434 435 mandatory: 0
435 436 advisory: 0
436 437 payload chunk size: 0
437 438 payload: 0 bytes
438 439 part header size: 16
439 440 part type: "test:song"
440 441 part id: "2"
441 442 part parameters: 0
442 443 :test:song:
443 444 mandatory: 0
444 445 advisory: 0
445 446 payload chunk size: 178
446 447 payload chunk size: 0
447 448 payload: 178 bytes
448 449 part header size: 22
449 450 part type: "test:debugreply"
450 451 part id: "3"
451 452 part parameters: 0
452 453 :test:debugreply:
453 454 mandatory: 0
454 455 advisory: 0
455 456 payload chunk size: 0
456 457 payload: 0 bytes
457 458 part header size: 43
458 459 part type: "test:math"
459 460 part id: "4"
460 461 part parameters: 3
461 462 :test:math:
462 463 mandatory: 2
463 464 advisory: 1
464 465 payload chunk size: 2
465 466 payload chunk size: 0
466 467 payload: 2 bytes
467 468 part header size: 29
468 469 part type: "test:song"
469 470 part id: "5"
470 471 part parameters: 1
471 472 :test:song:
472 473 mandatory: 1
473 474 advisory: 0
474 475 payload chunk size: 0
475 476 payload: 0 bytes
476 477 part header size: 16
477 478 part type: "test:ping"
478 479 part id: "6"
479 480 part parameters: 0
480 481 :test:ping:
481 482 mandatory: 0
482 483 advisory: 0
483 484 payload chunk size: 0
484 485 payload: 0 bytes
485 486 part header size: 0
486 487 end of bundle2 stream
487 488 parts count: 7
488 489
489 490 Test actual unbundling of test part
490 491 =======================================
491 492
492 493 Process the bundle
493 494
494 495 $ hg unbundle2 --debug < ../parts.hg2
495 496 start processing of HG2X stream
496 497 reading bundle2 stream parameters
497 498 start extraction of bundle2 parts
498 499 part header size: 17
499 500 part type: "test:empty"
500 501 part id: "0"
501 502 part parameters: 0
502 503 ignoring unsupported advisory part test:empty
503 504 payload chunk size: 0
504 505 part header size: 17
505 506 part type: "test:empty"
506 507 part id: "1"
507 508 part parameters: 0
508 509 ignoring unsupported advisory part test:empty
509 510 payload chunk size: 0
510 511 part header size: 16
511 512 part type: "test:song"
512 513 part id: "2"
513 514 part parameters: 0
514 515 found a handler for part 'test:song'
515 516 The choir starts singing:
516 517 payload chunk size: 178
517 518 payload chunk size: 0
518 519 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
519 520 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
520 521 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
521 522 part header size: 22
522 523 part type: "test:debugreply"
523 524 part id: "3"
524 525 part parameters: 0
525 526 found a handler for part 'test:debugreply'
526 527 debugreply: no reply
527 528 payload chunk size: 0
528 529 part header size: 43
529 530 part type: "test:math"
530 531 part id: "4"
531 532 part parameters: 3
532 533 ignoring unsupported advisory part test:math
533 534 payload chunk size: 2
534 535 payload chunk size: 0
535 536 part header size: 29
536 537 part type: "test:song"
537 538 part id: "5"
538 539 part parameters: 1
539 540 found a handler for part 'test:song'
540 541 ignoring unsupported advisory part test:song - randomparam
541 542 payload chunk size: 0
542 543 part header size: 16
543 544 part type: "test:ping"
544 545 part id: "6"
545 546 part parameters: 0
546 547 found a handler for part 'test:ping'
547 548 received ping request (id 6)
548 549 payload chunk size: 0
549 550 part header size: 0
550 551 end of bundle2 stream
551 552 0 unread bytes
552 553 3 total verses sung
553 554
554 555 Unbundle with an unknown mandatory part
555 556 (should abort)
556 557
557 558 $ hg bundle2 --parts --unknown ../unknown.hg2
558 559
559 560 $ hg unbundle2 < ../unknown.hg2
560 561 The choir starts singing:
561 562 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
562 563 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
563 564 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
564 565 debugreply: no reply
565 566 0 unread bytes
566 567 abort: missing support for test:unknown
567 568 [255]
568 569
569 570 Unbundle with an unknown mandatory part parameters
570 571 (should abort)
571 572
572 573 $ hg bundle2 --unknownparams ../unknown.hg2
573 574
574 575 $ hg unbundle2 < ../unknown.hg2
575 576 0 unread bytes
576 577 abort: missing support for test:song - randomparams
577 578 [255]
578 579
579 580 unbundle with a reply
580 581
581 582 $ hg bundle2 --parts --reply ../parts-reply.hg2
582 583 $ hg unbundle2 ../reply.hg2 < ../parts-reply.hg2
583 584 0 unread bytes
584 585 3 total verses sung
585 586
586 587 The reply is a bundle
587 588
588 589 $ cat ../reply.hg2
589 590 HG2X\x00\x00\x00\x1f (esc)
590 591 b2x:output\x00\x00\x00\x00\x00\x01\x0b\x01in-reply-to3\x00\x00\x00\xd9The choir starts singing: (esc)
591 592 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
592 593 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
593 594 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
594 595 \x00\x00\x00\x00\x00\x1f (esc)
595 596 b2x:output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to4\x00\x00\x00\xc9debugreply: capabilities: (esc)
596 597 debugreply: 'city=!'
597 598 debugreply: 'celeste,ville'
598 599 debugreply: 'elephants'
599 600 debugreply: 'babar'
600 601 debugreply: 'celeste'
601 602 debugreply: 'ping-pong'
602 603 \x00\x00\x00\x00\x00\x1e test:pong\x00\x00\x00\x02\x01\x00\x0b\x01in-reply-to7\x00\x00\x00\x00\x00\x1f (esc)
603 604 b2x:output\x00\x00\x00\x03\x00\x01\x0b\x01in-reply-to7\x00\x00\x00=received ping request (id 7) (esc)
604 605 replying to ping request (id 7)
605 606 \x00\x00\x00\x00\x00\x00 (no-eol) (esc)
606 607
607 608 The reply is valid
608 609
609 610 $ hg statbundle2 < ../reply.hg2
610 611 options count: 0
611 612 :b2x:output:
612 613 mandatory: 0
613 614 advisory: 1
614 615 payload: 217 bytes
615 616 :b2x:output:
616 617 mandatory: 0
617 618 advisory: 1
618 619 payload: 201 bytes
619 620 :test:pong:
620 621 mandatory: 1
621 622 advisory: 0
622 623 payload: 0 bytes
623 624 :b2x:output:
624 625 mandatory: 0
625 626 advisory: 1
626 627 payload: 61 bytes
627 628 parts count: 4
628 629
629 630 Unbundle the reply to get the output:
630 631
631 632 $ hg unbundle2 < ../reply.hg2
632 633 remote: The choir starts singing:
633 634 remote: Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
634 635 remote: Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
635 636 remote: Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
636 637 remote: debugreply: capabilities:
637 638 remote: debugreply: 'city=!'
638 639 remote: debugreply: 'celeste,ville'
639 640 remote: debugreply: 'elephants'
640 641 remote: debugreply: 'babar'
641 642 remote: debugreply: 'celeste'
642 643 remote: debugreply: 'ping-pong'
643 644 remote: received ping request (id 7)
644 645 remote: replying to ping request (id 7)
645 646 0 unread bytes
646 647
647 648 Test push race detection
648 649
649 650 $ hg bundle2 --pushrace ../part-race.hg2
650 651
651 652 $ hg unbundle2 < ../part-race.hg2
652 653 0 unread bytes
653 654 abort: push race: repository changed while pushing - please try again
654 655 [255]
655 656
656 657 Support for changegroup
657 658 ===================================
658 659
659 660 $ hg unbundle $TESTDIR/bundles/rebase.hg
660 661 adding changesets
661 662 adding manifests
662 663 adding file changes
663 664 added 8 changesets with 7 changes to 7 files (+3 heads)
664 665 (run 'hg heads' to see heads, 'hg merge' to merge)
665 666
666 667 $ hg log -G
667 o changeset: 8:02de42196ebe
668 | tag: tip
669 | parent: 6:24b6387c8c8c
670 | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
671 | date: Sat Apr 30 15:24:48 2011 +0200
672 | summary: H
673 |
674 | o changeset: 7:eea13746799a
675 |/| parent: 6:24b6387c8c8c
676 | | parent: 5:9520eea781bc
677 | | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
678 | | date: Sat Apr 30 15:24:48 2011 +0200
679 | | summary: G
680 | |
681 o | changeset: 6:24b6387c8c8c
682 | | parent: 1:cd010b8cd998
683 | | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
684 | | date: Sat Apr 30 15:24:48 2011 +0200
685 | | summary: F
686 | |
687 | o changeset: 5:9520eea781bc
688 |/ parent: 1:cd010b8cd998
689 | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
690 | date: Sat Apr 30 15:24:48 2011 +0200
691 | summary: E
668 o 8:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> H
692 669 |
693 | o changeset: 4:32af7686d403
694 | | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
695 | | date: Sat Apr 30 15:24:48 2011 +0200
696 | | summary: D
670 | o 7:eea13746799a draft Nicolas Dumazet <nicdumz.commits@gmail.com> G
671 |/|
672 o | 6:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
697 673 | |
698 | o changeset: 3:5fddd98957c8
699 | | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
700 | | date: Sat Apr 30 15:24:48 2011 +0200
701 | | summary: C
674 | o 5:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
675 |/
676 | o 4:32af7686d403 draft Nicolas Dumazet <nicdumz.commits@gmail.com> D
702 677 | |
703 | o changeset: 2:42ccdea3bb16
704 |/ user: Nicolas Dumazet <nicdumz.commits@gmail.com>
705 | date: Sat Apr 30 15:24:48 2011 +0200
706 | summary: B
707 |
708 o changeset: 1:cd010b8cd998
709 parent: -1:000000000000
710 user: Nicolas Dumazet <nicdumz.commits@gmail.com>
711 date: Sat Apr 30 15:24:48 2011 +0200
712 summary: A
678 | o 3:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> C
679 | |
680 | o 2:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com> B
681 |/
682 o 1:cd010b8cd998 draft Nicolas Dumazet <nicdumz.commits@gmail.com> A
713 683
714 @ changeset: 0:3903775176ed
715 user: test
716 date: Thu Jan 01 00:00:00 1970 +0000
717 summary: a
684 @ 0:3903775176ed draft test a
718 685
719 686
720 687 $ hg bundle2 --debug --rev '8+7+5+4' ../rev.hg2
721 688 4 changesets found
722 689 list of changesets:
723 690 32af7686d403cf45b5d95f2d70cebea587ac806a
724 691 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
725 692 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
726 693 02de42196ebee42ef284b6780a87cdc96e8eaab6
727 694 start emission of HG2X stream
728 695 bundle parameter:
729 696 start of parts
730 697 bundle part: "b2x:changegroup"
731 698 bundling: 1/4 changesets (25.00%)
732 699 bundling: 2/4 changesets (50.00%)
733 700 bundling: 3/4 changesets (75.00%)
734 701 bundling: 4/4 changesets (100.00%)
735 702 bundling: 1/4 manifests (25.00%)
736 703 bundling: 2/4 manifests (50.00%)
737 704 bundling: 3/4 manifests (75.00%)
738 705 bundling: 4/4 manifests (100.00%)
739 706 bundling: D 1/3 files (33.33%)
740 707 bundling: E 2/3 files (66.67%)
741 708 bundling: H 3/3 files (100.00%)
742 709 end of bundle
743 710
744 711 $ cat ../rev.hg2
745 712 HG2X\x00\x00\x00\x16\x0fb2x:changegroup\x00\x00\x00\x00\x00\x00\x00\x00\x06\x13\x00\x00\x00\xa42\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j_\xdd\xd9\x89W\xc8\xa5JMCm\xfe\x1d\xa9\xd8\x7f!\xa1\xb9{\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c (esc)
746 713 \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02D (esc)
747 714 \x00\x00\x00i\x00\x00\x00j\x00\x00\x00\x01D\x00\x00\x00\xa4\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\xcd\x01\x0b\x8c\xd9\x98\xf3\x98\x1aZ\x81\x15\xf9O\x8d\xa4\xabP`\x89\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)4dece9c826f69490507b98c6383a3009b295837d (esc)
748 715 \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02E (esc)
749 716 \x00\x00\x00i\x00\x00\x00j\x00\x00\x00\x01E\x00\x00\x00\xa2\xee\xa17Fy\x9a\x9e\x0b\xfd\x88\xf2\x9d<.\x9d\xc98\x9fRO$\xb68|\x8c\x8c\xae7\x17\x88\x80\xf3\xfa\x95\xde\xd3\xcb\x1c\xf7\x85\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\xee\xa17Fy\x9a\x9e\x0b\xfd\x88\xf2\x9d<.\x9d\xc98\x9fRO\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)365b93d57fdf4814e2b5911d6bacff2b12014441 (esc)
750 717 \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x00\x00\x00\x00i\x00\x00\x00j\x00\x00\x00\x01G\x00\x00\x00\xa4\x02\xdeB\x19n\xbe\xe4.\xf2\x84\xb6x (esc)
751 718 \x87\xcd\xc9n\x8e\xaa\xb6$\xb68|\x8c\x8c\xae7\x17\x88\x80\xf3\xfa\x95\xde\xd3\xcb\x1c\xf7\x85\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xdeB\x19n\xbe\xe4.\xf2\x84\xb6x (esc)
752 719 \x87\xcd\xc9n\x8e\xaa\xb6\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)8bee48edc7318541fc0013ee41b089276a8c24bf (esc)
753 720 \x00\x00\x00f\x00\x00\x00f\x00\x00\x00\x02H (esc)
754 721 \x00\x00\x00g\x00\x00\x00h\x00\x00\x00\x01H\x00\x00\x00\x00\x00\x00\x00\x8bn\x1fLG\xec\xb53\xff\xd0\xc8\xe5,\xdc\x88\xaf\xb6\xcd9\xe2\x0cf\xa5\xa0\x18\x17\xfd\xf5#\x9c'8\x02\xb5\xb7a\x8d\x05\x1c\x89\xe4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x81\x00\x00\x00\x81\x00\x00\x00+D\x00c3f1ca2924c16a19b0656a84900e504e5b0aec2d (esc)
755 722 \x00\x00\x00\x8bM\xec\xe9\xc8&\xf6\x94\x90P{\x98\xc68:0 \xb2\x95\x83}\x00}\x8c\x9d\x88\x84\x13%\xf5\xc6\xb0cq\xb3[N\x8a+\x1a\x83\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\x00\x00\x00+\x00\x00\x00\xac\x00\x00\x00+E\x009c6fd0350a6c0d0c49d4a9c5017cf07043f54e58 (esc)
756 723 \x00\x00\x00\x8b6[\x93\xd5\x7f\xdfH\x14\xe2\xb5\x91\x1dk\xac\xff+\x12\x01DA(\xa5\x84\xc6^\xf1!\xf8\x9e\xb6j\xb7\xd0\xbc\x15=\x80\x99\xe7\xceM\xec\xe9\xc8&\xf6\x94\x90P{\x98\xc68:0 \xb2\x95\x83}\xee\xa17Fy\x9a\x9e\x0b\xfd\x88\xf2\x9d<.\x9d\xc98\x9fRO\x00\x00\x00V\x00\x00\x00V\x00\x00\x00+F\x0022bfcfd62a21a3287edbd4d656218d0f525ed76a (esc)
757 724 \x00\x00\x00\x97\x8b\xeeH\xed\xc71\x85A\xfc\x00\x13\xeeA\xb0\x89'j\x8c$\xbf(\xa5\x84\xc6^\xf1!\xf8\x9e\xb6j\xb7\xd0\xbc\x15=\x80\x99\xe7\xce\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xdeB\x19n\xbe\xe4.\xf2\x84\xb6x (esc)
758 725 \x87\xcd\xc9n\x8e\xaa\xb6\x00\x00\x00+\x00\x00\x00V\x00\x00\x00\x00\x00\x00\x00\x81\x00\x00\x00\x81\x00\x00\x00+H\x008500189e74a9e0475e822093bc7db0d631aeb0b4 (esc)
759 726 \x00\x00\x00\x00\x00\x00\x00\x05D\x00\x00\x00b\xc3\xf1\xca)$\xc1j\x19\xb0ej\x84\x90\x0ePN[ (esc)
760 727 \xec-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02D (esc)
761 728 \x00\x00\x00\x00\x00\x00\x00\x05E\x00\x00\x00b\x9co\xd05 (esc)
762 729 l\r (no-eol) (esc)
763 730 \x0cI\xd4\xa9\xc5\x01|\xf0pC\xf5NX\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02E (esc)
764 731 \x00\x00\x00\x00\x00\x00\x00\x05H\x00\x00\x00b\x85\x00\x18\x9et\xa9\xe0G^\x82 \x93\xbc}\xb0\xd61\xae\xb0\xb4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xdeB\x19n\xbe\xe4.\xf2\x84\xb6x (esc)
765 732 \x87\xcd\xc9n\x8e\xaa\xb6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02H (esc)
766 733 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
767 734
768 735 $ hg unbundle2 < ../rev.hg2
769 736 adding changesets
770 737 adding manifests
771 738 adding file changes
772 739 added 0 changesets with 0 changes to 3 files
773 740 0 unread bytes
774 741 addchangegroup return: 1
775 742
776 743 with reply
777 744
778 745 $ hg bundle2 --rev '8+7+5+4' --reply ../rev-rr.hg2
779 746 $ hg unbundle2 ../rev-reply.hg2 < ../rev-rr.hg2
780 747 0 unread bytes
781 748 addchangegroup return: 1
782 749
783 750 $ cat ../rev-reply.hg2
784 751 HG2X\x00\x00\x003\x15b2x:reply:changegroup\x00\x00\x00\x00\x00\x02\x0b\x01\x06\x01in-reply-to1return1\x00\x00\x00\x00\x00\x1f (esc)
785 752 b2x:output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to1\x00\x00\x00dadding changesets (esc)
786 753 adding manifests
787 754 adding file changes
788 755 added 0 changesets with 0 changes to 3 files
789 756 \x00\x00\x00\x00\x00\x00 (no-eol) (esc)
790 757
791 758 Real world exchange
792 759 =====================
793 760
794 761
795 762 clone --pull
796 763
797 764 $ cd ..
798 765 $ hg clone main other --pull --rev 9520eea781bc
799 766 adding changesets
800 767 adding manifests
801 768 adding file changes
802 769 added 2 changesets with 2 changes to 2 files
803 770 updating to branch default
804 771 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
805 772 $ hg -R other log -G
806 @ changeset: 1:9520eea781bc
807 | tag: tip
808 | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
809 | date: Sat Apr 30 15:24:48 2011 +0200
810 | summary: E
773 @ 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
811 774 |
812 o changeset: 0:cd010b8cd998
813 user: Nicolas Dumazet <nicdumz.commits@gmail.com>
814 date: Sat Apr 30 15:24:48 2011 +0200
815 summary: A
775 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
816 776
817 777
818 778 pull
819 779
820 780 $ hg -R other pull -r 24b6387c8c8c
821 781 pulling from $TESTTMP/main (glob)
822 782 searching for changes
823 783 adding changesets
824 784 adding manifests
825 785 adding file changes
826 786 added 1 changesets with 1 changes to 1 files (+1 heads)
827 787 (run 'hg heads' to see heads, 'hg merge' to merge)
828 788
829 789 pull empty
830 790
831 791 $ hg -R other pull -r 24b6387c8c8c
832 792 pulling from $TESTTMP/main (glob)
833 793 no changes found
834 794
835 795 push
836 796
837 797 $ hg -R main push other --rev eea13746799a
838 798 pushing to other
839 799 searching for changes
840 800 remote: adding changesets
841 801 remote: adding manifests
842 802 remote: adding file changes
843 803 remote: added 1 changesets with 0 changes to 0 files (-1 heads)
844 804
845 805 pull over ssh
846 806
847 807 $ hg -R other pull ssh://user@dummy/main -r 02de42196ebe --traceback
848 808 pulling from ssh://user@dummy/main
849 809 searching for changes
850 810 adding changesets
851 811 adding manifests
852 812 adding file changes
853 813 added 1 changesets with 1 changes to 1 files (+1 heads)
854 814 (run 'hg heads' to see heads, 'hg merge' to merge)
855 815
856 816 pull over http
857 817
858 818 $ hg -R main serve -p $HGPORT -d --pid-file=main.pid -E main-error.log
859 819 $ cat main.pid >> $DAEMON_PIDS
860 820
861 821 $ hg -R other pull http://localhost:$HGPORT/ -r 42ccdea3bb16
862 822 pulling from http://localhost:$HGPORT/
863 823 searching for changes
864 824 adding changesets
865 825 adding manifests
866 826 adding file changes
867 827 added 1 changesets with 1 changes to 1 files (+1 heads)
868 828 (run 'hg heads .' to see heads, 'hg merge' to merge)
869 829 $ cat main-error.log
870 830
871 831 push over ssh
872 832
873 833 $ hg -R main push ssh://user@dummy/other -r 5fddd98957c8
874 834 pushing to ssh://user@dummy/other
875 835 searching for changes
876 836 remote: adding changesets
877 837 remote: adding manifests
878 838 remote: adding file changes
879 839 remote: added 1 changesets with 1 changes to 1 files
880 840
881 841 push over http
882 842
883 843 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
884 844 $ cat other.pid >> $DAEMON_PIDS
885 845
886 846 $ hg -R main push http://localhost:$HGPORT2/ -r 32af7686d403
887 847 pushing to http://localhost:$HGPORT2/
888 848 searching for changes
889 849 remote: adding changesets
890 850 remote: adding manifests
891 851 remote: adding file changes
892 852 remote: added 1 changesets with 1 changes to 1 files
893 853 $ cat other-error.log
894 854
895 855 Check final content.
896 856
897 857 $ hg -R other log -G
898 o changeset: 7:32af7686d403
899 | tag: tip
900 | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
901 | date: Sat Apr 30 15:24:48 2011 +0200
902 | summary: D
858 o 7:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com> D
903 859 |
904 o changeset: 6:5fddd98957c8
905 | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
906 | date: Sat Apr 30 15:24:48 2011 +0200
907 | summary: C
860 o 6:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> C
908 861 |
909 o changeset: 5:42ccdea3bb16
910 | parent: 0:cd010b8cd998
911 | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
912 | date: Sat Apr 30 15:24:48 2011 +0200
913 | summary: B
862 o 5:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> B
914 863 |
915 | o changeset: 4:02de42196ebe
916 | | parent: 2:24b6387c8c8c
917 | | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
918 | | date: Sat Apr 30 15:24:48 2011 +0200
919 | | summary: H
864 | o 4:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com> H
920 865 | |
921 | | o changeset: 3:eea13746799a
922 | |/| parent: 2:24b6387c8c8c
923 | | | parent: 1:9520eea781bc
924 | | | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
925 | | | date: Sat Apr 30 15:24:48 2011 +0200
926 | | | summary: G
927 | | |
928 | o | changeset: 2:24b6387c8c8c
929 |/ / parent: 0:cd010b8cd998
930 | | user: Nicolas Dumazet <nicdumz.commits@gmail.com>
931 | | date: Sat Apr 30 15:24:48 2011 +0200
932 | | summary: F
933 | |
934 | @ changeset: 1:9520eea781bc
935 |/ user: Nicolas Dumazet <nicdumz.commits@gmail.com>
936 | date: Sat Apr 30 15:24:48 2011 +0200
937 | summary: E
938 |
939 o changeset: 0:cd010b8cd998
940 user: Nicolas Dumazet <nicdumz.commits@gmail.com>
941 date: Sat Apr 30 15:24:48 2011 +0200
942 summary: A
866 | | o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> G
867 | |/|
868 | o | 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
869 |/ /
870 | @ 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
871 |/
872 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
943 873
944 874
945 875 Error Handling
946 876 ==============
947 877
948 878 Check that errors are properly returned to the client during push.
949 879
950 880 Setting up
951 881
952 882 $ cat > failpush.py << EOF
953 883 > """A small extension that makes push fails when using bundle2
954 884 >
955 885 > used to test error handling in bundle2
956 886 > """
957 887 >
958 888 > from mercurial import util
959 889 > from mercurial import bundle2
960 890 > from mercurial import exchange
961 891 > from mercurial import extensions
962 892 >
963 893 > def _pushbundle2failpart(orig, pushop, bundler):
964 894 > extradata = orig(pushop, bundler)
965 895 > reason = pushop.ui.config('failpush', 'reason', None)
966 896 > part = None
967 897 > if reason == 'abort':
968 898 > bundler.newpart('test:abort')
969 899 > if reason == 'unknown':
970 900 > bundler.newpart('TEST:UNKNOWN')
971 901 > if reason == 'race':
972 902 > # 20 Bytes of crap
973 903 > bundler.newpart('b2x:check:heads', data='01234567890123456789')
974 904 > return extradata
975 905 >
976 906 > @bundle2.parthandler("test:abort")
977 907 > def handleabort(op, part):
978 908 > raise util.Abort('Abandon ship!', hint="don't panic")
979 909 >
980 910 > def uisetup(ui):
981 911 > extensions.wrapfunction(exchange, '_pushbundle2extraparts', _pushbundle2failpart)
982 912 >
983 913 > EOF
984 914
985 915 $ cd main
986 916 $ hg up tip
987 917 3 files updated, 0 files merged, 1 files removed, 0 files unresolved
988 918 $ echo 'I' > I
989 919 $ hg add I
990 920 $ hg ci -m 'I'
991 921 $ hg id
992 922 e7ec4e813ba6 tip
993 923 $ cd ..
994 924
995 925 $ cat << EOF >> $HGRCPATH
996 926 > [extensions]
997 927 > failpush=$TESTTMP/failpush.py
998 928 > EOF
999 929
1000 930 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
1001 931 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
1002 932 $ cat other.pid >> $DAEMON_PIDS
1003 933
1004 934 Doing the actual push: Abort error
1005 935
1006 936 $ cat << EOF >> $HGRCPATH
1007 937 > [failpush]
1008 938 > reason = abort
1009 939 > EOF
1010 940
1011 941 $ hg -R main push other -r e7ec4e813ba6
1012 942 pushing to other
1013 943 searching for changes
1014 944 abort: Abandon ship!
1015 945 (don't panic)
1016 946 [255]
1017 947
1018 948 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
1019 949 pushing to ssh://user@dummy/other
1020 950 searching for changes
1021 951 abort: Abandon ship!
1022 952 (don't panic)
1023 953 [255]
1024 954
1025 955 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
1026 956 pushing to http://localhost:$HGPORT2/
1027 957 searching for changes
1028 958 abort: Abandon ship!
1029 959 (don't panic)
1030 960 [255]
1031 961
1032 962
1033 963 Doing the actual push: unknown mandatory parts
1034 964
1035 965 $ cat << EOF >> $HGRCPATH
1036 966 > [failpush]
1037 967 > reason = unknown
1038 968 > EOF
1039 969
1040 970 $ hg -R main push other -r e7ec4e813ba6
1041 971 pushing to other
1042 972 searching for changes
1043 973 abort: missing support for test:unknown
1044 974 [255]
1045 975
1046 976 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
1047 977 pushing to ssh://user@dummy/other
1048 978 searching for changes
1049 979 abort: missing support for test:unknown
1050 980 [255]
1051 981
1052 982 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
1053 983 pushing to http://localhost:$HGPORT2/
1054 984 searching for changes
1055 985 abort: missing support for test:unknown
1056 986 [255]
1057 987
1058 988 Doing the actual push: race
1059 989
1060 990 $ cat << EOF >> $HGRCPATH
1061 991 > [failpush]
1062 992 > reason = race
1063 993 > EOF
1064 994
1065 995 $ hg -R main push other -r e7ec4e813ba6
1066 996 pushing to other
1067 997 searching for changes
1068 998 abort: push failed:
1069 999 'repository changed while pushing - please try again'
1070 1000 [255]
1071 1001
1072 1002 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
1073 1003 pushing to ssh://user@dummy/other
1074 1004 searching for changes
1075 1005 abort: push failed:
1076 1006 'repository changed while pushing - please try again'
1077 1007 [255]
1078 1008
1079 1009 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
1080 1010 pushing to http://localhost:$HGPORT2/
1081 1011 searching for changes
1082 1012 abort: push failed:
1083 1013 'repository changed while pushing - please try again'
1084 1014 [255]
1085 1015
1086 1016 Doing the actual push: hook abort
1087 1017
1088 1018 $ cat << EOF >> $HGRCPATH
1089 1019 > [failpush]
1090 1020 > reason =
1091 1021 > [hooks]
1092 1022 > b2x-pretransactionclose.failpush = false
1093 1023 > EOF
1094 1024
1095 1025 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
1096 1026 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
1097 1027 $ cat other.pid >> $DAEMON_PIDS
1098 1028
1099 1029 $ hg -R main push other -r e7ec4e813ba6
1100 1030 pushing to other
1101 1031 searching for changes
1102 1032 transaction abort!
1103 1033 rollback completed
1104 1034 abort: b2x-pretransactionclose.failpush hook exited with status 1
1105 1035 [255]
1106 1036
1107 1037 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
1108 1038 pushing to ssh://user@dummy/other
1109 1039 searching for changes
1110 1040 abort: b2x-pretransactionclose.failpush hook exited with status 1
1111 1041 remote: transaction abort!
1112 1042 remote: rollback completed
1113 1043 [255]
1114 1044
1115 1045 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
1116 1046 pushing to http://localhost:$HGPORT2/
1117 1047 searching for changes
1118 1048 abort: b2x-pretransactionclose.failpush hook exited with status 1
1119 1049 [255]
1120 1050
1121 1051
General Comments 0
You need to be logged in to leave comments. Login now