bundlerepo: restore close() method

This commit is contained in:
Matt Mackall 2010-09-20 16:14:05 -05:00
parent 32de98afbd
commit cdb9f7c881
3 changed files with 7 additions and 1 deletions

View File

@ -600,6 +600,7 @@ def transplant(ui, repo, *revs, **opts):
tp.apply(repo, source, revmap, merges, opts)
finally:
if bundle:
source.close()
os.unlink(bundle)
cmdtable = {

View File

@ -177,7 +177,6 @@ class bundlerepository(localrepo.localrepository):
f = open(bundlename, "rb")
self.bundle = changegroup.readbundle(f, bundlename)
if self.bundle.compressed():
# we need a seekable, decompressed bundle
fdtemp, temp = tempfile.mkstemp(prefix="hg-bundle-",
suffix=".hg10un", dir=self.path)
self.tempfile = temp
@ -247,6 +246,10 @@ class bundlerepository(localrepo.localrepository):
else:
return filelog.filelog(self.sopener, f)
def close(self):
"""Close assigned bundle file immediately."""
self.bundle.close()
def __del__(self):
del self.bundle
if tempfile is not None:

View File

@ -143,6 +143,8 @@ class unbundle10(object):
return self._stream.seek(pos)
def tell(self):
return self._stream.tell()
def close(self):
return self._stream.close()
def chunklength(self):
d = self.read(4)