Fix traceback on bad system hgrc files
authorSoh Tk-r28629 <tksoh@freescale.com>
Mon, 31 Oct 2005 09:57:54 -0800
changeset 1483 a4ba63e04134
parent 1482 4d38b85e60aa
child 1484 840808c57969
Fix traceback on bad system hgrc files
mercurial/commands.py
mercurial/ui.py
--- a/mercurial/commands.py	Mon Oct 31 10:56:42 2005 -0700
+++ b/mercurial/commands.py	Mon Oct 31 09:57:54 2005 -0800
@@ -2449,7 +2449,12 @@
     except AttributeError:
         pass
 
-    u = ui.ui()
+    try:
+        u = ui.ui()
+    except util.Abort, inst:
+        sys.stderr.write(_("abort: %s\n") % inst)
+        sys.exit(1)
+
     external = []
     for x in u.extensions():
         def on_exception(Exception, inst):
--- a/mercurial/ui.py	Mon Oct 31 10:56:42 2005 -0700
+++ b/mercurial/ui.py	Mon Oct 31 09:57:54 2005 -0800
@@ -32,10 +32,13 @@
         self.interactive = (self.interactive and interactive)
 
     def readconfig(self, fn):
-        try:
-            self.cdata.read(fn)
-        except ConfigParser.ParsingError, inst:
-            raise util.Abort(_("Failed to parse %s\n%s") % (fn, inst))
+        if isinstance(fn, basestring):
+            fn = [fn]
+        for f in fn:
+            try:
+                self.cdata.read(f)
+            except ConfigParser.ParsingError, inst:
+                raise util.Abort(_("Failed to parse %s\n%s") % (f, inst))
 
     def setconfig(self, section, name, val):
         self.overlay[(section, name)] = val