Procházet zdrojové kódy

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

Jelmer Vernooij před 15 roky
rodič
revize
bc650881e2
2 změnil soubory, kde provedl 4 přidání a 4 odebrání
  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.
         :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?)
         # Write index for the thin pack (do we really need this?)
         temppath = os.path.join(self.pack_dir, 
         temppath = os.path.join(self.pack_dir, 

+ 3 - 3
dulwich/pack.py

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