Mercurial > public > mercurial-scm > hg
comparison mercurial/exchange.py @ 21144:7a20fe8dc080
bundle2: use HG2X in the header
The current implementation of bundle2 is still very experimental and the 3.0
freeze is yesterday. The current bundle2 format has never been field-tested, so
we rename the header to HG2X. This leaves the HG20 header available for real
usage as a stable format in Mercurial 3.1.
We won't guarantee that future mercurial versions will keep supporting this
`HG2X` format.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 17 Apr 2014 15:27:54 -0400 |
parents | 5bb5d4ba14e5 |
children | 0c5088be66af |
comparison
equal
deleted
inserted
replaced
21143:5bb5d4ba14e5 | 21144:7a20fe8dc080 |
---|---|
30 raise util.Abort(_('%s: not a Mercurial bundle') % fname) | 30 raise util.Abort(_('%s: not a Mercurial bundle') % fname) |
31 if version == '10': | 31 if version == '10': |
32 if alg is None: | 32 if alg is None: |
33 alg = changegroup.readexactly(fh, 2) | 33 alg = changegroup.readexactly(fh, 2) |
34 return changegroup.unbundle10(fh, alg) | 34 return changegroup.unbundle10(fh, alg) |
35 elif version == '20': | 35 elif version == '2X': |
36 return bundle2.unbundle20(ui, fh, header=magic + version) | 36 return bundle2.unbundle20(ui, fh, header=magic + version) |
37 else: | 37 else: |
38 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) | 38 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) |
39 | 39 |
40 | 40 |
543 | 543 |
544 def _pullbundle2(pullop): | 544 def _pullbundle2(pullop): |
545 """pull data using bundle2 | 545 """pull data using bundle2 |
546 | 546 |
547 For now, the only supported data are changegroup.""" | 547 For now, the only supported data are changegroup.""" |
548 kwargs = {'bundlecaps': set(['HG20'])} | 548 kwargs = {'bundlecaps': set(['HG2X'])} |
549 capsblob = bundle2.encodecaps(pullop.repo.bundle2caps) | 549 capsblob = bundle2.encodecaps(pullop.repo.bundle2caps) |
550 kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob)) | 550 kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob)) |
551 # pulling changegroup | 551 # pulling changegroup |
552 pullop.todosteps.remove('changegroup') | 552 pullop.todosteps.remove('changegroup') |
553 if not pullop.fetch: | 553 if not pullop.fetch: |
642 return tr | 642 return tr |
643 | 643 |
644 def getbundle(repo, source, heads=None, common=None, bundlecaps=None): | 644 def getbundle(repo, source, heads=None, common=None, bundlecaps=None): |
645 """return a full bundle (with potentially multiple kind of parts) | 645 """return a full bundle (with potentially multiple kind of parts) |
646 | 646 |
647 Could be a bundle HG10 or a bundle HG20 depending on bundlecaps | 647 Could be a bundle HG10 or a bundle HG2X depending on bundlecaps |
648 passed. For now, the bundle can contain only changegroup, but this will | 648 passed. For now, the bundle can contain only changegroup, but this will |
649 changes when more part type will be available for bundle2. | 649 changes when more part type will be available for bundle2. |
650 | 650 |
651 This is different from changegroup.getbundle that only returns an HG10 | 651 This is different from changegroup.getbundle that only returns an HG10 |
652 changegroup bundle. They may eventually get reunited in the future when we | 652 changegroup bundle. They may eventually get reunited in the future when we |
656 when the API of bundle is refined. | 656 when the API of bundle is refined. |
657 """ | 657 """ |
658 # build bundle here. | 658 # build bundle here. |
659 cg = changegroup.getbundle(repo, source, heads=heads, | 659 cg = changegroup.getbundle(repo, source, heads=heads, |
660 common=common, bundlecaps=bundlecaps) | 660 common=common, bundlecaps=bundlecaps) |
661 if bundlecaps is None or 'HG20' not in bundlecaps: | 661 if bundlecaps is None or 'HG2X' not in bundlecaps: |
662 return cg | 662 return cg |
663 # very crude first implementation, | 663 # very crude first implementation, |
664 # the bundle API will change and the generation will be done lazily. | 664 # the bundle API will change and the generation will be done lazily. |
665 b2caps = {} | 665 b2caps = {} |
666 for bcaps in bundlecaps: | 666 for bcaps in bundlecaps: |