tests/test-bundle2-remote-changegroup.t
changeset 38699 72c086b1af12
parent 38698 6437e89b64d5
child 38700 cfdf7bfb0ac0
equal deleted inserted replaced
38698:6437e89b64d5 38699:72c086b1af12
    38   >       - raw-remote-changegroup <python expression>
    38   >       - raw-remote-changegroup <python expression>
    39   >           Creates a remote-changegroup part with the data given in the
    39   >           Creates a remote-changegroup part with the data given in the
    40   >           Python expression as parameters. The Python expression is
    40   >           Python expression as parameters. The Python expression is
    41   >           evaluated with eval, and is expected to be a dict.
    41   >           evaluated with eval, and is expected to be a dict.
    42   >     """
    42   >     """
    43   >     def newpart(name, data=''):
    43   >     def newpart(name, data=b''):
    44   >         """wrapper around bundler.newpart adding an extra part making the
    44   >         """wrapper around bundler.newpart adding an extra part making the
    45   >         client output information about each processed part"""
    45   >         client output information about each processed part"""
    46   >         bundler.newpart('output', data=name)
    46   >         bundler.newpart(b'output', data=name)
    47   >         part = bundler.newpart(name, data=data)
    47   >         part = bundler.newpart(name, data=data)
    48   >         return part
    48   >         return part
    49   > 
    49   > 
    50   >     for line in open(repo.vfs.join('bundle2maker'), 'rb'):
    50   >     for line in open(repo.vfs.join(b'bundle2maker'), 'rb'):
    51   >         line = line.strip()
    51   >         line = line.strip()
    52   >         try:
    52   >         try:
    53   >             verb, args = line.split(None, 1)
    53   >             verb, args = line.split(None, 1)
    54   >         except ValueError:
    54   >         except ValueError:
    55   >             verb, args = line, ''
    55   >             verb, args = line, b''
    56   >         if verb == 'remote-changegroup':
    56   >         if verb == b'remote-changegroup':
    57   >            url, file = args.split()
    57   >            url, file = args.split()
    58   >            bundledata = open(file, 'rb').read()
    58   >            bundledata = open(file, 'rb').read()
    59   >            digest = util.digester.preferred(b2caps['digests'])
    59   >            digest = util.digester.preferred(b2caps[b'digests'])
    60   >            d = util.digester([digest], bundledata)
    60   >            d = util.digester([digest], bundledata)
    61   >            part = newpart('remote-changegroup')
    61   >            part = newpart(b'remote-changegroup')
    62   >            part.addparam('url', url)
    62   >            part.addparam(b'url', url)
    63   >            part.addparam('size', str(len(bundledata)))
    63   >            part.addparam(b'size', str(len(bundledata)))
    64   >            part.addparam('digests', digest)
    64   >            part.addparam(b'digests', digest)
    65   >            part.addparam('digest:%s' % digest, d[digest])
    65   >            part.addparam(b'digest:%s' % digest, d[digest])
    66   >         elif verb == 'raw-remote-changegroup':
    66   >         elif verb == b'raw-remote-changegroup':
    67   >            part = newpart('remote-changegroup')
    67   >            part = newpart(b'remote-changegroup')
    68   >            for k, v in eval(args).items():
    68   >            for k, v in eval(args).items():
    69   >                part.addparam(k, str(v))
    69   >                part.addparam(k, str(v))
    70   >         elif verb == 'changegroup':
    70   >         elif verb == b'changegroup':
    71   >             _common, heads = args.split()
    71   >             _common, heads = args.split()
    72   >             common.extend(repo[r].node() for r in repo.revs(_common))
    72   >             common.extend(repo[r].node() for r in repo.revs(_common))
    73   >             heads = [repo[r].node() for r in repo.revs(heads)]
    73   >             heads = [repo[r].node() for r in repo.revs(heads)]
    74   >             outgoing = discovery.outgoing(repo, common, heads)
    74   >             outgoing = discovery.outgoing(repo, common, heads)
    75   >             cg = changegroup.makechangegroup(repo, outgoing, '01',
    75   >             cg = changegroup.makechangegroup(repo, outgoing, b'01',
    76   >                                              'changegroup')
    76   >                                              b'changegroup')
    77   >             newpart('changegroup', cg.getchunks())
    77   >             newpart(b'changegroup', cg.getchunks())
    78   >         else:
    78   >         else:
    79   >             raise Exception('unknown verb')
    79   >             raise Exception('unknown verb')
    80   > 
    80   > 
    81   > exchange.getbundle2partsmapping['changegroup'] = _getbundlechangegrouppart
    81   > exchange.getbundle2partsmapping[b'changegroup'] = _getbundlechangegrouppart
    82   > EOF
    82   > EOF
    83 
    83 
    84 Start a simple HTTP server to serve bundles
    84 Start a simple HTTP server to serve bundles
    85 
    85 
    86   $ $PYTHON "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
    86   $ $PYTHON "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid