소스 검색

Actually, enforce determine_wants() returns an empty list.

Jelmer Vernooij 11 년 전
부모
커밋
37fd301545
4개의 변경된 파일9개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 0
      NEWS
  2. 4 2
      dulwich/repo.py
  3. 2 2
      dulwich/server.py
  4. 1 1
      dulwich/tests/test_server.py

+ 2 - 0
NEWS

@@ -12,6 +12,8 @@
   * Fix capability negotiation when fetching packs over HTTP.
     (#1072461, William Grant)
 
+  * Enforce determine_wants returning an empty list rather than None. (Fabien Boucher, Jelmer Vernooij)
+
  IMPROVEMENTS
 
   * Support passing a single revision to BaseRepo.get_walker() rather than a list of revisions. 

+ 4 - 2
dulwich/repo.py

@@ -896,10 +896,12 @@ class BaseRepo(object):
         :return: iterator over objects, with __len__ implemented
         """
         wants = determine_wants(self.get_refs())
-        if not wants:
+        if type(wants) is not list:
+            raise TypeError("determine_wants() did not return a list")
+        if wants == []:
             # TODO(dborowitz): find a way to short-circuit that doesn't change
             # this interface.
-            return None
+            return []
         haves = self.object_store.find_common_revisions(graph_walker)
         return self.object_store.iter_shas(
           self.object_store.find_missing_objects(haves, wants, progress,

+ 2 - 2
dulwich/server.py

@@ -359,7 +359,7 @@ class ProtocolGraphWalker(object):
         if not heads:
             # The repo is empty, so short-circuit the whole process.
             self.proto.write_pkt_line(None)
-            return None
+            return []
         values = set(heads.itervalues())
         if self.advertise_refs or not self.http_req:
             for i, (ref, sha) in enumerate(sorted(heads.iteritems())):
@@ -402,7 +402,7 @@ class ProtocolGraphWalker(object):
             # The client may close the socket at this point, expecting a
             # flush-pkt from the server. We might be ready to send a packfile at
             # this point, so we need to explicitly short-circuit in this case.
-            return None
+            return []
 
         return want_revs
 

+ 1 - 1
dulwich/tests/test_server.py

@@ -264,7 +264,7 @@ class ProtocolGraphWalkerTestCase(TestCase):
         self.assertEqual((None, None), _split_proto_line('', allowed))
 
     def test_determine_wants(self):
-        self.assertEqual(None, self._walker.determine_wants({}))
+        self.assertEqual([], self._walker.determine_wants({}))
         self.assertEqual(None, self._walker.proto.get_received_line())
 
         self._walker.proto.set_output([