# HG changeset patch # User Alexis S. L. Carvalho # Date 2006-10-16 23:38:04 # Node ID b19360aa21e9c053a377a8c50f3e743051c40f7e # Parent 7012c889e8f2e5c91e5ee95adbb3271581736625 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 > ignored diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -233,10 +233,12 @@ class bundlerepository(localrepo.localre 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: diff --git a/tests/test-bundle b/tests/test-bundle --- a/tests/test-bundle +++ b/tests/test-bundle @@ -57,4 +57,5 @@ cd partial 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 .. diff --git a/tests/test-bundle.out b/tests/test-bundle.out --- a/tests/test-bundle.out +++ b/tests/test-bundle.out @@ -208,3 +208,4 @@ user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: 0.3m +abort: No such file or directory: ../does-not-exist.hg