write_pack_data expects a file object, not a callback. Add a ProtocolFile object...
authorJohn Carr <john.carr@unrouted.co.uk>
Thu, 25 Dec 2008 13:12:00 +0000 (13:12 +0000)
committerJohn Carr <john.carr@unrouted.co.uk>
Thu, 25 Dec 2008 13:12:00 +0000 (13:12 +0000)
dulwich/protocol.py
dulwich/server.py

index e467bc9a21acf13e9ba22263e09915623ed1ca55..f37b56cf948e050c1cd507f4d110ffe0e9231d0f 100644 (file)
 
 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):
index fd9e557cd2f3072b3b8daa4c3fc0a4510ac8216a..42b00ee7c09184992be9e268626bfb08dc5d2389 100644 (file)
@@ -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")