changeset 37646:72e26319f3b8

wireproto: use command executor for unbundle This also required unifying the name of the argument because the new API always passes arguments by keyword. I decided to change implementations to "bundle" instead of the interface to "cg" because "bundle" is more appropriate in a modern world. Differential Revision: https://phab.mercurial-scm.org/D3314
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 13 Apr 2018 11:30:44 -0700
parents 72b0982cd509
children 516b5a5edae3
files mercurial/exchange.py mercurial/localrepo.py mercurial/wireprotov1peer.py
diffstat 3 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Thu Apr 12 12:33:07 2018 -0700
+++ b/mercurial/exchange.py	Fri Apr 13 11:30:44 2018 -0700
@@ -1096,8 +1096,12 @@
     stream = util.chunkbuffer(bundler.getchunks())
     try:
         try:
-            reply = pushop.remote.unbundle(
-                stream, ['force'], pushop.remote.url())
+            with pushop.remote.commandexecutor() as e:
+                reply = e.callcommand('unbundle', {
+                    'bundle': stream,
+                    'heads': ['force'],
+                    'url': pushop.remote.url(),
+                }).result()
         except error.BundleValueError as exc:
             raise error.Abort(_('missing support for %s') % exc)
         try:
--- a/mercurial/localrepo.py	Thu Apr 12 12:33:07 2018 -0700
+++ b/mercurial/localrepo.py	Fri Apr 13 11:30:44 2018 -0700
@@ -275,14 +275,14 @@
         raise error.Abort(_('cannot perform stream clone against local '
                             'peer'))
 
-    def unbundle(self, cg, heads, url):
+    def unbundle(self, bundle, heads, url):
         """apply a bundle on a repo
 
         This function handles the repo locking itself."""
         try:
             try:
-                cg = exchange.readbundle(self.ui, cg, None)
-                ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
+                bundle = exchange.readbundle(self.ui, bundle, None)
+                ret = exchange.unbundle(self._repo, bundle, heads, 'push', url)
                 if util.safehasattr(ret, 'getchunks'):
                     # This is a bundle20 object, turn it into an unbundler.
                     # This little dance should be dropped eventually when the
--- a/mercurial/wireprotov1peer.py	Thu Apr 12 12:33:07 2018 -0700
+++ b/mercurial/wireprotov1peer.py	Fri Apr 13 11:30:44 2018 -0700
@@ -436,7 +436,7 @@
         else:
             return changegroupmod.cg1unpacker(f, 'UN')
 
-    def unbundle(self, cg, heads, url):
+    def unbundle(self, bundle, heads, url):
         '''Send cg (a readable file-like object representing the
         changegroup to push, typically a chunkbuffer object) to the
         remote server as a bundle.
@@ -456,9 +456,9 @@
         else:
             heads = wireprototypes.encodelist(heads)
 
-        if util.safehasattr(cg, 'deltaheader'):
+        if util.safehasattr(bundle, 'deltaheader'):
             # this a bundle10, do the old style call sequence
-            ret, output = self._callpush("unbundle", cg, heads=heads)
+            ret, output = self._callpush("unbundle", bundle, heads=heads)
             if ret == "":
                 raise error.ResponseError(
                     _('push failed:'), output)
@@ -472,7 +472,7 @@
                 self.ui.status(_('remote: '), l)
         else:
             # bundle2 push. Send a stream, fetch a stream.
-            stream = self._calltwowaystream('unbundle', cg, heads=heads)
+            stream = self._calltwowaystream('unbundle', bundle, heads=heads)
             ret = bundle2.getunbundler(self.ui, stream)
         return ret