Mercurial > hg
comparison mercurial/exchange.py @ 29808:8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Now that all users are in exchange, we can safely move the code in the
'exchange' module. This function is really about processing the argument of a
'getbundle' call, so it even makes senses to do so.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 09 Aug 2016 17:06:35 +0200 |
parents | d4e026341e16 |
children | a76d5ba7ac43 |
comparison
equal
deleted
inserted
replaced
29807:d4e026341e16 | 29808:8d226db31f20 |
---|---|
254 if version is None: | 254 if version is None: |
255 raise ValueError('bundler does not support common obsmarker format') | 255 raise ValueError('bundler does not support common obsmarker format') |
256 stream = obsolete.encodemarkers(markers, True, version=version) | 256 stream = obsolete.encodemarkers(markers, True, version=version) |
257 return bundler.newpart('obsmarkers', data=stream) | 257 return bundler.newpart('obsmarkers', data=stream) |
258 return None | 258 return None |
259 | |
260 def _computeoutgoing(repo, heads, common): | |
261 """Computes which revs are outgoing given a set of common | |
262 and a set of heads. | |
263 | |
264 This is a separate function so extensions can have access to | |
265 the logic. | |
266 | |
267 Returns a discovery.outgoing object. | |
268 """ | |
269 cl = repo.changelog | |
270 if common: | |
271 hasnode = cl.hasnode | |
272 common = [n for n in common if hasnode(n)] | |
273 else: | |
274 common = [nullid] | |
275 if not heads: | |
276 heads = cl.heads() | |
277 return discovery.outgoing(repo, common, heads) | |
259 | 278 |
260 def _forcebundle1(op): | 279 def _forcebundle1(op): |
261 """return true if a pull/push must use bundle1 | 280 """return true if a pull/push must use bundle1 |
262 | 281 |
263 This function is used to allow testing of the older bundle version""" | 282 This function is used to allow testing of the older bundle version""" |
1534 raise ValueError(_('request for bundle10 must include changegroup')) | 1553 raise ValueError(_('request for bundle10 must include changegroup')) |
1535 | 1554 |
1536 if kwargs: | 1555 if kwargs: |
1537 raise ValueError(_('unsupported getbundle arguments: %s') | 1556 raise ValueError(_('unsupported getbundle arguments: %s') |
1538 % ', '.join(sorted(kwargs.keys()))) | 1557 % ', '.join(sorted(kwargs.keys()))) |
1539 outgoing = changegroup.computeoutgoing(repo, heads, common) | 1558 outgoing = _computeoutgoing(repo, heads, common) |
1540 return changegroup.getchangegroup(repo, source, outgoing, | 1559 return changegroup.getchangegroup(repo, source, outgoing, |
1541 bundlecaps=bundlecaps) | 1560 bundlecaps=bundlecaps) |
1542 | 1561 |
1543 # bundle20 case | 1562 # bundle20 case |
1544 b2caps = {} | 1563 b2caps = {} |
1571 cgversions = [v for v in cgversions | 1590 cgversions = [v for v in cgversions |
1572 if v in changegroup.supportedoutgoingversions(repo)] | 1591 if v in changegroup.supportedoutgoingversions(repo)] |
1573 if not cgversions: | 1592 if not cgversions: |
1574 raise ValueError(_('no common changegroup version')) | 1593 raise ValueError(_('no common changegroup version')) |
1575 version = max(cgversions) | 1594 version = max(cgversions) |
1576 outgoing = changegroup.computeoutgoing(repo, heads, common) | 1595 outgoing = _computeoutgoing(repo, heads, common) |
1577 cg = changegroup.getlocalchangegroupraw(repo, source, outgoing, | 1596 cg = changegroup.getlocalchangegroupraw(repo, source, outgoing, |
1578 bundlecaps=bundlecaps, | 1597 bundlecaps=bundlecaps, |
1579 version=version) | 1598 version=version) |
1580 | 1599 |
1581 if cg: | 1600 if cg: |
1624 # - changeset are being exchanged, | 1643 # - changeset are being exchanged, |
1625 # - the client supports it. | 1644 # - the client supports it. |
1626 if not (kwargs.get('cg', True) and 'hgtagsfnodes' in b2caps): | 1645 if not (kwargs.get('cg', True) and 'hgtagsfnodes' in b2caps): |
1627 return | 1646 return |
1628 | 1647 |
1629 outgoing = changegroup.computeoutgoing(repo, heads, common) | 1648 outgoing = _computeoutgoing(repo, heads, common) |
1630 | 1649 |
1631 if not outgoing.missingheads: | 1650 if not outgoing.missingheads: |
1632 return | 1651 return |
1633 | 1652 |
1634 cache = tags.hgtagsfnodescache(repo.unfiltered()) | 1653 cache = tags.hgtagsfnodescache(repo.unfiltered()) |