Преглед на файлове

write_pack_data expects a file object, not a callback. Add a ProtocolFile object to satisfy its desires for now.

John Carr преди 16 години
родител
ревизия
75f1dd79b6
променени са 2 файла, в които са добавени 18 реда и са изтрити 2 реда
  1. 16 0
      dulwich/protocol.py
  2. 2 2
      dulwich/server.py

+ 16 - 0
dulwich/protocol.py

@@ -19,6 +19,22 @@
 
 TCP_GIT_PORT = 9418
 
+class ProtocolFile(object):
+    """
+    Some network ops are like file ops. The file ops expect to operate on
+    file objects, so provide them with a dummy file.
+    """
+
+    def __init__(self, read, write):
+        self.read = read
+        self.write = write
+
+    def tell(self):
+        pass
+
+    def close(self):
+        pass
+
 class Protocol(object):
 
     def __init__(self, read, write):

+ 2 - 2
dulwich/server.py

@@ -17,7 +17,7 @@
 # MA  02110-1301, USA.
 
 import SocketServer
-from dulwich.protocol import Protocol, TCP_GIT_PORT, extract_capabilities
+from dulwich.protocol import Protocol, ProtocolFile, TCP_GIT_PORT, extract_capabilities
 from dulwich.repo import Repo
 from dulwich.pack import PackData, Pack, write_pack_data
 import os, sha, tempfile
@@ -140,7 +140,7 @@ class GitBackend(Backend):
 
         progress("counting objects: %d, done.\n" % len(sha_queue))
 
-        write_pack_data(write, (self.repo.get_object(sha).as_raw_string() for sha in sha_queue))
+        write_pack_data(ProtocolFile(None, write), (self.repo.get_object(sha).as_raw_string() for sha in sha_queue), len(sha_queue))
 
         progress("how was that, then?\n")