Browse Source

fetch: pass fetch depth into determine_wants

Peter Rowlands 4 years ago
parent
commit
83dbaca039
3 changed files with 7 additions and 10 deletions
  1. 3 6
      dulwich/client.py
  2. 3 3
      dulwich/object_store.py
  3. 1 1
      dulwich/repo.py

+ 3 - 6
dulwich/client.py

@@ -502,10 +502,7 @@ class GitClient(object):
 
         """
         if determine_wants is None:
-            if depth is not None and depth > 1:
-                determine_wants = target.object_store.determine_wants_force
-            else:
-                determine_wants = target.object_store.determine_wants_all
+            determine_wants = target.object_store.determine_wants_all
         if CAPABILITY_THIN_PACK in self._fetch_capabilities:
             # TODO(jelmer): Avoid reading entire file into memory and
             # only processing it after the whole file has been fetched.
@@ -1026,7 +1023,7 @@ class TraditionalGitClient(GitClient):
                 return FetchPackResult(refs, symrefs, agent)
 
             try:
-                wants = determine_wants(refs)
+                wants = determine_wants(refs, depth=depth)
             except BaseException:
                 proto.write_pkt_line(None)
                 raise
@@ -2045,7 +2042,7 @@ class HttpGitClient(GitClient):
             symrefs,
             agent,
         ) = self._negotiate_upload_pack_capabilities(server_capabilities)
-        wants = determine_wants(refs)
+        wants = determine_wants(refs, depth=depth)
         if wants is not None:
             wants = [cid for cid in wants if cid != ZERO_SHA]
         if not wants:

+ 3 - 3
dulwich/object_store.py

@@ -82,13 +82,13 @@ class BaseObjectStore(object):
                 return True
             return depth > self._get_depth(sha)
 
-        return {
+        return [
             sha
             for (ref, sha) in refs.items()
-            if sha not in self or _want_deepen(sha)
+            if (sha not in self or _want_deepen(sha))
             and not ref.endswith(ANNOTATED_TAG_SUFFIX)
             and not sha == ZERO_SHA
-        }
+        ]
 
     def iter_shas(self, shas):
         """Iterate over the objects for the specified shas.

+ 1 - 1
dulwich/repo.py

@@ -495,7 +495,7 @@ class BaseRepo(object):
                     refs[ref + ANNOTATED_TAG_SUFFIX] = obj.object[1]
                 refs[ref] = sha
 
-        wants = determine_wants(refs)
+        wants = determine_wants(refs, depth=depth)
         if not isinstance(wants, list):
             raise TypeError("determine_wants() did not return a list")