Patchwork D3294: bundlerepo: use command executor for wire protocol commands

login
register
mail settings
Submitter phabricator
Date April 12, 2018, 8 p.m.
Message ID <differential-rev-PHID-DREV-pybh7cajowqv5l7mvx55-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30829/
State Superseded
Headers show

Comments

phabricator - April 12, 2018, 8 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3294

AFFECTED FILES
  mercurial/bundlerepo.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -540,17 +540,32 @@ 
                       and peer.capable('getbundle')
                       and peer.capable('bundle2'))
         if canbundle2:
-            kwargs = {}
-            kwargs[r'common'] = common
-            kwargs[r'heads'] = rheads
-            kwargs[r'bundlecaps'] = exchange.caps20to10(repo, role='client')
-            kwargs[r'cg'] = True
-            b2 = peer.getbundle('incoming', **kwargs)
-            fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(),
-                                                     bundlename)
+            with peer.commandexecutor() as e:
+                fincoming = e.callcommand('getbundle', {
+                    'source': 'incoming',
+                    'common': common,
+                    'heads': rheads,
+                    'bundlecaps': exchange.caps20to10(repo, role='client'),
+                    'cg': True,
+                })
+
+                e.sendcommands()
+                b2 = fincoming.result()
+
+                fname = bundle = changegroup.writechunks(ui,
+                                                         b2._forwardchunks(),
+                                                         bundlename)
         else:
             if peer.capable('getbundle'):
-                cg = peer.getbundle('incoming', common=common, heads=rheads)
+                with peer.commandexecutor() as e:
+                    fincoming = e.callcommand('getbundle', {
+                        'source': 'incoming',
+                        'common': common,
+                        'heads': rheads,
+                    })
+
+                    e.sendcommands()
+                    cg = fincoming.result()
             elif onlyheads is None and not peer.capable('changegroupsubset'):
                 # compat with older servers when pulling all remote heads
 
@@ -596,7 +611,13 @@ 
 
     if bundlerepo:
         reponodes = [ctx.node() for ctx in bundlerepo[bundlerepo.firstnewrev:]]
-        remotephases = peer.listkeys('phases')
+
+        with peer.commandexecutor() as e:
+            flistkeys = e.callcommand('listkeys', {
+                'namespace': 'phases',
+            })
+
+        remotephases = flistkeys.result()
 
         pullop = exchange.pulloperation(bundlerepo, peer, heads=reponodes)
         pullop.trmanager = bundletransactionmanager()