Mercurial > hg
comparison mercurial/bundlerepo.py @ 3429:b19360aa21e9
bundlerepo: avoid exception in __del__ when the bundle doesn't exist
$ hg -R bundle://foo.hg
abort: No such file or directory: foo.hg
Exception exceptions.AttributeError: "'bundlerepository' object has no attribute 'bundlefile'" in <bound method bundlerepository.__del__ of <mercurial.bundlerepo.bundlerepository object at 0xa7ab9fac>> ignored
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 16 Oct 2006 20:38:04 -0300 |
parents | 386f04d6ecb3 |
children | 0ed2732aa393 |
comparison
equal
deleted
inserted
replaced
3428:7012c889e8f2 | 3429:b19360aa21e9 |
---|---|
231 def close(self): | 231 def close(self): |
232 """Close assigned bundle file immediately.""" | 232 """Close assigned bundle file immediately.""" |
233 self.bundlefile.close() | 233 self.bundlefile.close() |
234 | 234 |
235 def __del__(self): | 235 def __del__(self): |
236 if not self.bundlefile.closed: | 236 bundlefile = getattr(self, 'bundlefile', None) |
237 self.bundlefile.close() | 237 if bundlefile and not bundlefile.closed: |
238 if self.tempfile is not None: | 238 bundlefile.close() |
239 os.unlink(self.tempfile) | 239 tempfile = getattr(self, 'tempfile', None) |
240 if tempfile is not None: | |
241 os.unlink(tempfile) | |
240 | 242 |
241 def instance(ui, path, create): | 243 def instance(ui, path, create): |
242 if create: | 244 if create: |
243 raise util.Abort(_('cannot create new bundle repository')) | 245 raise util.Abort(_('cannot create new bundle repository')) |
244 path = util.drop_scheme('file', path) | 246 path = util.drop_scheme('file', path) |