# HG changeset patch # User Patrick Mezard # Date 1180901485 -7200 # Node ID 5371a213b0f46b3af14c9f1a809c708743e94f16 # Parent 96d8a56d4ef9057003a9dd0d3fea73af25e82303 ui: make readsections() abort when configuration cannot be read. diff -r 96d8a56d4ef9 -r 5371a213b0f4 mercurial/ui.py --- a/mercurial/ui.py Wed Jun 06 20:22:52 2007 +0200 +++ b/mercurial/ui.py Sun Jun 03 22:11:25 2007 +0200 @@ -170,7 +170,15 @@ 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 -r 96d8a56d4ef9 -r 5371a213b0f4 tests/test-acl.out --- a/tests/test-acl.out Wed Jun 06 20:22:52 2007 +0200 +++ b/tests/test-acl.out Sun Jun 03 22:11:25 2007 +0200 @@ -470,12 +470,11 @@ 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 -r 96d8a56d4ef9 -r 5371a213b0f4 tests/test-notify --- a/tests/test-notify Wed Jun 06 20:22:52 2007 +0200 +++ b/tests/test-notify Sun Jun 03 22:11:25 2007 +0200 @@ -48,6 +48,12 @@ 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 -r 96d8a56d4ef9 -r 5371a213b0f4 tests/test-notify.out --- a/tests/test-notify.out Wed Jun 06 20:22:52 2007 +0200 +++ b/tests/test-notify.out Sun Jun 03 22:11:25 2007 +0200 @@ -34,6 +34,9 @@ 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