changeset 77:d7b8768d005a

reapplying defunkts changes
author Scott Chacon <schacon@gmail.com>
date Fri, 01 May 2009 20:16:07 -0700
parents aa2dadf04144
children 71b07e16004f
files git_handler.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/git_handler.py
+++ b/git_handler.py
@@ -360,14 +360,16 @@
     def generate_pack_contents(self, want, have):
         graph_walker = SimpleFetchGraphWalker(want, self.git.get_parents)
         next = graph_walker.next()
-        shas = []
+        shas = set()
         while next:
             if next in have:
                 graph_walker.ack(next)
             else:
-                shas.append(next)
+                shas.add(next)
             next = graph_walker.next()
-
+        
+        seen = []
+        
         # so now i have the shas, need to turn them into a list of
         # tuples (sha, path) for ALL the objects i'm sending
         # TODO : don't send blobs or trees they already have
@@ -377,11 +379,15 @@
             for (mode, name, sha) in tree.entries():
                 if mode == 57344: # TODO : properly handle submodules
                     continue
+                if sha in seen:
+                    continue
+                    
                 obj = self.git.get_object(sha)
+                seen.append(sha)
                 if isinstance (obj, Blob):
                     changes.append((obj, path + name))
                 elif isinstance(obj, Tree):
-                    changes.extend (get_objects (obj, path + name + '/'))
+                    changes.extend(get_objects(obj, path + name + '/'))
             return changes
 
         objects = []