Skip to content
Snippets Groups Projects
Commit 7cdd2a7d authored by Martin Geisler's avatar Martin Geisler
Browse files

config: raise ConfigError on non-existing include files

Before, an %include directive for a non-existing file resulted in an
IOError and a traceback.
parent fb45c1e4
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,13 @@
base = os.path.dirname(src)
inc = os.path.normpath(os.path.join(base, inc))
if include:
include(inc, remap=remap, sections=sections)
try:
include(inc, remap=remap, sections=sections)
except IOError, inst:
msg = _("config error at %s:%d: "
"cannot include %s (%s)") \
% (src, line, inc, inst.strerror)
raise error.ConfigError(msg)
continue
if emptyre.match(l):
continue
......
......@@ -22,3 +22,6 @@
echo '[foo]' >> $HGRCPATH
echo ' x = y' >> $HGRCPATH
hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|"
echo '%include /no-such-file' > $HGRCPATH
hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|"
......@@ -11,3 +11,4 @@
paths.default=.../foo%bar
ui.slash=True
hg: config error at $HGRCPATH:8: ' x = y'
hg: config error at $HGRCPATH:1: cannot include /no-such-file (No such file or directory)
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