Mercurial > hg
comparison tests/test-bundle2.t @ 20802:520df53ad26a
bundle2: a very first version of bundle2 unbundler
This changeset introduce an unbundler class to match the bundle2 bundler. It is
currently able to unbundle an empty bundle2 only and will gain more feature at
the same pace than the bundler.
It also comes with its special extension command in test.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 18 Mar 2014 14:28:42 -0700 |
parents | 9c5183cb9bca |
children | 88db3e615319 |
comparison
equal
deleted
inserted
replaced
20801:9c5183cb9bca | 20802:520df53ad26a |
---|---|
6 > | 6 > |
7 > Current bundle2 implementation is far too limited to be used in any core | 7 > Current bundle2 implementation is far too limited to be used in any core |
8 > code. We still need to be able to test it while it grow up. | 8 > code. We still need to be able to test it while it grow up. |
9 > """ | 9 > """ |
10 > | 10 > |
11 > import sys | |
11 > from mercurial import cmdutil | 12 > from mercurial import cmdutil |
12 > from mercurial import bundle2 | 13 > from mercurial import bundle2 |
13 > cmdtable = {} | 14 > cmdtable = {} |
14 > command = cmdutil.command(cmdtable) | 15 > command = cmdutil.command(cmdtable) |
15 > | 16 > |
17 > def cmdbundle2(ui, repo): | 18 > def cmdbundle2(ui, repo): |
18 > """write a bundle2 container on standard ouput""" | 19 > """write a bundle2 container on standard ouput""" |
19 > bundle = bundle2.bundle20() | 20 > bundle = bundle2.bundle20() |
20 > for chunk in bundle.getchunks(): | 21 > for chunk in bundle.getchunks(): |
21 > ui.write(chunk) | 22 > ui.write(chunk) |
23 > | |
24 > @command('unbundle2', [], '') | |
25 > def cmdunbundle2(ui, repo): | |
26 > """read a bundle2 container from standard input""" | |
27 > unbundler = bundle2.unbundle20(sys.stdin) | |
28 > ui.write('options count: %i\n' % len(unbundler.params)) | |
29 > parts = list(unbundler) | |
30 > ui.write('parts count: %i\n' % len(parts)) | |
22 > EOF | 31 > EOF |
23 $ cat >> $HGRCPATH << EOF | 32 $ cat >> $HGRCPATH << EOF |
24 > [extensions] | 33 > [extensions] |
25 > bundle2=$TESTTMP/bundle2.py | 34 > bundle2=$TESTTMP/bundle2.py |
26 > EOF | 35 > EOF |
32 | 41 |
33 Test simple generation of empty bundle | 42 Test simple generation of empty bundle |
34 | 43 |
35 $ hg bundle2 | 44 $ hg bundle2 |
36 HG20\x00\x00\x00\x00 (no-eol) (esc) | 45 HG20\x00\x00\x00\x00 (no-eol) (esc) |
46 | |
47 Test parsing of an empty bundle | |
48 | |
49 $ hg bundle2 | hg unbundle2 | |
50 options count: 0 | |
51 parts count: 0 |