Merge support for lazy loading packs.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 11 Jun 2010 22:16:56 +0000 (00:16 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 11 Jun 2010 22:16:56 +0000 (00:16 +0200)
1  2 
dulwich/pack.py

diff --cc dulwich/pack.py
index 57cbbe66fa5e2a15c50d9e84db0c2483485e63e2,6ac6b1abeb8b01f3ad7fd824f93430ec69ae2a5e..55b12628618a1e4ee33f2d8a930368510e612f69
@@@ -1281,10 -1281,19 +1281,21 @@@ class Pack(object)
  
      def __init__(self, basename):
          self._basename = basename
-         self._data_path = self._basename + ".pack"
-         self._idx_path = self._basename + ".idx"
          self._data = None
          self._idx = None
 -        self._data_load = lambda: PackData(self._basename + ".pack")
 -        self._idx_load = lambda: load_pack_index(self._basename + ".idx")
++        self._idx_path = self._basename + ".idx"
++        self._data_path = self._basename + ".pack"
++        self._data_load = lambda: PackData(self._data_path)
++        self._idx_load = lambda: load_pack_index(self._idx_path)
+     @classmethod
+     def from_lazy_objects(self, data_fn, idx_fn):
+         """Create a new pack object from callables to load pack data and 
+         index objects."""
+         ret = Pack("")
+         ret._data_load = data_fn
+         ret._idx_load = idx_fn
+         return ret
  
      @classmethod
      def from_objects(self, data, idx):