Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/ui.py @ 1876:2e0fd78587bd
Catch hgrc interpolation errors nicely.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 10 Mar 2006 11:34:02 +0100 |
parents | a84829140fb1 |
children | c0320567931f |
comparison
equal
deleted
inserted
replaced
1875:2f4a0734c100 | 1876:2e0fd78587bd |
---|---|
62 | 62 |
63 def config(self, section, name, default=None): | 63 def config(self, section, name, default=None): |
64 if self.overlay.has_key((section, name)): | 64 if self.overlay.has_key((section, name)): |
65 return self.overlay[(section, name)] | 65 return self.overlay[(section, name)] |
66 if self.cdata.has_option(section, name): | 66 if self.cdata.has_option(section, name): |
67 return self.cdata.get(section, name) | 67 try: |
68 return self.cdata.get(section, name) | |
69 except ConfigParser.InterpolationError, inst: | |
70 raise util.Abort(_("Error in configuration:\n%s") % inst) | |
68 if self.parentui is None: | 71 if self.parentui is None: |
69 return default | 72 return default |
70 else: | 73 else: |
71 return self.parentui.config(section, name, default) | 74 return self.parentui.config(section, name, default) |
72 | 75 |
73 def configbool(self, section, name, default=False): | 76 def configbool(self, section, name, default=False): |
74 if self.overlay.has_key((section, name)): | 77 if self.overlay.has_key((section, name)): |
75 return self.overlay[(section, name)] | 78 return self.overlay[(section, name)] |
76 if self.cdata.has_option(section, name): | 79 if self.cdata.has_option(section, name): |
77 return self.cdata.getboolean(section, name) | 80 try: |
81 return self.cdata.getboolean(section, name) | |
82 except ConfigParser.InterpolationError, inst: | |
83 raise util.Abort(_("Error in configuration:\n%s") % inst) | |
78 if self.parentui is None: | 84 if self.parentui is None: |
79 return default | 85 return default |
80 else: | 86 else: |
81 return self.parentui.configbool(section, name, default) | 87 return self.parentui.configbool(section, name, default) |
82 | 88 |
83 def configitems(self, section): | 89 def configitems(self, section): |
84 items = {} | 90 items = {} |
85 if self.parentui is not None: | 91 if self.parentui is not None: |
86 items = dict(self.parentui.configitems(section)) | 92 items = dict(self.parentui.configitems(section)) |
87 if self.cdata.has_section(section): | 93 if self.cdata.has_section(section): |
88 items.update(dict(self.cdata.items(section))) | 94 try: |
95 items.update(dict(self.cdata.items(section))) | |
96 except ConfigParser.InterpolationError, inst: | |
97 raise util.Abort(_("Error in configuration:\n%s") % inst) | |
89 x = items.items() | 98 x = items.items() |
90 x.sort() | 99 x.sort() |
91 return x | 100 return x |
92 | 101 |
93 def walkconfig(self, seen=None): | 102 def walkconfig(self, seen=None): |