Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 8222:d30a21594812
more whitespace cleanup and some other style nits
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Mon, 27 Apr 2009 12:37:19 +0200 |
parents | 6e6ebeb52899 |
children | 46293a0c7e9f |
comparison
equal
deleted
inserted
replaced
8221:f35b933044cc | 8222:d30a21594812 |
---|---|
7 | 7 |
8 from i18n import _ | 8 from i18n import _ |
9 import errno, getpass, os, re, socket, sys, tempfile | 9 import errno, getpass, os, re, socket, sys, tempfile |
10 import config, traceback, util, error | 10 import config, traceback, util, error |
11 | 11 |
12 _booleans = {'1':True, 'yes':True, 'true':True, 'on':True, | 12 _booleans = {'1': True, 'yes': True, 'true': True, 'on': True, |
13 '0':False, 'no':False, 'false':False, 'off':False} | 13 '0': False, 'no': False, 'false': False, 'off': False} |
14 | 14 |
15 class ui(object): | 15 class ui(object): |
16 def __init__(self, src=None): | 16 def __init__(self, src=None): |
17 self._buffers = [] | 17 self._buffers = [] |
18 self.quiet = self.verbose = self.debugflag = self._traceback = False | 18 self.quiet = self.verbose = self.debugflag = self._traceback = False |
32 self.fixconfig() | 32 self.fixconfig() |
33 else: | 33 else: |
34 # we always trust global config files | 34 # we always trust global config files |
35 for f in util.rcpath(): | 35 for f in util.rcpath(): |
36 self.readconfig(f, trust=True) | 36 self.readconfig(f, trust=True) |
37 | |
37 def copy(self): | 38 def copy(self): |
38 return self.__class__(self) | 39 return self.__class__(self) |
39 | 40 |
40 def _is_trusted(self, fp, f): | 41 def _is_trusted(self, fp, f): |
41 st = util.fstat(fp) | 42 st = util.fstat(fp) |
55 self.warn(_('Not trusting file %s from untrusted ' | 56 self.warn(_('Not trusting file %s from untrusted ' |
56 'user %s, group %s\n') % (f, user, group)) | 57 'user %s, group %s\n') % (f, user, group)) |
57 return False | 58 return False |
58 | 59 |
59 def readconfig(self, filename, root=None, trust=False, | 60 def readconfig(self, filename, root=None, trust=False, |
60 sections = None): | 61 sections=None): |
61 try: | 62 try: |
62 fp = open(filename) | 63 fp = open(filename) |
63 except IOError: | 64 except IOError: |
64 if not sections: # ignore unless we were looking for something | 65 if not sections: # ignore unless we were looking for something |
65 return | 66 return |
123 value = self._data(untrusted).get(section, name, default) | 124 value = self._data(untrusted).get(section, name, default) |
124 if self.debugflag and not untrusted and self._reportuntrusted: | 125 if self.debugflag and not untrusted and self._reportuntrusted: |
125 uvalue = self._ucfg.get(section, name) | 126 uvalue = self._ucfg.get(section, name) |
126 if uvalue is not None and uvalue != value: | 127 if uvalue is not None and uvalue != value: |
127 self.debug(_("ignoring untrusted configuration option " | 128 self.debug(_("ignoring untrusted configuration option " |
128 "%s.%s = %s\n") % (section, name, uvalue)) | 129 "%s.%s = %s\n") % (section, name, uvalue)) |
129 return value | 130 return value |
130 | 131 |
131 def configbool(self, section, name, default=False, untrusted=False): | 132 def configbool(self, section, name, default=False, untrusted=False): |
132 v = self.config(section, name, None, untrusted) | 133 v = self.config(section, name, None, untrusted) |
133 if v == None: | 134 if v == None: |
151 return section in self._data(untrusted) | 152 return section in self._data(untrusted) |
152 | 153 |
153 def configitems(self, section, untrusted=False): | 154 def configitems(self, section, untrusted=False): |
154 items = self._data(untrusted).items(section) | 155 items = self._data(untrusted).items(section) |
155 if self.debugflag and not untrusted and self._reportuntrusted: | 156 if self.debugflag and not untrusted and self._reportuntrusted: |
156 for k,v in self._ucfg.items(section): | 157 for k, v in self._ucfg.items(section): |
157 if self._tcfg.get(section, k) != v: | 158 if self._tcfg.get(section, k) != v: |
158 self.debug(_("ignoring untrusted configuration option " | 159 self.debug(_("ignoring untrusted configuration option " |
159 "%s.%s = %s\n") % (section, k, v)) | 160 "%s.%s = %s\n") % (section, k, v)) |
160 return items | 161 return items |
161 | 162 |