Mercurial > hg
comparison mercurial/exchange.py @ 32515:e70d6dbde713
bundle2: move function building obsmarker-part in the bundle2 module
We move it next to similar part building functions. We will need it for the
"writenewbundle" logic. This will allow us to easily include obsmarkers in
on-disk bundle, a necessary step before having `hg strip` also operate on
markers.
(Yes, the bundle2 module was already too large, but there any many
interdependencies between its components so it is non-trivial to split, this is
a quest for another adventure.)
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 28 May 2017 11:48:18 -0700 |
parents | bd872f64a8ba |
children | 9929af2b09b4 |
comparison
equal
deleted
inserted
replaced
32514:3f5d675fddf4 | 32515:e70d6dbde713 |
---|---|
245 requirements = streamclone.readbundle1header(fh)[2] | 245 requirements = streamclone.readbundle1header(fh)[2] |
246 params = 'requirements=%s' % ','.join(sorted(requirements)) | 246 params = 'requirements=%s' % ','.join(sorted(requirements)) |
247 return 'none-packed1;%s' % urlreq.quote(params) | 247 return 'none-packed1;%s' % urlreq.quote(params) |
248 else: | 248 else: |
249 raise error.Abort(_('unknown bundle type: %s') % b) | 249 raise error.Abort(_('unknown bundle type: %s') % b) |
250 | |
251 def buildobsmarkerspart(bundler, markers): | |
252 """add an obsmarker part to the bundler with <markers> | |
253 | |
254 No part is created if markers is empty. | |
255 Raises ValueError if the bundler doesn't support any known obsmarker format. | |
256 """ | |
257 if markers: | |
258 remoteversions = bundle2.obsmarkersversion(bundler.capabilities) | |
259 version = obsolete.commonversion(remoteversions) | |
260 if version is None: | |
261 raise ValueError('bundler does not support common obsmarker format') | |
262 stream = obsolete.encodemarkers(markers, True, version=version) | |
263 return bundler.newpart('obsmarkers', data=stream) | |
264 return None | |
265 | 250 |
266 def _computeoutgoing(repo, heads, common): | 251 def _computeoutgoing(repo, heads, common): |
267 """Computes which revs are outgoing given a set of common | 252 """Computes which revs are outgoing given a set of common |
268 and a set of heads. | 253 and a set of heads. |
269 | 254 |
820 if obsolete.commonversion(remoteversions) is None: | 805 if obsolete.commonversion(remoteversions) is None: |
821 return | 806 return |
822 pushop.stepsdone.add('obsmarkers') | 807 pushop.stepsdone.add('obsmarkers') |
823 if pushop.outobsmarkers: | 808 if pushop.outobsmarkers: |
824 markers = sorted(pushop.outobsmarkers) | 809 markers = sorted(pushop.outobsmarkers) |
825 buildobsmarkerspart(bundler, markers) | 810 bundle2.buildobsmarkerspart(bundler, markers) |
826 | 811 |
827 @b2partsgenerator('bookmarks') | 812 @b2partsgenerator('bookmarks') |
828 def _pushb2bookmarks(pushop, bundler): | 813 def _pushb2bookmarks(pushop, bundler): |
829 """handle bookmark push through bundle2""" | 814 """handle bookmark push through bundle2""" |
830 if 'bookmarks' in pushop.stepsdone: | 815 if 'bookmarks' in pushop.stepsdone: |
1646 if heads is None: | 1631 if heads is None: |
1647 heads = repo.heads() | 1632 heads = repo.heads() |
1648 subset = [c.node() for c in repo.set('::%ln', heads)] | 1633 subset = [c.node() for c in repo.set('::%ln', heads)] |
1649 markers = repo.obsstore.relevantmarkers(subset) | 1634 markers = repo.obsstore.relevantmarkers(subset) |
1650 markers = sorted(markers) | 1635 markers = sorted(markers) |
1651 buildobsmarkerspart(bundler, markers) | 1636 bundle2.buildobsmarkerspart(bundler, markers) |
1652 | 1637 |
1653 @getbundle2partsgenerator('hgtagsfnodes') | 1638 @getbundle2partsgenerator('hgtagsfnodes') |
1654 def _getbundletagsfnodes(bundler, repo, source, bundlecaps=None, | 1639 def _getbundletagsfnodes(bundler, repo, source, bundlecaps=None, |
1655 b2caps=None, heads=None, common=None, | 1640 b2caps=None, heads=None, common=None, |
1656 **kwargs): | 1641 **kwargs): |