treediscovery: switch to command executor interface
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 13 Apr 2018 11:10:59 -0700
changeset 37634 0ed11f9368fd
parent 37633 33a6eee08db2
child 37635 cc8c06835097
treediscovery: switch to command executor interface We now have a new interface for requesting that commands run. Switch to it. Differential Revision: https://phab.mercurial-scm.org/D3272
mercurial/treediscovery.py
--- a/mercurial/treediscovery.py	Wed Apr 11 16:18:26 2018 -0700
+++ b/mercurial/treediscovery.py	Fri Apr 13 11:10:59 2018 -0700
@@ -36,7 +36,8 @@
     base = set()
 
     if not heads:
-        heads = remote.heads()
+        with remote.commandexecutor() as e:
+            heads = e.callcommand('heads', {}).result()
 
     if repo.changelog.tip() == nullid:
         base.add(nullid)
@@ -65,7 +66,10 @@
     # a 'branch' here is a linear segment of history, with four parts:
     # head, root, first parent, second parent
     # (a branch always has two parents (or none) by definition)
-    unknown = collections.deque(remote.branches(unknown))
+    with remote.commandexecutor() as e:
+        branches = e.callcommand('branches', {'nodes': unknown}).result()
+
+    unknown = collections.deque(branches)
     while unknown:
         r = []
         while unknown:
@@ -107,7 +111,12 @@
             repo.ui.debug("request %d: %s\n" %
                         (reqcnt, " ".join(map(short, r))))
             for p in xrange(0, len(r), 10):
-                for b in remote.branches(r[p:p + 10]):
+                with remote.commandexecutor() as e:
+                    branches = e.callcommand('branches', {
+                        'nodes': r[p:p + 10],
+                    }).result()
+
+                for b in branches:
                     repo.ui.debug("received %s:%s\n" %
                                   (short(b[0]), short(b[1])))
                     unknown.append(b)
@@ -117,7 +126,11 @@
         newsearch = []
         reqcnt += 1
         repo.ui.progress(_('searching'), reqcnt, unit=_('queries'))
-        for n, l in zip(search, remote.between(search)):
+
+        with remote.commandexecutor() as e:
+            between = e.callcommand('between', {'pairs': search}).result()
+
+        for n, l in zip(search, between):
             l.append(n[1])
             p = n[0]
             f = 1