Mercurial > hg-stable
comparison mercurial/exchange.py @ 21645:aed14bb165f3
bundle2: introduce a ``caps20to10`` function
This function factors the creation of appropriate entries to use in
``bundlecaps`` argument of ``getbundle``. This cleans up code calling
``getbundle`` and helps its usage in more part of the code.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 22 May 2014 13:31:33 -0700 |
parents | 17755dd8c509 |
children | ddf9a00c1239 |
comparison
equal
deleted
inserted
replaced
21644:17755dd8c509 | 21645:aed14bb165f3 |
---|---|
530 | 530 |
531 def _pullbundle2(pullop): | 531 def _pullbundle2(pullop): |
532 """pull data using bundle2 | 532 """pull data using bundle2 |
533 | 533 |
534 For now, the only supported data are changegroup.""" | 534 For now, the only supported data are changegroup.""" |
535 kwargs = {'bundlecaps': set(['HG2X'])} | 535 kwargs = {'bundlecaps': caps20to10(pullop.repo)} |
536 capsblob = bundle2.encodecaps(pullop.repo.bundle2caps) | |
537 kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob)) | |
538 # pulling changegroup | 536 # pulling changegroup |
539 pullop.todosteps.remove('changegroup') | 537 pullop.todosteps.remove('changegroup') |
540 | 538 |
541 kwargs['common'] = pullop.common | 539 kwargs['common'] = pullop.common |
542 kwargs['heads'] = pullop.heads or pullop.rheads | 540 kwargs['heads'] = pullop.heads or pullop.rheads |
633 if key.startswith('dump'): | 631 if key.startswith('dump'): |
634 data = base85.b85decode(remoteobs[key]) | 632 data = base85.b85decode(remoteobs[key]) |
635 pullop.repo.obsstore.mergemarkers(tr, data) | 633 pullop.repo.obsstore.mergemarkers(tr, data) |
636 pullop.repo.invalidatevolatilesets() | 634 pullop.repo.invalidatevolatilesets() |
637 return tr | 635 return tr |
636 | |
637 def caps20to10(repo): | |
638 """return a set with appropriate options to use bundle20 during getbundle""" | |
639 caps = set(['HG2X']) | |
640 capsblob = bundle2.encodecaps(repo.bundle2caps) | |
641 caps.add('bundle2=' + urllib.quote(capsblob)) | |
642 return caps | |
638 | 643 |
639 def getbundle(repo, source, heads=None, common=None, bundlecaps=None, | 644 def getbundle(repo, source, heads=None, common=None, bundlecaps=None, |
640 **kwargs): | 645 **kwargs): |
641 """return a full bundle (with potentially multiple kind of parts) | 646 """return a full bundle (with potentially multiple kind of parts) |
642 | 647 |