Exemple #1
0
def getbundle(repo,
              source,
              heads=None,
              common=None,
              bundlecaps=None,
              **kwargs):
    """return a full bundle (with potentially multiple kind of parts)

    Could be a bundle HG10 or a bundle HG2Y depending on bundlecaps
    passed. For now, the bundle can contain only changegroup, but this will
    changes when more part type will be available for bundle2.

    This is different from changegroup.getchangegroup that only returns an HG10
    changegroup bundle. They may eventually get reunited in the future when we
    have a clearer idea of the API we what to query different data.

    The implementation is at a very early stage and will get massive rework
    when the API of bundle is refined.
    """
    # bundle10 case
    if bundlecaps is None or 'HG2Y' not in bundlecaps:
        if bundlecaps and not kwargs.get('cg', True):
            raise ValueError(
                _('request for bundle10 must include changegroup'))

        if kwargs:
            raise ValueError(
                _('unsupported getbundle arguments: %s') %
                ', '.join(sorted(kwargs.keys())))
        return changegroup.getchangegroup(repo,
                                          source,
                                          heads=heads,
                                          common=common,
                                          bundlecaps=bundlecaps)

    # bundle20 case
    b2caps = {}
    for bcaps in bundlecaps:
        if bcaps.startswith('bundle2='):
            blob = urllib.unquote(bcaps[len('bundle2='):])
            b2caps.update(bundle2.decodecaps(blob))
    bundler = bundle2.bundle20(repo.ui, b2caps)

    for name in getbundle2partsorder:
        func = getbundle2partsmapping[name]
        kwargs['heads'] = heads
        kwargs['common'] = common
        func(bundler,
             repo,
             source,
             bundlecaps=bundlecaps,
             b2caps=b2caps,
             **kwargs)

    return util.chunkbuffer(bundler.getchunks())
def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None,
                              b2caps=None, heads=None, common=None, **kwargs):
    """add a changegroup part to the requested bundle"""
    cg = None
    if kwargs.get('cg', True):
        # build changegroup bundle here.
        cg = changegroup.getchangegroup(repo, source, heads=heads,
                                        common=common, bundlecaps=bundlecaps)

    if cg:
        bundler.newpart('b2x:changegroup', data=cg.getchunks())
Exemple #3
0
def getbundle(repo, source, heads=None, common=None, bundlecaps=None,
              **kwargs):
    """return a full bundle (with potentially multiple kind of parts)

    Could be a bundle HG10 or a bundle HG2Y depending on bundlecaps
    passed. For now, the bundle can contain only changegroup, but this will
    changes when more part type will be available for bundle2.

    This is different from changegroup.getchangegroup that only returns an HG10
    changegroup bundle. They may eventually get reunited in the future when we
    have a clearer idea of the API we what to query different data.

    The implementation is at a very early stage and will get massive rework
    when the API of bundle is refined.
    """
    # bundle10 case
    if bundlecaps is None or 'HG2Y' not in bundlecaps:
        if bundlecaps and not kwargs.get('cg', True):
            raise ValueError(_('request for bundle10 must include changegroup'))

        if kwargs:
            raise ValueError(_('unsupported getbundle arguments: %s')
                             % ', '.join(sorted(kwargs.keys())))
        return changegroup.getchangegroup(repo, source, heads=heads,
                                          common=common, bundlecaps=bundlecaps)

    # bundle20 case
    b2caps = {}
    for bcaps in bundlecaps:
        if bcaps.startswith('bundle2='):
            blob = urllib.unquote(bcaps[len('bundle2='):])
            b2caps.update(bundle2.decodecaps(blob))
    bundler = bundle2.bundle20(repo.ui, b2caps)

    kwargs['heads'] = heads
    kwargs['common'] = common

    for name in getbundle2partsorder:
        func = getbundle2partsmapping[name]
        func(bundler, repo, source, bundlecaps=bundlecaps, b2caps=b2caps,
             **kwargs)

    return util.chunkbuffer(bundler.getchunks())
Exemple #4
0
def _getbundlechangegrouppart(bundler,
                              repo,
                              source,
                              bundlecaps=None,
                              b2caps=None,
                              heads=None,
                              common=None,
                              **kwargs):
    """add a changegroup part to the requested bundle"""
    cg = None
    if kwargs.get('cg', True):
        # build changegroup bundle here.
        cg = changegroup.getchangegroup(repo,
                                        source,
                                        heads=heads,
                                        common=common,
                                        bundlecaps=bundlecaps)

    if cg:
        bundler.newpart('b2x:changegroup', data=cg.getchunks())