Mercurial > public > mercurial-scm > hg-stable
diff mercurial/ui.py @ 1473:7d66ce9895fa
make readconfig take a filename instead of a file pointer as argument
catch parse error while reading a config file
add a testcase for parse error
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Thu, 27 Oct 2005 13:40:56 -0700 |
parents | bf109779f48b |
children | a4ba63e04134 |
line wrap: on
line diff
--- a/mercurial/ui.py Thu Oct 27 13:31:12 2005 -0700 +++ b/mercurial/ui.py Thu Oct 27 13:40:56 2005 -0700 @@ -15,7 +15,7 @@ interactive=True): self.overlay = {} self.cdata = ConfigParser.SafeConfigParser() - self.cdata.read(util.rcpath) + self.readconfig(util.rcpath) self.quiet = self.configbool("ui", "quiet") self.verbose = self.configbool("ui", "verbose") @@ -31,8 +31,11 @@ self.debugflag = (self.debugflag or debug) self.interactive = (self.interactive and interactive) - def readconfig(self, fp): - self.cdata.readfp(fp) + def readconfig(self, fn): + try: + self.cdata.read(fn) + except ConfigParser.ParsingError, inst: + raise util.Abort(_("Failed to parse %s\n%s") % (fn, inst)) def setconfig(self, section, name, val): self.overlay[(section, name)] = val