comparison mercurial/ui.py @ 8199:e9f90e5989d9

ui: _get_cdata -> _data
author Matt Mackall <mpm@selenic.com>
date Sun, 26 Apr 2009 16:50:44 -0500
parents cf9accffd0b3
children 865d2c646f29
comparison
equal deleted inserted replaced
8198:cf9accffd0b3 8199:e9f90e5989d9
125 def setconfig(self, section, name, value): 125 def setconfig(self, section, name, value):
126 for cdata in (self.overlay, self.cdata, self.ucdata): 126 for cdata in (self.overlay, self.cdata, self.ucdata):
127 cdata.set(section, name, value) 127 cdata.set(section, name, value)
128 self.fixconfig() 128 self.fixconfig()
129 129
130 def _get_cdata(self, untrusted): 130 def _data(self, untrusted):
131 if untrusted: 131 return untrusted and self.ucdata or self.cdata
132 return self.ucdata
133 return self.cdata
134 132
135 def configsource(self, section, name, untrusted=False): 133 def configsource(self, section, name, untrusted=False):
136 return self._get_cdata(untrusted).source(section, name) or 'none' 134 return self._data(untrusted).source(section, name) or 'none'
137 135
138 def config(self, section, name, default=None, untrusted=False): 136 def config(self, section, name, default=None, untrusted=False):
139 value = self._get_cdata(untrusted).get(section, name, default) 137 value = self._data(untrusted).get(section, name, default)
140 if self.debugflag and not untrusted: 138 if self.debugflag and not untrusted:
141 uvalue = self.ucdata.get(section, name) 139 uvalue = self.ucdata.get(section, name)
142 if uvalue is not None and uvalue != value: 140 if uvalue is not None and uvalue != value:
143 self.warn(_("Ignoring untrusted configuration option " 141 self.warn(_("Ignoring untrusted configuration option "
144 "%s.%s = %s\n") % (section, name, uvalue)) 142 "%s.%s = %s\n") % (section, name, uvalue))
162 result = result.replace(",", " ").split() 160 result = result.replace(",", " ").split()
163 return result 161 return result
164 162
165 def has_section(self, section, untrusted=False): 163 def has_section(self, section, untrusted=False):
166 '''tell whether section exists in config.''' 164 '''tell whether section exists in config.'''
167 return section in self._get_cdata(untrusted) 165 return section in self._data(untrusted)
168 166
169 def configitems(self, section, untrusted=False): 167 def configitems(self, section, untrusted=False):
170 items = self._get_cdata(untrusted).items(section) 168 items = self._data(untrusted).items(section)
171 if self.debugflag and not untrusted: 169 if self.debugflag and not untrusted:
172 for k,v in self.ucdata.items(section): 170 for k,v in self.ucdata.items(section):
173 if self.cdata.get(section, k) != v: 171 if self.cdata.get(section, k) != v:
174 self.warn(_("Ignoring untrusted configuration option " 172 self.warn(_("Ignoring untrusted configuration option "
175 "%s.%s = %s\n") % (section, k, v)) 173 "%s.%s = %s\n") % (section, k, v))
176 return items 174 return items
177 175
178 def walkconfig(self, untrusted=False): 176 def walkconfig(self, untrusted=False):
179 cdata = self._get_cdata(untrusted) 177 cdata = self._data(untrusted)
180 for section in cdata.sections(): 178 for section in cdata.sections():
181 for name, value in self.configitems(section, untrusted): 179 for name, value in self.configitems(section, untrusted):
182 yield section, name, str(value).replace('\n', '\\n') 180 yield section, name, str(value).replace('\n', '\\n')
183 181
184 def username(self): 182 def username(self):