Browse Source

Pass external object resolve function rather than full object store to ThinPackData constructor.

Jelmer Vernooij 15 năm trước cách đây
mục cha
commit
bc650881e2
2 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 1 1
      dulwich/object_store.py
  2. 3 3
      dulwich/pack.py

+ 1 - 1
dulwich/object_store.py

@@ -392,7 +392,7 @@ class DiskObjectStore(PackBasedObjectStore):
 
         :param path: Path to the pack file.
         """
-        data = ThinPackData(self, path)
+        data = ThinPackData(self.get_raw, path)
 
         # Write index for the thin pack (do we really need this?)
         temppath = os.path.join(self.pack_dir, 

+ 3 - 3
dulwich/pack.py

@@ -873,9 +873,9 @@ class PackData(object):
 class ThinPackData(PackData):
     """PackData for thin packs, which require an ObjectStore for resolving."""
 
-    def __init__(self, store, *args, **kwargs):
+    def __init__(self, resolve_ext_ref, *args, **kwargs):
         super(ThinPackData, self).__init__(*args, **kwargs)
-        self.store = store
+        self.resolve_ext_ref = resolve_ext_ref
 
     def get_ref(self, sha):
         """Resolve a reference looking in both this pack and the store."""
@@ -887,7 +887,7 @@ class ThinPackData(PackData):
             # rewritten.
             return super(ThinPackData, self).get_ref(sha)
         except KeyError:
-            type, obj = self.store.get_raw(sha)
+            type, obj = self.resolve_ext_ref(sha)
             return None, type, obj
 
     def iterentries(self, progress=None):