Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 15035:cc669e4fec95
ui: allow alternatives for config options
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 11 Aug 2011 14:34:03 -0500 |
parents | b55c1c6a793e |
children | 7c03e3b1b858 |
comparison
equal
deleted
inserted
replaced
15034:72f312f41a4a | 15035:cc669e4fec95 |
---|---|
153 | 153 |
154 def configsource(self, section, name, untrusted=False): | 154 def configsource(self, section, name, untrusted=False): |
155 return self._data(untrusted).source(section, name) or 'none' | 155 return self._data(untrusted).source(section, name) or 'none' |
156 | 156 |
157 def config(self, section, name, default=None, untrusted=False): | 157 def config(self, section, name, default=None, untrusted=False): |
158 value = self._data(untrusted).get(section, name, default) | 158 if isinstance(name, list): |
159 alternates = name | |
160 else: | |
161 alternates = [name] | |
162 | |
163 for n in alternates: | |
164 value = self._data(untrusted).get(section, name, None) | |
165 if value is not None: | |
166 name = n | |
167 break | |
168 else: | |
169 value = default | |
170 | |
159 if self.debugflag and not untrusted and self._reportuntrusted: | 171 if self.debugflag and not untrusted and self._reportuntrusted: |
160 uvalue = self._ucfg.get(section, name) | 172 uvalue = self._ucfg.get(section, name) |
161 if uvalue is not None and uvalue != value: | 173 if uvalue is not None and uvalue != value: |
162 self.debug("ignoring untrusted configuration option " | 174 self.debug("ignoring untrusted configuration option " |
163 "%s.%s = %s\n" % (section, name, uvalue)) | 175 "%s.%s = %s\n" % (section, name, uvalue)) |