tests/test-bundle2.t
changeset 20804 db9d3991d2c6
parent 20803 88db3e615319
child 20805 c5aaeca0cfbf
equal deleted inserted replaced
20803:88db3e615319 20804:db9d3991d2c6
    12   > from mercurial import cmdutil
    12   > from mercurial import cmdutil
    13   > from mercurial import bundle2
    13   > from mercurial import bundle2
    14   > cmdtable = {}
    14   > cmdtable = {}
    15   > command = cmdutil.command(cmdtable)
    15   > command = cmdutil.command(cmdtable)
    16   > 
    16   > 
    17   > @command('bundle2', [], '')
    17   > @command('bundle2',
    18   > def cmdbundle2(ui, repo):
    18   >          [('', 'param', [], 'stream level parameter'),],
       
    19   >          '')
       
    20   > def cmdbundle2(ui, repo, **opts):
    19   >     """write a bundle2 container on standard ouput"""
    21   >     """write a bundle2 container on standard ouput"""
    20   >     bundle = bundle2.bundle20()
    22   >     bundler = bundle2.bundle20()
    21   >     for chunk in bundle.getchunks():
    23   >     for p in opts['param']:
       
    24   >         bundler.addparam(p)
       
    25   >     for chunk in bundler.getchunks():
    22   >         ui.write(chunk)
    26   >         ui.write(chunk)
    23   > 
    27   > 
    24   > @command('unbundle2', [], '')
    28   > @command('unbundle2', [], '')
    25   > def cmdunbundle2(ui, repo):
    29   > def cmdunbundle2(ui, repo):
    26   >     """read a bundle2 container from standard input"""
    30   >     """read a bundle2 container from standard input"""
    40   $ cd main
    44   $ cd main
    41   $ touch a
    45   $ touch a
    42   $ hg add a
    46   $ hg add a
    43   $ hg commit -m 'a'
    47   $ hg commit -m 'a'
    44 
    48 
    45 Test simple generation of empty bundle
    49 
       
    50 Empty bundle
       
    51 =================
       
    52 
       
    53 - no option
       
    54 - no parts
       
    55 
       
    56 Test bundling
    46 
    57 
    47   $ hg bundle2
    58   $ hg bundle2
    48   HG20\x00\x00\x00\x00 (no-eol) (esc)
    59   HG20\x00\x00\x00\x00 (no-eol) (esc)
    49 
    60 
    50 Test parsing of an empty bundle
    61 Test unbundling
    51 
    62 
    52   $ hg bundle2 | hg unbundle2
    63   $ hg bundle2 | hg unbundle2
    53   options count: 0
    64   options count: 0
    54   parts count:   0
    65   parts count:   0
    55 
    66 
    58   $ hg bundle --all ../bundle.hg
    69   $ hg bundle --all ../bundle.hg
    59   1 changesets found
    70   1 changesets found
    60   $ hg unbundle2 < ../bundle.hg
    71   $ hg unbundle2 < ../bundle.hg
    61   abort: unknown bundle version 10
    72   abort: unknown bundle version 10
    62   [255]
    73   [255]
       
    74 
       
    75 Test parameters
       
    76 =================
       
    77 
       
    78 - some options
       
    79 - no parts
       
    80 
       
    81 advisory parameters, no value
       
    82 -------------------------------
       
    83 
       
    84 Simplest possible parameters form
       
    85 
       
    86 Test generation
       
    87 
       
    88   $ hg bundle2 --param 'caution'
       
    89   HG20\x00\x07caution\x00\x00 (no-eol) (esc)
       
    90 
       
    91 Test generation multiple option
       
    92 
       
    93   $ hg bundle2 --param 'caution' --param 'meal'
       
    94   HG20\x00\x0ccaution meal\x00\x00 (no-eol) (esc)