wireproto: properly call clonebundles command
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 13 Apr 2018 12:13:42 -0700
changeset 37649 a168799687e5
parent 37648 8f3c6fb55369
child 37650 62ebfda864de
wireproto: properly call clonebundles command We should not be using _call() to make wire protocol calls because it isn't part of the peer API. But clonebundles wasn't part of the supported commands in the peer API! So this commit defines that command in the commands interface, implements it, and teaches the one caller in core to call it using the command executor interface. Differential Revision: https://phab.mercurial-scm.org/D3317
mercurial/exchange.py
mercurial/localrepo.py
mercurial/repository.py
mercurial/wireprotov1peer.py
--- a/mercurial/exchange.py	Fri Apr 13 11:37:37 2018 -0700
+++ b/mercurial/exchange.py	Fri Apr 13 12:13:42 2018 -0700
@@ -2170,7 +2170,8 @@
     if not remote.capable('clonebundles'):
         return
 
-    res = remote._call('clonebundles')
+    with remote.commandexecutor() as e:
+        res = e.callcommand('clonebundles', {}).result()
 
     # If we call the wire protocol command, that's good enough to record the
     # attempt.
--- a/mercurial/localrepo.py	Fri Apr 13 11:37:37 2018 -0700
+++ b/mercurial/localrepo.py	Fri Apr 13 12:13:42 2018 -0700
@@ -235,6 +235,9 @@
     def capabilities(self):
         return self._caps
 
+    def clonebundles(self):
+        return self._repo.tryread('clonebundles.manifest')
+
     def debugwireargs(self, one, two, three=None, four=None, five=None):
         """Used to test argument passing over the wire"""
         return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
--- a/mercurial/repository.py	Fri Apr 13 11:37:37 2018 -0700
+++ b/mercurial/repository.py	Fri Apr 13 12:13:42 2018 -0700
@@ -101,6 +101,12 @@
         Returns a set of string capabilities.
         """
 
+    def clonebundles():
+        """Obtains the clone bundles manifest for the repo.
+
+        Returns the manifest as unparsed bytes.
+        """
+
     def debugwireargs(one, two, three=None, four=None, five=None):
         """Used to facilitate debugging of arguments passed over the wire."""
 
--- a/mercurial/wireprotov1peer.py	Fri Apr 13 11:37:37 2018 -0700
+++ b/mercurial/wireprotov1peer.py	Fri Apr 13 12:13:42 2018 -0700
@@ -322,6 +322,10 @@
 
     # Begin of ipeercommands interface.
 
+    def clonebundles(self):
+        self.requirecap('clonebundles', _('clone bundles'))
+        return self._call('clonebundles')
+
     @batchable
     def lookup(self, key):
         self.requirecap('lookup', _('look up remote revision'))