Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 37167:6f467adf9f05
bundle: add the possibility to bundle a stream v2 part
Differential Revision: https://phab.mercurial-scm.org/D1954
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 31 Jan 2018 11:09:20 +0100 |
parents | 6c7a6b04b274 |
children | 7e906d8a825f |
comparison
equal
deleted
inserted
replaced
37166:568e9b928c4c | 37167:6f467adf9f05 |
---|---|
1594 mandatory=False) | 1594 mandatory=False) |
1595 if opts.get('phases') and repo.revs('%ln and secret()', | 1595 if opts.get('phases') and repo.revs('%ln and secret()', |
1596 outgoing.missingheads): | 1596 outgoing.missingheads): |
1597 part.addparam('targetphase', '%d' % phases.secret, mandatory=False) | 1597 part.addparam('targetphase', '%d' % phases.secret, mandatory=False) |
1598 | 1598 |
1599 if opts.get('streamv2', False): | |
1600 addpartbundlestream2(bundler, repo, stream=True) | |
1601 | |
1599 if opts.get('tagsfnodescache', True): | 1602 if opts.get('tagsfnodescache', True): |
1600 addparttagsfnodescache(repo, bundler, outgoing) | 1603 addparttagsfnodescache(repo, bundler, outgoing) |
1601 | 1604 |
1602 if opts.get('revbranchcache', True): | 1605 if opts.get('revbranchcache', True): |
1603 addpartrevbranchcache(repo, bundler, outgoing) | 1606 addpartrevbranchcache(repo, bundler, outgoing) |
1654 yield n | 1657 yield n |
1655 for n in sorted(closed): | 1658 for n in sorted(closed): |
1656 yield n | 1659 yield n |
1657 | 1660 |
1658 bundler.newpart('cache:rev-branch-cache', data=generate()) | 1661 bundler.newpart('cache:rev-branch-cache', data=generate()) |
1662 | |
1663 def _formatrequirementsspec(requirements): | |
1664 return urlreq.quote(','.join(sorted(requirements))) | |
1665 | |
1666 def _formatrequirementsparams(requirements): | |
1667 requirements = _formatrequirementsspec(requirements) | |
1668 params = "%s%s" % (urlreq.quote("requirements="), requirements) | |
1669 return params | |
1670 | |
1671 def addpartbundlestream2(bundler, repo, **kwargs): | |
1672 if not kwargs.get('stream', False): | |
1673 return | |
1674 | |
1675 if not streamclone.allowservergeneration(repo): | |
1676 raise error.Abort(_('stream data requested but server does not allow ' | |
1677 'this feature'), | |
1678 hint=_('well-behaved clients should not be ' | |
1679 'requesting stream data from servers not ' | |
1680 'advertising it; the client may be buggy')) | |
1681 | |
1682 # Stream clones don't compress well. And compression undermines a | |
1683 # goal of stream clones, which is to be fast. Communicate the desire | |
1684 # to avoid compression to consumers of the bundle. | |
1685 bundler.prefercompressed = False | |
1686 | |
1687 filecount, bytecount, it = streamclone.generatev2(repo) | |
1688 requirements = _formatrequirementsspec(repo.requirements) | |
1689 part = bundler.newpart('stream2', data=it) | |
1690 part.addparam('bytecount', '%d' % bytecount, mandatory=True) | |
1691 part.addparam('filecount', '%d' % filecount, mandatory=True) | |
1692 part.addparam('requirements', requirements, mandatory=True) | |
1659 | 1693 |
1660 def buildobsmarkerspart(bundler, markers): | 1694 def buildobsmarkerspart(bundler, markers): |
1661 """add an obsmarker part to the bundler with <markers> | 1695 """add an obsmarker part to the bundler with <markers> |
1662 | 1696 |
1663 No part is created if markers is empty. | 1697 No part is created if markers is empty. |