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 0x
a7ab9fac>> ignored
--- a/mercurial/bundlerepo.py Mon Oct 16 18:01:25 2006 -0300
+++ b/mercurial/bundlerepo.py Mon Oct 16 20:38:04 2006 -0300
@@ -233,10 +233,12 @@
self.bundlefile.close()
def __del__(self):
- if not self.bundlefile.closed:
- self.bundlefile.close()
- if self.tempfile is not None:
- os.unlink(self.tempfile)
+ bundlefile = getattr(self, 'bundlefile', None)
+ if bundlefile and not bundlefile.closed:
+ bundlefile.close()
+ tempfile = getattr(self, 'tempfile', None)
+ if tempfile is not None:
+ os.unlink(tempfile)
def instance(ui, path, create):
if create:
--- a/tests/test-bundle Mon Oct 16 18:01:25 2006 -0300
+++ b/tests/test-bundle Mon Oct 16 20:38:04 2006 -0300
@@ -57,4 +57,5 @@
hg -R bundle://../full.hg log
hg incoming bundle://../full.hg
hg -R bundle://../full.hg outgoing ../partial2
+hg -R bundle://../does-not-exist.hg outgoing ../partial2
cd ..
--- a/tests/test-bundle.out Mon Oct 16 18:01:25 2006 -0300
+++ b/tests/test-bundle.out Mon Oct 16 20:38:04 2006 -0300
@@ -208,3 +208,4 @@
date: Mon Jan 12 13:46:40 1970 +0000
summary: 0.3m
+abort: No such file or directory: ../does-not-exist.hg