@@ -248,6 +248,12 @@ class BaseObjectStore(object):
"""Close any files opened by this object store."""
# Default implementation is a NO-OP
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self.close()
class PackBasedObjectStore(BaseObjectStore):
@@ -916,6 +916,14 @@ class Repo(BaseRepo):
create = init_bare
+ def close(self):
+ self.object_store.close()
class MemoryRepo(BaseRepo):
"""Repo that stores refs, objects, and named files in memory.
@@ -55,6 +55,9 @@ class _StubRepo(object):
os.mkdir(self.path)
+ pass
def _get_shallow(repo):
shallow_file = repo.get_named_file('shallow')