Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 13238:1b591f9b7fd2
ui: add configpath helper
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 06 Jan 2011 17:04:33 -0600 |
parents | 3da456d0c885 |
children | 95b0d4c1c9e1 |
comparison
equal
deleted
inserted
replaced
13237:c046978cc0a9 | 13238:1b591f9b7fd2 |
---|---|
150 uvalue = self._ucfg.get(section, name) | 150 uvalue = self._ucfg.get(section, name) |
151 if uvalue is not None and uvalue != value: | 151 if uvalue is not None and uvalue != value: |
152 self.debug(_("ignoring untrusted configuration option " | 152 self.debug(_("ignoring untrusted configuration option " |
153 "%s.%s = %s\n") % (section, name, uvalue)) | 153 "%s.%s = %s\n") % (section, name, uvalue)) |
154 return value | 154 return value |
155 | |
156 def configpath(self, section, name, default=None, untrusted=False): | |
157 'get a path config item, expanded relative to config file' | |
158 v = self.config(section, name, default, untrusted) | |
159 if not os.path.isabs(v) or "://" not in v: | |
160 src = self.configsource(section, name, untrusted) | |
161 if ':' in src: | |
162 base = os.path.dirname(src.rsplit(':')) | |
163 v = os.path.join(base, os.path.expanduser(v)) | |
164 return v | |
155 | 165 |
156 def configbool(self, section, name, default=False, untrusted=False): | 166 def configbool(self, section, name, default=False, untrusted=False): |
157 v = self.config(section, name, None, untrusted) | 167 v = self.config(section, name, None, untrusted) |
158 if v is None: | 168 if v is None: |
159 return default | 169 return default |