|
@@ -1394,7 +1394,7 @@ class Pack(object):
|
|
|
|
|
|
@classmethod
|
|
|
def from_lazy_objects(self, data_fn, idx_fn):
|
|
|
- """Create a new pack object from callables to load pack data and
|
|
|
+ """Create a new pack object from callables to load pack data and
|
|
|
index objects."""
|
|
|
ret = Pack("")
|
|
|
ret._data_load = data_fn
|
|
@@ -1498,6 +1498,21 @@ class Pack(object):
|
|
|
yield ShaFile.from_raw_chunks(
|
|
|
*self.data.resolve_object(offset, type, obj))
|
|
|
|
|
|
+ def keep(self, msg=None):
|
|
|
+ """Add a .keep file for the pack, preventing git from garbage collecting it.
|
|
|
+ :param msg: A message written inside the .keep file; can be used later to
|
|
|
+ determine whether or not a .keep file is obsolete.
|
|
|
+ :return: The path of the .keep file, as a string."""
|
|
|
+ keepfile_name = '%s.keep' % self._basename
|
|
|
+ keepfile = GitFile(keepfile_name, 'wb')
|
|
|
+ try:
|
|
|
+ if msg:
|
|
|
+ keepfile.write(msg)
|
|
|
+ keepfile.write('\n')
|
|
|
+ finally:
|
|
|
+ keepfile.close()
|
|
|
+ return keepfile_name
|
|
|
+
|
|
|
|
|
|
try:
|
|
|
from dulwich._pack import apply_delta, bisect_find_sha
|