Mercurial > hg > hg-git
changeset 957:06385a2b30f3
init: handle AttributeError in addition to ImportError
If a module doesn't exist, it yields an ImportError,
if an attribtue doesn't exist on a module, it yields an AttributeError
author | timeless@gmail.com |
---|---|
date | Tue, 29 Dec 2015 18:06:14 +0000 (2015-12-29) |
parents | e7316a108780 |
children | 07473e474bc4 |
files | hggit/__init__.py hggit/git_handler.py hggit/gitdirstate.py hggit/overlay.py |
diffstat | 4 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -50,7 +50,7 @@ try: from mercurial import exchange exchange.push # existed in first iteration of this file -except ImportError: +except (AttributeError, ImportError): # We only *use* the exchange module in hg 3.2+, so this is safe pass @@ -58,7 +58,7 @@ from mercurial import ignore ignore.readpats ignoremod = True -except ImportError: +except (AttributeError, ImportError): # The ignore module disappeared in Mercurial 3.5 ignoremod = False
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -1525,7 +1525,7 @@ from mercurial import encoding old = encoding.encoding encoding.encoding = new_encoding - except ImportError: + except (AttributeError, ImportError): old = hgutil._encoding hgutil._encoding = new_encoding return old
--- a/hggit/gitdirstate.py +++ b/hggit/gitdirstate.py @@ -8,7 +8,7 @@ from mercurial import ignore ignore.readpats ignoremod = True -except ImportError: +except (AttributeError, ImportError): # ignore module was removed in Mercurial 3.5 ignoremod = False from mercurial import match as matchmod @@ -18,7 +18,7 @@ try: from mercurial import pathutil pathutil.pathauditor -except ImportError: +except (AttributeError, ImportError): pathutil = scmutil from mercurial import util from mercurial.i18n import _
--- a/hggit/overlay.py +++ b/hggit/overlay.py @@ -240,7 +240,7 @@ try: from mercurial import phases return phases.draft - except ImportError: + except (AttributeError, ImportError): return 1 def totuple(self): @@ -346,7 +346,7 @@ # Mercurial >= 3.3 from mercurial import namespaces self.names = namespaces.namespaces() - except ImportError: + except (AttributeError, ImportError): pass def __getitem__(self, n):