1530 def bundle2requested(bundlecaps): |
1530 def bundle2requested(bundlecaps): |
1531 if bundlecaps is not None: |
1531 if bundlecaps is not None: |
1532 return any(cap.startswith('HG2') for cap in bundlecaps) |
1532 return any(cap.startswith('HG2') for cap in bundlecaps) |
1533 return False |
1533 return False |
1534 |
1534 |
1535 def getbundle(repo, source, heads=None, common=None, bundlecaps=None, |
1535 def getbundlechunks(repo, source, heads=None, common=None, bundlecaps=None, |
1536 **kwargs): |
1536 **kwargs): |
1537 """return a full bundle (with potentially multiple kind of parts) |
1537 """Return chunks constituting a bundle's raw data. |
1538 |
1538 |
1539 Could be a bundle HG10 or a bundle HG20 depending on bundlecaps |
1539 Could be a bundle HG10 or a bundle HG20 depending on bundlecaps |
1540 passed. For now, the bundle can contain only changegroup, but this will |
1540 passed. |
1541 changes when more part type will be available for bundle2. |
1541 |
1542 |
1542 Returns an iterator over raw chunks (of varying sizes). |
1543 This is different from changegroup.getchangegroup that only returns an HG10 |
|
1544 changegroup bundle. They may eventually get reunited in the future when we |
|
1545 have a clearer idea of the API we what to query different data. |
|
1546 |
|
1547 The implementation is at a very early stage and will get massive rework |
|
1548 when the API of bundle is refined. |
|
1549 """ |
1543 """ |
1550 usebundle2 = bundle2requested(bundlecaps) |
1544 usebundle2 = bundle2requested(bundlecaps) |
1551 # bundle10 case |
1545 # bundle10 case |
1552 if not usebundle2: |
1546 if not usebundle2: |
1553 if bundlecaps and not kwargs.get('cg', True): |
1547 if bundlecaps and not kwargs.get('cg', True): |
1555 |
1549 |
1556 if kwargs: |
1550 if kwargs: |
1557 raise ValueError(_('unsupported getbundle arguments: %s') |
1551 raise ValueError(_('unsupported getbundle arguments: %s') |
1558 % ', '.join(sorted(kwargs.keys()))) |
1552 % ', '.join(sorted(kwargs.keys()))) |
1559 outgoing = _computeoutgoing(repo, heads, common) |
1553 outgoing = _computeoutgoing(repo, heads, common) |
1560 return changegroup.getchangegroup(repo, source, outgoing, |
1554 bundler = changegroup.getbundler('01', repo, bundlecaps) |
1561 bundlecaps=bundlecaps) |
1555 return changegroup.getsubsetraw(repo, outgoing, bundler, source) |
1562 |
1556 |
1563 # bundle20 case |
1557 # bundle20 case |
1564 b2caps = {} |
1558 b2caps = {} |
1565 for bcaps in bundlecaps: |
1559 for bcaps in bundlecaps: |
1566 if bcaps.startswith('bundle2='): |
1560 if bcaps.startswith('bundle2='): |
1574 for name in getbundle2partsorder: |
1568 for name in getbundle2partsorder: |
1575 func = getbundle2partsmapping[name] |
1569 func = getbundle2partsmapping[name] |
1576 func(bundler, repo, source, bundlecaps=bundlecaps, b2caps=b2caps, |
1570 func(bundler, repo, source, bundlecaps=bundlecaps, b2caps=b2caps, |
1577 **kwargs) |
1571 **kwargs) |
1578 |
1572 |
1579 return util.chunkbuffer(bundler.getchunks()) |
1573 return bundler.getchunks() |
1580 |
1574 |
1581 @getbundle2partsgenerator('changegroup') |
1575 @getbundle2partsgenerator('changegroup') |
1582 def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, |
1576 def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, |
1583 b2caps=None, heads=None, common=None, **kwargs): |
1577 b2caps=None, heads=None, common=None, **kwargs): |
1584 """add a changegroup part to the requested bundle""" |
1578 """add a changegroup part to the requested bundle""" |