# HG changeset patch # User Patrick Mezard # Date 2007-06-03 20:11:25 # Node ID 5371a213b0f46b3af14c9f1a809c708743e94f16 # Parent 96d8a56d4ef9057003a9dd0d3fea73af25e82303 ui: make readsections() abort when configuration cannot be read. diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -170,7 +170,15 @@ class ui(object): cdata = util.configparser() try: - cdata.read(filename) + try: + fp = open(filename) + except IOError, inst: + raise util.Abort(_("unable to open %s: %s") % (filename, + getattr(inst, "strerror", inst))) + try: + cdata.readfp(fp, filename) + finally: + fp.close() except ConfigParser.ParsingError, inst: raise util.Abort(_("failed to parse %s\n%s") % (filename, inst)) diff --git a/tests/test-acl.out b/tests/test-acl.out --- a/tests/test-acl.out +++ b/tests/test-acl.out @@ -470,12 +470,11 @@ adding foo/file.txt revisions adding quux/file.py revisions added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook -acl: acl.allow enabled, 1 entries for user barney -acl: acl.deny enabled, 0 entries for user barney -acl: allowing changeset ef1ea85a6374 -acl: allowing changeset f9cafe1212c8 -acl: allowing changeset 911600dab2ae -rolling back last transaction +error: pretxnchangegroup.acl hook failed: unable to open ../acl.config: No such file or directory +abort: unable to open ../acl.config: No such file or directory +transaction abort! +rollback completed +no rollback information available 0:6675d58eff77 betty is allowed inside foo/ by a acl.config file diff --git a/tests/test-notify b/tests/test-notify --- a/tests/test-notify +++ b/tests/test-notify @@ -48,6 +48,12 @@ template = Subject: {desc|firstline|stri baseurl = http://test/ EOF +echo % fail for config file is missing +hg --cwd b rollback +hg --cwd b pull ../a 2>&1 | grep 'unable to open.*\.notify\.conf' > /dev/null && echo pull failed + +touch "$HGTMP/.notify.conf" + echo % pull hg --cwd b rollback hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \ diff --git a/tests/test-notify.out b/tests/test-notify.out --- a/tests/test-notify.out +++ b/tests/test-notify.out @@ -34,6 +34,9 @@ diff -r cb9a9f314b8b -r 0647d048b600 a a +a (run 'hg update' to get a working copy) +% fail for config file is missing +rolling back last transaction +pull failed % pull rolling back last transaction pulling from ../a