Move send/read cmd out of way - not convinced protocol.py is the right place, but...
authorJohn Carr <john.carr@unrouted.co.uk>
Wed, 24 Dec 2008 23:31:57 +0000 (23:31 +0000)
committerJohn Carr <john.carr@unrouted.co.uk>
Wed, 24 Dec 2008 23:31:57 +0000 (23:31 +0000)
dulwich/client.py
dulwich/server.py

index 606db0535c19fc7110d576b3eea75deae3855b27..08843f8c2d3f03ebd39b1c2dc25fc2ea0dae171b 100644 (file)
@@ -54,9 +54,6 @@ class GitClient(object):
         self.fileno = fileno
         self.host = host
 
-    def send_cmd(self, name, *args):
-        self.proto.write_pkt_line("%s %s" % (name, "".join(["%s\0" % a for a in args])))
-
     def capabilities(self):
         return "multi_ack side-band-64k thin-pack ofs-delta"
 
@@ -73,7 +70,7 @@ class GitClient(object):
         return refs, server_capabilities
 
     def send_pack(self, path):
-        self.send_cmd("git-receive-pack", path, "host=%s" % self.host)
+        self.proto.send_cmd("git-receive-pack", path, "host=%s" % self.host)
         refs, server_capabilities = self.read_refs()
         changed_refs = [] # FIXME
         if not changed_refs:
@@ -93,7 +90,7 @@ class GitClient(object):
         :param pack_data: Callback called for each bit of data in the pack
         :param progress: Callback for progress reports (strings)
         """
-        self.send_cmd("git-upload-pack", path, "host=%s" % self.host)
+        self.proto.send_cmd("git-upload-pack", path, "host=%s" % self.host)
 
         (refs, server_capabilities) = self.read_refs()
        
index f556a2307d8d9118ecbc1d58fc0bc16b46c6abc4..2b67727a8a817c4a514d6111372bb383c13e1f48 100644 (file)
@@ -261,15 +261,7 @@ class TCPGitRequestHandler(SocketServer.StreamRequestHandler):
 
     def handle(self):
         proto = Protocol(self.rfile.read, self.wfile.write)
-
-        request = proto.read_pkt_line()
-
-        # up until the space is the command to run, everything after is parameters
-        splice_point = request.find(' ')
-        command, params = request[:splice_point], request[splice_point+1:]
-
-        # params are null seperated
-        params = params.split(chr(0))
+        cmd, args = proto.read_cmd()
 
         # switch case to handle the specific git command
         if command == 'git-upload-pack':