Mercurial > public > mercurial-scm > hg-stable
diff mercurial/extensions.py @ 14415:c238b12a1ed4
extensions: raise when trying to find an extension that failed to load
extensions that depend on other extensions (such as record) use this pattern
to check if the dependant extension is available:
try:
mq = extensions.find('mq')
except KeyError:
return
but since if an error occurs while loading an extension it leaves its entry
in the _extensions map as None, we want to raise in that situation too.
(rather than adding another check if the return value is None)
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Mon, 23 May 2011 23:09:00 +0300 |
parents | 1f46be4689ed |
children | cd31a1cc1521 |
line wrap: on
line diff
--- a/mercurial/extensions.py Mon May 23 15:56:31 2011 +0200 +++ b/mercurial/extensions.py Mon May 23 23:09:00 2011 +0300 @@ -21,13 +21,17 @@ def find(name): '''return module with given extension name''' + mod = None try: - return _extensions[name] + mod = _extensions[name] except KeyError: for k, v in _extensions.iteritems(): if k.endswith('.' + name) or k.endswith('/' + name): - return v + mod = v + break + if not mod: raise KeyError(name) + return mod def loadpath(path, module_name): module_name = module_name.replace('.', '_')