Parcourir la source

MissingObjectFinder: minor cleanup: 80 chars, others.

David Borowitz il y a 14 ans
Parent
commit
dec5a42a45
2 fichiers modifiés avec 11 ajouts et 4 suppressions
  1. 2 0
      NEWS
  2. 9 4
      dulwich/object_store.py

+ 2 - 0
NEWS

@@ -48,6 +48,8 @@
   * Use real in-memory objects rather than stubs for server tests.
     (Dave Borowitz)
 
+  * Clean up MissingObjectFinder. (Dave Borowitz)
+
  API CHANGES
 
   * ObjectStore.iter_tree_contents now walks contents in depth-first, sorted

+ 9 - 4
dulwich/object_store.py

@@ -711,8 +711,10 @@ class MissingObjectFinder(object):
 
     def __init__(self, object_store, haves, wants, progress=None,
                  get_tagged=None):
-        self.sha_done = set(haves)
-        self.objects_to_send = set([(w, None, False) for w in wants if w not in haves])
+        haves = set(haves)
+        self.sha_done = haves
+        self.objects_to_send = set([(w, None, False) for w in wants
+                                    if w not in haves])
         self.object_store = object_store
         if progress is None:
             self.progress = lambda x: None
@@ -721,10 +723,13 @@ class MissingObjectFinder(object):
         self._tagged = get_tagged and get_tagged() or {}
 
     def add_todo(self, entries):
-        self.objects_to_send.update([e for e in entries if not e[0] in self.sha_done])
+        self.objects_to_send.update([e for e in entries
+                                     if not e[0] in self.sha_done])
 
     def parse_tree(self, tree):
-        self.add_todo([(sha, name, not stat.S_ISDIR(mode)) for (mode, name, sha) in tree.entries() if not S_ISGITLINK(mode)])
+        self.add_todo([(sha, name, not stat.S_ISDIR(mode))
+                       for mode, name, sha in tree.entries()
+                       if not S_ISGITLINK(mode)])
 
     def parse_commit(self, commit):
         self.add_todo([(commit.tree, "", False)])