Mercurial > hg
comparison tests/test-bundle2.t @ 20889:deed5edb72de
bundle2: first version of a bundle processing
We now have a function that interpret part content.
This is a version early version of this function. It'll see major changes in
scope and API in future development. As for previous I'm just focussing on
getting minimal logic setup. Refining will happen with real world usage.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 24 Mar 2014 12:25:33 -0700 |
parents | 0b0d3800c248 |
children | ec7fc110faee |
comparison
equal
deleted
inserted
replaced
20888:0b0d3800c248 | 20889:deed5edb72de |
---|---|
17 > | 17 > |
18 > ELEPHANTSSONG = """Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko | 18 > ELEPHANTSSONG = """Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
19 > Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko | 19 > Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
20 > Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.""" | 20 > Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.""" |
21 > assert len(ELEPHANTSSONG) == 178 # future test say 178 bytes, trust it. | 21 > assert len(ELEPHANTSSONG) == 178 # future test say 178 bytes, trust it. |
22 > | |
23 > def songhandler(repo, part): | |
24 > """handle a "test:song" bundle2 part, printing the lyrics on stdin""" | |
25 > repo.ui.write('The choir start singing:\n') | |
26 > for line in part.data.split('\n'): | |
27 > repo.ui.write(' %s\n' % line) | |
28 > | |
29 > bundle2.parthandlermapping['test:song'] = songhandler | |
22 > | 30 > |
23 > @command('bundle2', | 31 > @command('bundle2', |
24 > [('', 'param', [], 'stream level parameter'), | 32 > [('', 'param', [], 'stream level parameter'), |
25 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),], | 33 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),], |
26 > '[OUTPUTFILE]') | 34 > '[OUTPUTFILE]') |
53 > else: | 61 > else: |
54 > file = open(path, 'w') | 62 > file = open(path, 'w') |
55 > | 63 > |
56 > for chunk in bundler.getchunks(): | 64 > for chunk in bundler.getchunks(): |
57 > file.write(chunk) | 65 > file.write(chunk) |
66 > | |
67 > @command('unbundle2', [], '') | |
68 > def cmdunbundle2(ui, repo): | |
69 > """process a bundle2 stream from stdin on the current repo""" | |
70 > bundle2.processbundle(repo, sys.stdin) | |
58 > | 71 > |
59 > @command('statbundle2', [], '') | 72 > @command('statbundle2', [], '') |
60 > def cmdstatbundle2(ui, repo): | 73 > def cmdstatbundle2(ui, repo): |
61 > """print statistic on the bundle2 container read from stdin""" | 74 > """print statistic on the bundle2 container read from stdin""" |
62 > unbundler = bundle2.unbundle20(ui, sys.stdin) | 75 > unbundler = bundle2.unbundle20(ui, sys.stdin) |
325 payload: 178 bytes | 338 payload: 178 bytes |
326 :test:math: | 339 :test:math: |
327 mandatory: 2 | 340 mandatory: 2 |
328 advisory: 1 | 341 advisory: 1 |
329 payload: 2 bytes | 342 payload: 2 bytes |
343 | |
344 Test actual unbundling | |
345 ======================== | |
346 | |
347 Process the bundle | |
348 | |
349 $ hg unbundle2 --debug < ../parts.hg2 | |
350 start processing of HG20 stream | |
351 reading bundle2 stream parameters | |
352 start extraction of bundle2 parts | |
353 part header size: 13 | |
354 part type: "test:empty" | |
355 part parameters: 0 | |
356 payload chunk size: 0 | |
357 ignoring unknown advisory part 'test:empty' | |
358 part header size: 13 | |
359 part type: "test:empty" | |
360 part parameters: 0 | |
361 payload chunk size: 0 | |
362 ignoring unknown advisory part 'test:empty' | |
363 part header size: 12 | |
364 part type: "test:song" | |
365 part parameters: 0 | |
366 payload chunk size: 178 | |
367 payload chunk size: 0 | |
368 found an handler for part 'test:song' | |
369 The choir start singing: | |
370 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko | |
371 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko | |
372 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. | |
373 part header size: 39 | |
374 part type: "test:math" | |
375 part parameters: 3 | |
376 payload chunk size: 2 | |
377 payload chunk size: 0 | |
378 ignoring unknown advisory part 'test:math' | |
379 part header size: 0 | |
380 end of bundle2 stream |