Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHGa119e97b6caf: py3: handle keyword arguments correctly in exchange.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
durin42 |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
empty. The default value of ``None`` means to respect the server | empty. The default value of ``None`` means to respect the server | ||||
configuration for preferring stream clones. | configuration for preferring stream clones. | ||||
Returns the ``pulloperation`` created for this pull. | Returns the ``pulloperation`` created for this pull. | ||||
""" | """ | ||||
if opargs is None: | if opargs is None: | ||||
opargs = {} | opargs = {} | ||||
pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks, | pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks, | ||||
streamclonerequested=streamclonerequested, **opargs) | streamclonerequested=streamclonerequested, | ||||
**pycompat.strkwargs(opargs)) | |||||
peerlocal = pullop.remote.local() | peerlocal = pullop.remote.local() | ||||
if peerlocal: | if peerlocal: | ||||
missing = set(peerlocal.requirements) - pullop.repo.supported | missing = set(peerlocal.requirements) - pullop.repo.supported | ||||
if missing: | if missing: | ||||
msg = _("required features are not" | msg = _("required features are not" | ||||
" supported in the destination:" | " supported in the destination:" | ||||
" %s") % (', '.join(sorted(missing))) | " %s") % (', '.join(sorted(missing))) | ||||
return bundler.getchunks() | return bundler.getchunks() | ||||
@getbundle2partsgenerator('changegroup') | @getbundle2partsgenerator('changegroup') | ||||
def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, | def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, | ||||
b2caps=None, heads=None, common=None, **kwargs): | b2caps=None, heads=None, common=None, **kwargs): | ||||
"""add a changegroup part to the requested bundle""" | """add a changegroup part to the requested bundle""" | ||||
cgstream = None | cgstream = None | ||||
if kwargs.get('cg', True): | if kwargs.get(r'cg', True): | ||||
# build changegroup bundle here. | # build changegroup bundle here. | ||||
version = '01' | version = '01' | ||||
cgversions = b2caps.get('changegroup') | cgversions = b2caps.get('changegroup') | ||||
if cgversions: # 3.1 and 3.2 ship with an empty value | if cgversions: # 3.1 and 3.2 ship with an empty value | ||||
cgversions = [v for v in cgversions | cgversions = [v for v in cgversions | ||||
if v in changegroup.supportedoutgoingversions(repo)] | if v in changegroup.supportedoutgoingversions(repo)] | ||||
if not cgversions: | if not cgversions: | ||||
raise ValueError(_('no common changegroup version')) | raise ValueError(_('no common changegroup version')) | ||||
mandatory=False) | mandatory=False) | ||||
if 'treemanifest' in repo.requirements: | if 'treemanifest' in repo.requirements: | ||||
part.addparam('treemanifest', '1') | part.addparam('treemanifest', '1') | ||||
@getbundle2partsgenerator('bookmarks') | @getbundle2partsgenerator('bookmarks') | ||||
def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None, | def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None, | ||||
b2caps=None, **kwargs): | b2caps=None, **kwargs): | ||||
"""add a bookmark part to the requested bundle""" | """add a bookmark part to the requested bundle""" | ||||
if not kwargs.get('bookmarks', False): | if not kwargs.get(r'bookmarks', False): | ||||
return | return | ||||
if 'bookmarks' not in b2caps: | if 'bookmarks' not in b2caps: | ||||
raise ValueError(_('no common bookmarks exchange method')) | raise ValueError(_('no common bookmarks exchange method')) | ||||
books = bookmod.listbinbookmarks(repo) | books = bookmod.listbinbookmarks(repo) | ||||
data = bookmod.binaryencode(books) | data = bookmod.binaryencode(books) | ||||
if data: | if data: | ||||
bundler.newpart('bookmarks', data=data) | bundler.newpart('bookmarks', data=data) | ||||
@getbundle2partsgenerator('listkeys') | @getbundle2partsgenerator('listkeys') | ||||
def _getbundlelistkeysparts(bundler, repo, source, bundlecaps=None, | def _getbundlelistkeysparts(bundler, repo, source, bundlecaps=None, | ||||
b2caps=None, **kwargs): | b2caps=None, **kwargs): | ||||
"""add parts containing listkeys namespaces to the requested bundle""" | """add parts containing listkeys namespaces to the requested bundle""" | ||||
listkeys = kwargs.get('listkeys', ()) | listkeys = kwargs.get(r'listkeys', ()) | ||||
for namespace in listkeys: | for namespace in listkeys: | ||||
part = bundler.newpart('listkeys') | part = bundler.newpart('listkeys') | ||||
part.addparam('namespace', namespace) | part.addparam('namespace', namespace) | ||||
keys = repo.listkeys(namespace).items() | keys = repo.listkeys(namespace).items() | ||||
part.data = pushkey.encodekeys(keys) | part.data = pushkey.encodekeys(keys) | ||||
@getbundle2partsgenerator('obsmarkers') | @getbundle2partsgenerator('obsmarkers') | ||||
def _getbundleobsmarkerpart(bundler, repo, source, bundlecaps=None, | def _getbundleobsmarkerpart(bundler, repo, source, bundlecaps=None, | ||||
b2caps=None, heads=None, **kwargs): | b2caps=None, heads=None, **kwargs): | ||||
"""add an obsolescence markers part to the requested bundle""" | """add an obsolescence markers part to the requested bundle""" | ||||
if kwargs.get('obsmarkers', False): | if kwargs.get(r'obsmarkers', False): | ||||
if heads is None: | if heads is None: | ||||
heads = repo.heads() | heads = repo.heads() | ||||
subset = [c.node() for c in repo.set('::%ln', heads)] | subset = [c.node() for c in repo.set('::%ln', heads)] | ||||
markers = repo.obsstore.relevantmarkers(subset) | markers = repo.obsstore.relevantmarkers(subset) | ||||
markers = sorted(markers) | markers = sorted(markers) | ||||
bundle2.buildobsmarkerspart(bundler, markers) | bundle2.buildobsmarkerspart(bundler, markers) | ||||
@getbundle2partsgenerator('phases') | @getbundle2partsgenerator('phases') | ||||
def _getbundlephasespart(bundler, repo, source, bundlecaps=None, | def _getbundlephasespart(bundler, repo, source, bundlecaps=None, | ||||
b2caps=None, heads=None, **kwargs): | b2caps=None, heads=None, **kwargs): | ||||
"""add phase heads part to the requested bundle""" | """add phase heads part to the requested bundle""" | ||||
if kwargs.get('phases', False): | if kwargs.get(r'phases', False): | ||||
if not 'heads' in b2caps.get('phases'): | if not 'heads' in b2caps.get('phases'): | ||||
raise ValueError(_('no common phases exchange method')) | raise ValueError(_('no common phases exchange method')) | ||||
if heads is None: | if heads is None: | ||||
heads = repo.heads() | heads = repo.heads() | ||||
headsbyphase = collections.defaultdict(set) | headsbyphase = collections.defaultdict(set) | ||||
if repo.publishing(): | if repo.publishing(): | ||||
headsbyphase[phases.public] = heads | headsbyphase[phases.public] = heads | ||||
Only values for heads in this bundle will be transferred. | Only values for heads in this bundle will be transferred. | ||||
The part data consists of pairs of 20 byte changeset node and .hgtags | The part data consists of pairs of 20 byte changeset node and .hgtags | ||||
filenodes raw values. | filenodes raw values. | ||||
""" | """ | ||||
# Don't send unless: | # Don't send unless: | ||||
# - changeset are being exchanged, | # - changeset are being exchanged, | ||||
# - the client supports it. | # - the client supports it. | ||||
if not (kwargs.get('cg', True) and 'hgtagsfnodes' in b2caps): | if not (kwargs.get(r'cg', True) and 'hgtagsfnodes' in b2caps): | ||||
return | return | ||||
outgoing = _computeoutgoing(repo, heads, common) | outgoing = _computeoutgoing(repo, heads, common) | ||||
bundle2.addparttagsfnodescache(repo, bundler, outgoing) | bundle2.addparttagsfnodescache(repo, bundler, outgoing) | ||||
def check_heads(repo, their_heads, context): | def check_heads(repo, their_heads, context): | ||||
"""check if the heads of a repo have been modified | """check if the heads of a repo have been modified | ||||