Show More
@@ -1532,20 +1532,14 b' def bundle2requested(bundlecaps):' | |||||
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. |
|
|||
1542 |
|
1541 | |||
1543 | This is different from changegroup.getchangegroup that only returns an HG10 |
|
1542 | Returns an iterator over raw chunks (of varying sizes). | |
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 | |
@@ -1557,8 +1551,8 b' def getbundle(repo, source, heads=None, ' | |||||
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 = {} | |
@@ -1576,7 +1570,7 b' def getbundle(repo, source, heads=None, ' | |||||
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 |
|
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, |
@@ -149,14 +149,18 b' class localpeer(peer.peerrepository):' | |||||
149 |
|
149 | |||
150 | def getbundle(self, source, heads=None, common=None, bundlecaps=None, |
|
150 | def getbundle(self, source, heads=None, common=None, bundlecaps=None, | |
151 | **kwargs): |
|
151 | **kwargs): | |
152 |
c |
|
152 | chunks = exchange.getbundlechunks(self._repo, source, heads=heads, | |
153 |
common=common, bundlecaps=bundlecaps, |
|
153 | common=common, bundlecaps=bundlecaps, | |
|
154 | **kwargs) | |||
|
155 | cb = util.chunkbuffer(chunks) | |||
|
156 | ||||
154 | if bundlecaps is not None and 'HG20' in bundlecaps: |
|
157 | if bundlecaps is not None and 'HG20' in bundlecaps: | |
155 | # When requesting a bundle2, getbundle returns a stream to make the |
|
158 | # When requesting a bundle2, getbundle returns a stream to make the | |
156 | # wire level function happier. We need to build a proper object |
|
159 | # wire level function happier. We need to build a proper object | |
157 | # from it in local peer. |
|
160 | # from it in local peer. | |
158 |
|
|
161 | return bundle2.getunbundler(self.ui, cb) | |
159 |
|
|
162 | else: | |
|
163 | return changegroup.getunbundler('01', cb, None) | |||
160 |
|
164 | |||
161 | # TODO We might want to move the next two calls into legacypeer and add |
|
165 | # TODO We might want to move the next two calls into legacypeer and add | |
162 | # unbundle instead. |
|
166 | # unbundle instead. |
@@ -772,8 +772,10 b' def getbundle(repo, proto, others):' | |||||
772 | if not exchange.bundle2requested(opts.get('bundlecaps')): |
|
772 | if not exchange.bundle2requested(opts.get('bundlecaps')): | |
773 | return ooberror(bundle2required) |
|
773 | return ooberror(bundle2required) | |
774 |
|
774 | |||
775 |
c |
|
775 | chunks = exchange.getbundlechunks(repo, 'serve', **opts) | |
776 | return streamres(proto.groupchunks(cg)) |
|
776 | # TODO avoid util.chunkbuffer() here since it is adding overhead to | |
|
777 | # what is fundamentally a generator proxying operation. | |||
|
778 | return streamres(proto.groupchunks(util.chunkbuffer(chunks))) | |||
777 |
|
779 | |||
778 | @wireprotocommand('heads') |
|
780 | @wireprotocommand('heads') | |
779 | def heads(repo, proto): |
|
781 | def heads(repo, proto): |
@@ -170,7 +170,7 b' Get branch and merge:' | |||||
170 | $ hg debuggetbundle repo bundle -t bundle2 |
|
170 | $ hg debuggetbundle repo bundle -t bundle2 | |
171 | $ hg debugbundle bundle |
|
171 | $ hg debugbundle bundle | |
172 | Stream params: {} |
|
172 | Stream params: {} | |
173 |
changegroup -- "sortdict([('version', '01') |
|
173 | changegroup -- "sortdict([('version', '01')])" | |
174 | 7704483d56b2a7b5db54dcee7c62378ac629b348 |
|
174 | 7704483d56b2a7b5db54dcee7c62378ac629b348 | |
175 | 29a4d1f17bd3f0779ca0525bebb1cfb51067c738 |
|
175 | 29a4d1f17bd3f0779ca0525bebb1cfb51067c738 | |
176 | 713346a995c363120712aed1aee7e04afd867638 |
|
176 | 713346a995c363120712aed1aee7e04afd867638 |
General Comments 0
You need to be logged in to leave comments.
Login now