Simplify checking of alternates in __contains__.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 14 Nov 2012 10:27:04 +0000 (11:27 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 14 Nov 2012 10:29:40 +0000 (11:29 +0100)
dulwich/object_store.py

index 4d261a2940f9d94b26bc34278456c1d07feca278..4972ee039b33d5cc3c5f085e36c8c8d061e90913 100644 (file)
@@ -231,21 +231,24 @@ class PackBasedObjectStore(BaseObjectStore):
         return []
 
     def contains_packed(self, sha):
-        """Check if a particular object is present by SHA1 and is packed."""
+        """Check if a particular object is present by SHA1 and is packed.
+
+        This does not check alternates.
+        """
         for pack in self.packs:
             if sha in pack:
                 return True
         return False
 
     def __contains__(self, sha):
-        """Check if a particular object is present by SHA1 in the main or alternate stores.
+        """Check if a particular object is present by SHA1.
 
         This method makes no distinction between loose and packed objects.
         """
         if self.contains_packed(sha) or self.contains_loose(sha):
             return True
         for alternate in self.alternates:
-            if alternate.contains_packed(sha) or alternate.contains_loose(sha):
+            if sha in alternate:
                 return True
         return False
 
@@ -305,7 +308,10 @@ class PackBasedObjectStore(BaseObjectStore):
         return itertools.chain(*iterables)
 
     def contains_loose(self, sha):
-        """Check if a particular object is present by SHA1 and is loose."""
+        """Check if a particular object is present by SHA1 and is loose.
+
+        This does not check alternates.
+        """
         return self._get_loose_object(sha) is not None
 
     def get_raw(self, name):