diff mercurial/sshrepo.py @ 11589:e8d22fe2ddab

protocol: clean up call-like functions in http and ssh clients
author Matt Mackall <mpm@selenic.com>
date Wed, 14 Jul 2010 17:07:10 -0500
parents 8a1f625e971d
children 0b15aee0a306
line wrap: on
line diff
--- a/mercurial/sshrepo.py	Wed Jul 14 16:55:44 2010 -0500
+++ b/mercurial/sshrepo.py	Wed Jul 14 17:07:10 2010 -0500
@@ -65,8 +65,8 @@
         self.pipeo, self.pipei, self.pipee = util.popen3(cmd)
 
         # skip any noise generated by remote shell
-        self.do_cmd("hello")
-        r = self.do_cmd("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
+        self._callstream("hello")
+        r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
         lines = ["", "dummy"]
         max_noise = 500
         while lines[-1] and max_noise:
@@ -118,7 +118,7 @@
 
     __del__ = cleanup
 
-    def do_cmd(self, cmd, **args):
+    def _callstream(self, cmd, **args):
         self.ui.debug("sending %s command\n" % cmd)
         self.pipeo.write("%s\n" % cmd)
         for k, v in sorted(args.iteritems()):
@@ -128,17 +128,10 @@
 
         return self.pipei
 
-    def call(self, cmd, **args):
-        self.do_cmd(cmd, **args)
+    def _call(self, cmd, **args):
+        self._callstream(cmd, **args)
         return self._recv()
 
-    def _call(self, cmd, **args):
-        self.do_cmd(cmd, **args)
-        return self._recv()
-
-    def _callstream(self, cmd, **args):
-        return self.do_cmd(cmd, **args)
-
     def _recv(self):
         l = self.pipei.readline()
         self.readerr()
@@ -157,28 +150,28 @@
         self.readerr()
 
     def lock(self):
-        self.call("lock")
+        self._call("lock")
         return remotelock(self)
 
     def unlock(self):
-        self.call("unlock")
+        self._call("unlock")
 
     def changegroup(self, nodes, kind):
         n = " ".join(map(hex, nodes))
-        return self.do_cmd("changegroup", roots=n)
+        return self._callstream("changegroup", roots=n)
 
     def changegroupsubset(self, bases, heads, kind):
         self.requirecap('changegroupsubset', _('look up remote changes'))
         bases = " ".join(map(hex, bases))
         heads = " ".join(map(hex, heads))
-        return self.do_cmd("changegroupsubset", bases=bases, heads=heads)
+        return self._callstream("changegroupsubset", bases=bases, heads=heads)
 
     def unbundle(self, cg, heads, source):
         '''Send cg (a readable file-like object representing the
         changegroup to push, typically a chunkbuffer object) to the
         remote server as a bundle. Return an integer indicating the
         result of the push (see localrepository.addchangegroup()).'''
-        d = self.call("unbundle", heads=' '.join(map(hex, heads)))
+        d = self._call("unbundle", heads=' '.join(map(hex, heads)))
         if d:
             # remote may send "unsynced changes"
             self.abort(error.RepoError(_("push refused: %s") % d))
@@ -206,7 +199,7 @@
         '''Send a changegroup to the remote server.  Return an integer
         similar to unbundle(). DEPRECATED, since it requires locking the
         remote.'''
-        d = self.call("addchangegroup")
+        d = self._call("addchangegroup")
         if d:
             self.abort(error.RepoError(_("push refused: %s") % d))
         while 1: