Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 3073:24c1db20990c
Include section name and parameter name (if available) in config errors.
Added tests for this.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 08 Sep 2006 10:01:45 +0200 |
parents | 1efd5a6df5a3 |
children | 09e8aecd8016 |
comparison
equal
deleted
inserted
replaced
3072:bc3fe3b5b785 | 3073:24c1db20990c |
---|---|
120 return self.overlay[(section, name)] | 120 return self.overlay[(section, name)] |
121 if self.cdata.has_option(section, name): | 121 if self.cdata.has_option(section, name): |
122 try: | 122 try: |
123 return self.cdata.get(section, name) | 123 return self.cdata.get(section, name) |
124 except ConfigParser.InterpolationError, inst: | 124 except ConfigParser.InterpolationError, inst: |
125 raise util.Abort(_("Error in configuration:\n%s") % inst) | 125 raise util.Abort(_("Error in configuration section [%s] " |
126 "parameter '%s':\n%s") | |
127 % (section, name, inst)) | |
126 if self.parentui is None: | 128 if self.parentui is None: |
127 return default | 129 return default |
128 else: | 130 else: |
129 return self.parentui.config(section, name, default) | 131 return self.parentui.config(section, name, default) |
130 | 132 |
142 return self.overlay[(section, name)] | 144 return self.overlay[(section, name)] |
143 if self.cdata.has_option(section, name): | 145 if self.cdata.has_option(section, name): |
144 try: | 146 try: |
145 return self.cdata.getboolean(section, name) | 147 return self.cdata.getboolean(section, name) |
146 except ConfigParser.InterpolationError, inst: | 148 except ConfigParser.InterpolationError, inst: |
147 raise util.Abort(_("Error in configuration:\n%s") % inst) | 149 raise util.Abort(_("Error in configuration section [%s] " |
150 "parameter '%s':\n%s") | |
151 % (section, name, inst)) | |
148 if self.parentui is None: | 152 if self.parentui is None: |
149 return default | 153 return default |
150 else: | 154 else: |
151 return self.parentui.configbool(section, name, default) | 155 return self.parentui.configbool(section, name, default) |
152 | 156 |
160 items = dict(self.parentui.configitems(section)) | 164 items = dict(self.parentui.configitems(section)) |
161 if self.cdata.has_section(section): | 165 if self.cdata.has_section(section): |
162 try: | 166 try: |
163 items.update(dict(self.cdata.items(section))) | 167 items.update(dict(self.cdata.items(section))) |
164 except ConfigParser.InterpolationError, inst: | 168 except ConfigParser.InterpolationError, inst: |
165 raise util.Abort(_("Error in configuration:\n%s") % inst) | 169 raise util.Abort(_("Error in configuration section [%s]:\n%s") |
170 % (section, inst)) | |
166 x = items.items() | 171 x = items.items() |
167 x.sort() | 172 x.sort() |
168 return x | 173 return x |
169 | 174 |
170 def walkconfig(self, seen=None): | 175 def walkconfig(self, seen=None): |
172 seen = {} | 177 seen = {} |
173 for (section, name), value in self.overlay.iteritems(): | 178 for (section, name), value in self.overlay.iteritems(): |
174 yield section, name, value | 179 yield section, name, value |
175 seen[section, name] = 1 | 180 seen[section, name] = 1 |
176 for section in self.cdata.sections(): | 181 for section in self.cdata.sections(): |
177 for name, value in self.cdata.items(section): | 182 try: |
178 if (section, name) in seen: continue | 183 for name, value in self.cdata.items(section): |
179 yield section, name, value.replace('\n', '\\n') | 184 if (section, name) in seen: continue |
180 seen[section, name] = 1 | 185 yield section, name, value.replace('\n', '\\n') |
186 seen[section, name] = 1 | |
187 except ConfigParser.InterpolationError, inst: | |
188 raise util.Abort(_("Error in configuration section [%s]:\n%s") | |
189 % (section, inst)) | |
181 if self.parentui is not None: | 190 if self.parentui is not None: |
182 for parent in self.parentui.walkconfig(seen): | 191 for parent in self.parentui.walkconfig(seen): |
183 yield parent | 192 yield parent |
184 | 193 |
185 def extensions(self): | 194 def extensions(self): |