571 kwargs = {'bundlecaps': set(['HG2X'])} |
571 kwargs = {'bundlecaps': set(['HG2X'])} |
572 capsblob = bundle2.encodecaps(pullop.repo.bundle2caps) |
572 capsblob = bundle2.encodecaps(pullop.repo.bundle2caps) |
573 kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob)) |
573 kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob)) |
574 # pulling changegroup |
574 # pulling changegroup |
575 pullop.todosteps.remove('changegroup') |
575 pullop.todosteps.remove('changegroup') |
|
576 |
|
577 kwargs['common'] = pullop.common |
|
578 kwargs['heads'] = pullop.heads or pullop.rheads |
576 if not pullop.fetch: |
579 if not pullop.fetch: |
577 pullop.repo.ui.status(_("no changes found\n")) |
580 pullop.repo.ui.status(_("no changes found\n")) |
578 pullop.cgresult = 0 |
581 pullop.cgresult = 0 |
579 else: |
582 else: |
580 kwargs['common'] = pullop.common |
|
581 kwargs['heads'] = pullop.heads or pullop.rheads |
|
582 if pullop.heads is None and list(pullop.common) == [nullid]: |
583 if pullop.heads is None and list(pullop.common) == [nullid]: |
583 pullop.repo.ui.status(_("requesting all changes\n")) |
584 pullop.repo.ui.status(_("requesting all changes\n")) |
584 _pullbundle2extraprepare(pullop, kwargs) |
585 _pullbundle2extraprepare(pullop, kwargs) |
585 if kwargs.keys() == ['format']: |
586 if kwargs.keys() == ['format']: |
586 return # nothing to pull |
587 return # nothing to pull |
587 bundle = pullop.remote.getbundle('pull', **kwargs) |
588 bundle = pullop.remote.getbundle('pull', **kwargs) |
588 try: |
589 try: |
589 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction) |
590 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction) |
590 except bundle2.UnknownPartError, exc: |
591 except bundle2.UnknownPartError, exc: |
591 raise util.Abort('missing support for %s' % exc) |
592 raise util.Abort('missing support for %s' % exc) |
592 assert len(op.records['changegroup']) == 1 |
593 |
593 pullop.cgresult = op.records['changegroup'][0]['return'] |
594 if pullop.fetch: |
|
595 assert len(op.records['changegroup']) == 1 |
|
596 pullop.cgresult = op.records['changegroup'][0]['return'] |
594 |
597 |
595 def _pullbundle2extraprepare(pullop, kwargs): |
598 def _pullbundle2extraprepare(pullop, kwargs): |
596 """hook function so that extensions can extend the getbundle call""" |
599 """hook function so that extensions can extend the getbundle call""" |
597 pass |
600 pass |
598 |
601 |
682 have a clearer idea of the API we what to query different data. |
685 have a clearer idea of the API we what to query different data. |
683 |
686 |
684 The implementation is at a very early stage and will get massive rework |
687 The implementation is at a very early stage and will get massive rework |
685 when the API of bundle is refined. |
688 when the API of bundle is refined. |
686 """ |
689 """ |
687 # build bundle here. |
690 # build changegroup bundle here. |
688 cg = changegroup.getbundle(repo, source, heads=heads, |
691 cg = changegroup.getbundle(repo, source, heads=heads, |
689 common=common, bundlecaps=bundlecaps) |
692 common=common, bundlecaps=bundlecaps) |
690 if bundlecaps is None or 'HG2X' not in bundlecaps: |
693 if bundlecaps is None or 'HG2X' not in bundlecaps: |
691 return cg |
694 return cg |
692 # very crude first implementation, |
695 # very crude first implementation, |
695 for bcaps in bundlecaps: |
698 for bcaps in bundlecaps: |
696 if bcaps.startswith('bundle2='): |
699 if bcaps.startswith('bundle2='): |
697 blob = urllib.unquote(bcaps[len('bundle2='):]) |
700 blob = urllib.unquote(bcaps[len('bundle2='):]) |
698 b2caps.update(bundle2.decodecaps(blob)) |
701 b2caps.update(bundle2.decodecaps(blob)) |
699 bundler = bundle2.bundle20(repo.ui, b2caps) |
702 bundler = bundle2.bundle20(repo.ui, b2caps) |
700 part = bundle2.bundlepart('b2x:changegroup', data=cg.getchunks()) |
703 if cg: |
701 bundler.addpart(part) |
704 part = bundle2.bundlepart('b2x:changegroup', data=cg.getchunks()) |
|
705 bundler.addpart(part) |
702 _getbundleextrapart(bundler, repo, source, heads=heads, common=common, |
706 _getbundleextrapart(bundler, repo, source, heads=heads, common=common, |
703 bundlecaps=bundlecaps, **kwargs) |
707 bundlecaps=bundlecaps, **kwargs) |
704 return util.chunkbuffer(bundler.getchunks()) |
708 return util.chunkbuffer(bundler.getchunks()) |
705 |
709 |
706 def _getbundleextrapart(bundler, repo, source, heads=None, common=None, |
710 def _getbundleextrapart(bundler, repo, source, heads=None, common=None, |