فهرست منبع

Move send/read cmd out of way - not convinced protocol.py is the right place, but certainly don't want them in the code that doesnt need them

John Carr 16 سال پیش
والد
کامیت
9c46e5fd85
2فایلهای تغییر یافته به همراه3 افزوده شده و 14 حذف شده
  1. 2 5
      dulwich/client.py
  2. 1 9
      dulwich/server.py

+ 2 - 5
dulwich/client.py

@@ -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()
        

+ 1 - 9
dulwich/server.py

@@ -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':