Преглед на файлове

BaseObjectStore.determine_wants_all no longer breaks on zero SHAs.

Jelmer Vernooij преди 14 години
родител
ревизия
8a2f5cefc0
променени са 4 файла, в които са добавени 15 реда и са изтрити 1 реда
  1. 3 0
      NEWS
  2. 3 1
      dulwich/object_store.py
  3. 1 0
      dulwich/objects.py
  4. 8 0
      dulwich/tests/test_object_store.py

+ 3 - 0
NEWS

@@ -9,6 +9,9 @@
   * Fix get_transport_and_path compatibility with pre-2.6.5 versions of Python.
     (Max Bowsher, #707438)
 
+  * BaseObjectStore.determine_wants_all no longer breaks on zero SHAs.
+    (Jelmer Vernooij)
+
  IMPROVEMENTS
 
   * Sphinxified documentation. (Lukasz Balcerzak)

+ 3 - 1
dulwich/object_store.py

@@ -40,6 +40,7 @@ from dulwich.objects import (
     ShaFile,
     Tag,
     Tree,
+    ZERO_SHA,
     hex_to_sha,
     sha_to_hex,
     hex_to_filename,
@@ -66,7 +67,8 @@ class BaseObjectStore(object):
 
     def determine_wants_all(self, refs):
         return [sha for (ref, sha) in refs.iteritems()
-                if not sha in self and not ref.endswith("^{}")]
+                if not sha in self and not ref.endswith("^{}") and
+                   not sha == ZERO_SHA]
 
     def iter_shas(self, shas):
         """Iterate over the objects for the specified shas.

+ 1 - 0
dulwich/objects.py

@@ -43,6 +43,7 @@ from dulwich._compat import (
     TreeEntryTuple,
     )
 
+ZERO_SHA = "0" * 40
 
 # Header fields for commits
 _TREE_HEADER = "tree"

+ 8 - 0
dulwich/tests/test_object_store.py

@@ -57,6 +57,14 @@ testobject = make_object(Blob, data="yummy data")
 
 class ObjectStoreTests(object):
 
+    def test_determine_wants_all(self):
+        self.assertEquals(["1" * 40],
+            self.store.determine_wants_all({"refs/heads/foo": "1" * 40}))
+
+    def test_determine_wants_all_zero(self):
+        self.assertEquals([],
+            self.store.determine_wants_all({"refs/heads/foo": "0" * 40}))
+
     def test_iter(self):
         self.assertEquals([], list(self.store))