Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 3343:ab406cfa1b99
ui.py: don't query parentui.cdata when looking up config items.
We copied the contents of parentui.cdata on initialization.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Tue, 10 Oct 2006 18:43:20 -0300 |
parents | 4eeb79b4da30 |
children | d9b3d3d34749 |
comparison
equal
deleted
inserted
replaced
3342:4eeb79b4da30 | 3343:ab406cfa1b99 |
---|---|
96 return func(section, name) | 96 return func(section, name) |
97 except ConfigParser.InterpolationError, inst: | 97 except ConfigParser.InterpolationError, inst: |
98 raise util.Abort(_("Error in configuration section [%s] " | 98 raise util.Abort(_("Error in configuration section [%s] " |
99 "parameter '%s':\n%s") | 99 "parameter '%s':\n%s") |
100 % (section, name, inst)) | 100 % (section, name, inst)) |
101 if self.parentui is None: | 101 return default |
102 return default | |
103 else: | |
104 return self.parentui._config(section, name, default, funcname) | |
105 | 102 |
106 def config(self, section, name, default=None): | 103 def config(self, section, name, default=None): |
107 return self._config(section, name, default, 'get') | 104 return self._config(section, name, default, 'get') |
108 | 105 |
109 def configbool(self, section, name, default=False): | 106 def configbool(self, section, name, default=False): |
122 '''tell whether section exists in config.''' | 119 '''tell whether section exists in config.''' |
123 return self.cdata.has_section(section) | 120 return self.cdata.has_section(section) |
124 | 121 |
125 def configitems(self, section): | 122 def configitems(self, section): |
126 items = {} | 123 items = {} |
127 if self.parentui is not None: | |
128 items = dict(self.parentui.configitems(section)) | |
129 if self.cdata.has_section(section): | 124 if self.cdata.has_section(section): |
130 try: | 125 try: |
131 items.update(dict(self.cdata.items(section))) | 126 items.update(dict(self.cdata.items(section))) |
132 except ConfigParser.InterpolationError, inst: | 127 except ConfigParser.InterpolationError, inst: |
133 raise util.Abort(_("Error in configuration section [%s]:\n%s") | 128 raise util.Abort(_("Error in configuration section [%s]:\n%s") |
134 % (section, inst)) | 129 % (section, inst)) |
135 x = items.items() | 130 x = items.items() |
136 x.sort() | 131 x.sort() |
137 return x | 132 return x |
138 | 133 |
139 def walkconfig(self, seen=None): | 134 def walkconfig(self): |
140 if seen is None: | 135 seen = {} |
141 seen = {} | |
142 for (section, name), value in self.overlay.iteritems(): | 136 for (section, name), value in self.overlay.iteritems(): |
143 yield section, name, value | 137 yield section, name, value |
144 seen[section, name] = 1 | 138 seen[section, name] = 1 |
145 sections = self.cdata.sections() | 139 sections = self.cdata.sections() |
146 sections.sort() | 140 sections.sort() |
147 for section in sections: | 141 for section in sections: |
148 for name, value in self.configitems(section): | 142 for name, value in self.configitems(section): |
149 if (section, name) in seen: continue | 143 if (section, name) in seen: continue |
150 yield section, name, value.replace('\n', '\\n') | 144 yield section, name, value.replace('\n', '\\n') |
151 seen[section, name] = 1 | 145 seen[section, name] = 1 |
152 if self.parentui is not None: | |
153 for parent in self.parentui.walkconfig(seen): | |
154 yield parent | |
155 | 146 |
156 def extensions(self): | 147 def extensions(self): |
157 result = self.configitems("extensions") | 148 result = self.configitems("extensions") |
158 for i, (key, value) in enumerate(result): | 149 for i, (key, value) in enumerate(result): |
159 if value: | 150 if value: |