Mercurial > hg
changeset 4517:5371a213b0f4
ui: make readsections() abort when configuration cannot be read.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 03 Jun 2007 22:11:25 +0200 |
parents | 96d8a56d4ef9 |
children | 3e4aa4c9efe4 |
files | mercurial/ui.py tests/test-acl.out tests/test-notify tests/test-notify.out |
diffstat | 4 files changed, 23 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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))
--- 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
--- 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/' \
--- 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