Просмотр исходного кода

Generate and send useful packs

John Carr 16 лет назад
Родитель
Сommit
c1f18d1946
2 измененных файлов с 24 добавлено и 1 удалено
  1. 21 1
      bin/dul-daemon
  2. 3 0
      dulwich/server.py

+ 21 - 1
bin/dul-daemon

@@ -91,11 +91,31 @@ class GitBackend(Backend):
 
         commits_to_send = want[:]
         for sha in commits_to_send:
+            if sha in sha_queue:
+                continue
+
             sha_queue.append((1,sha))
 
             c = self.repo.commit(sha)
             for p in c.parents():
-                commits_to_send.append(p)
+                if not p in commits_to_send:
+                    commits_to_send.append(p)
+
+            def parse_tree(tree, sha_queue):
+                for mode, name, x in tree.entries():
+                    if not x in sha_queue:
+                        try:
+                            t = self.repo.get_tree(x)
+                            sha_queue.append((2, x))
+                            parse_tree(t, sha_queue)
+                        except:
+                            sha_queue.append((3, x))
+
+            treesha = c.tree()
+            if treesha not in sha_queue:
+                sha_queue.append((2, treesha))
+                t = self.repo.get_tree(treesha)
+                parse_tree(t, sha_queue)
 
             progress("counting objects: %d\r" % len(sha_queue))
 

+ 3 - 0
dulwich/server.py

@@ -190,6 +190,9 @@ class ReceivePackHandler(Handler):
         # backend can now deal with this refs and read a pack using self.read
         self.backend.apply_pack(client_refs, self.read)
 
+        # when we have read all the pack from the client, it assumes everything worked OK
+        # there is NO ack from the server before it reports victory.
+
 
 class TCPGitRequestHandler(SocketServer.StreamRequestHandler, Handler):