##// END OF EJS Templates
bundle2: make sure the unbundler refuse non bundle2 stream...
bundle2: make sure the unbundler refuse non bundle2 stream We now make use of the magic string at the beginning of the file.

File last commit:

r20803:88db3e61 default
r20803:88db3e61 default
Show More
test-bundle2.t
62 lines | 1.5 KiB | text/troff | Tads3Lexer
Create an extension to test bundle2 API
$ cat > bundle2.py << EOF
> """A small extension to test bundle2 implementation
>
> Current bundle2 implementation is far too limited to be used in any core
> code. We still need to be able to test it while it grow up.
> """
>
> import sys
> from mercurial import cmdutil
> from mercurial import bundle2
> cmdtable = {}
> command = cmdutil.command(cmdtable)
>
> @command('bundle2', [], '')
> def cmdbundle2(ui, repo):
> """write a bundle2 container on standard ouput"""
> bundle = bundle2.bundle20()
> for chunk in bundle.getchunks():
> ui.write(chunk)
>
> @command('unbundle2', [], '')
> def cmdunbundle2(ui, repo):
> """read a bundle2 container from standard input"""
> unbundler = bundle2.unbundle20(sys.stdin)
> ui.write('options count: %i\n' % len(unbundler.params))
> parts = list(unbundler)
> ui.write('parts count: %i\n' % len(parts))
> EOF
$ cat >> $HGRCPATH << EOF
> [extensions]
> bundle2=$TESTTMP/bundle2.py
> EOF
The extension requires a repo (currently unused)
$ hg init main
$ cd main
$ touch a
$ hg add a
$ hg commit -m 'a'
Test simple generation of empty bundle
$ hg bundle2
HG20\x00\x00\x00\x00 (no-eol) (esc)
Test parsing of an empty bundle
$ hg bundle2 | hg unbundle2
options count: 0
parts count: 0
Test old style bundle are detected and refused
$ hg bundle --all ../bundle.hg
1 changesets found
$ hg unbundle2 < ../bundle.hg
abort: unknown bundle version 10
[255]