diff mercurial/ui.py @ 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 1b5b98837bb5
children 669e76b7df24
line wrap: on
line diff
--- 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))