2
0
John Carr 16 жил өмнө
parent
commit
af849995f5
2 өөрчлөгдсөн 17 нэмэгдсэн , 15 устгасан
  1. 4 4
      dulwich/protocol.py
  2. 13 11
      dulwich/server.py

+ 4 - 4
dulwich/protocol.py

@@ -80,12 +80,12 @@ class Protocol(object):
         :param channel: int specifying which channel to write to
         :param blob: a blob of data (as a string) to send on this channel
         """
-        # a pktline can be a max of 65535. a sideband line can therefore be
-        # 65535-5 = 65530
+        # a pktline can be a max of 65520. a sideband line can therefore be
+        # 65520-5 = 65515
         # WTF: Why have the len in ASCII, but the channel in binary.
         while blob:
-            self.write_pkt_line("%s%s" % (chr(channel), blob[:65530]))
-            blob = blob[65530:]
+            self.write_pkt_line("%s%s" % (chr(channel), blob[:65515]))
+            blob = blob[65515:]
 
     def send_cmd(self, cmd, *args):
         """

+ 13 - 11
dulwich/server.py

@@ -40,7 +40,7 @@ class Backend(object):
         """
         raise NotImplementedError
 
-    def fetch_objects(self, determine_wants, graph_waker, progress):
+    def fetch_objects(self, determine_wants, graph_walker, progress):
         """
         Yield the objects required for a list of commits.
 
@@ -84,8 +84,9 @@ class GitBackend(Backend):
 
         print "pack applied"
 
-    def fetch_objects(self, determine_wants, graph_waker, progress):
-        for sha in generate_pack_contents(determine_wants(self.get_refs()), have, self.repo.get_object):
+    def fetch_objects(self, determine_wants, graph_walker, progress):
+        shas = self.repo.find_missing_objects(determine_wants, graph_walker, progress)
+        for sha in shas:
             yield self.repo.get_object(sha)
 
 
@@ -108,9 +109,9 @@ class UploadPackHandler(Handler):
         def determine_wants(heads):
             keys = heads.keys()
             if keys:
-                self.proto.write_pkt_line("%s %s\x00%s\n" % (keys[0], heads[keys[0]], self.capabilities()))
+                self.proto.write_pkt_line("%s %s\x00%s\n" % ( heads[keys[0]], keys[0], self.capabilities()))
                 for k in keys[1:]:
-                    self.proto.write_pkt_line("%s %s\n" % (k, heads[k]))
+                    self.proto.write_pkt_line("%s %s\n" % (heads[k], k))
 
             # i'm done..
             self.proto.write("0000")
@@ -125,17 +126,17 @@ class UploadPackHandler(Handler):
 
             want_revs = []
             while want and want[:4] == 'want':
-                want_rev = want[5:45]
-                # FIXME: This check probably isnt needed?
-                want_revs.append(want_rev)
+                want_revs.append(want[5:45])
                 want = self.proto.read_pkt_line()
             return want_revs
 
         progress = lambda x: self.proto.write_sideband(2, x)
+        write = lambda x: self.proto.write_sideband(1, x)
 
         class ProtocolGraphWalker(object):
 
-            def __init__(self):
+            def __init__(self, proto):
+                self.proto = proto
                 self._last_sha = None
 
             def ack(self, have_ref):
@@ -146,8 +147,8 @@ class UploadPackHandler(Handler):
                 if have[:4] == 'have':
                     return have[5:45]
 
-                if have[:4] == 'done':
-                    return None
+                #if have[:4] == 'done':
+                #    return None
 
                 if self._last_sha:
                     # Oddness: Git seems to resend the last ACK, without the "continue" statement
@@ -156,6 +157,7 @@ class UploadPackHandler(Handler):
                 # The exchange finishes with a NAK
                 self.proto.write_pkt_line("NAK\n")
 
+        graph_walker = ProtocolGraphWalker(self.proto)
         objects = list(self.backend.fetch_objects(determine_wants, graph_walker, progress))
         progress("dul-daemon says what\n")
         progress("counting objects: %d, done.\n" % len(objects))