Skip to content
Snippets Groups Projects
Commit c238b12a authored by Idan Kamara's avatar Idan Kamara
Browse files

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)
parent 90937dd4
No related branches found
No related tags found
No related merge requests found
......@@ -21,4 +21,5 @@
def find(name):
'''return module with given extension name'''
mod = None
try:
......@@ -24,5 +25,5 @@
try:
return _extensions[name]
mod = _extensions[name]
except KeyError:
for k, v in _extensions.iteritems():
if k.endswith('.' + name) or k.endswith('/' + name):
......@@ -26,5 +27,7 @@
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)
......@@ -30,4 +33,5 @@
raise KeyError(name)
return mod
def loadpath(path, module_name):
module_name = module_name.replace('.', '_')
......
......@@ -99,5 +99,18 @@
abort: 'mq' extension not loaded
[255]
help (bad mq)
$ echo "mq=nonexistant" >> $HGRCPATH
$ hg help qrecord
*** failed to import extension mq from nonexistant: [Errno 2] No such file or directory
hg qrecord [OPTION]... PATCH [FILE]...
interactively record a new patch
See "hg help qnew" & "hg help record" for more information and usage.
use "hg -v help qrecord" to show global options
help (mq present)
......@@ -102,6 +115,8 @@
help (mq present)
$ echo "mq=" >> $HGRCPATH
$ sed 's/mq=nonexistant/mq=/' $HGRCPATH > hgrc.tmp
$ mv hgrc.tmp $HGRCPATH
$ hg help qrecord
hg qrecord [OPTION]... PATCH [FILE]...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment