comparison mercurial/ui.py @ 8204:797586be575d

ui: report_untrusted fixes - report_untrusted -> _reportuntrusted - only report config shadows if enabled - config shadows are debug messages
author Matt Mackall <mpm@selenic.com>
date Sun, 26 Apr 2009 16:50:44 -0500
parents 3377fa11af67
children 00736cd2702a
comparison
equal deleted inserted replaced
8203:3377fa11af67 8204:797586be575d
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
19 self.interactive = self.report_untrusted = True 19 self.interactive = self._reportuntrusted = True
20 self._ocfg = config.config() # overlay 20 self._ocfg = config.config() # overlay
21 self._tcfg = config.config() # trusted 21 self._tcfg = config.config() # trusted
22 self._ucfg = config.config() # untrusted 22 self._ucfg = config.config() # untrusted
23 self._trustusers = {} 23 self._trustusers = {}
24 self._trustgroups = {} 24 self._trustgroups = {}
61 user = util.username(st.st_uid) 61 user = util.username(st.st_uid)
62 group = util.groupname(st.st_gid) 62 group = util.groupname(st.st_gid)
63 if user in tusers or group in tgroups or user == util.username(): 63 if user in tusers or group in tgroups or user == util.username():
64 return True 64 return True
65 65
66 if self.report_untrusted: 66 if self._reportuntrusted:
67 self.warn(_('Not trusting file %s from untrusted ' 67 self.warn(_('Not trusting file %s from untrusted '
68 'user %s, group %s\n') % (f, user, group)) 68 'user %s, group %s\n') % (f, user, group))
69 return False 69 return False
70 70
71 def readconfig(self, filename, root=None, trust=False, 71 def readconfig(self, filename, root=None, trust=False,
109 self.debugflag = self.configbool('ui', 'debug') 109 self.debugflag = self.configbool('ui', 'debug')
110 self.verbose = self.debugflag or self.configbool('ui', 'verbose') 110 self.verbose = self.debugflag or self.configbool('ui', 'verbose')
111 self.quiet = not self.debugflag and self.configbool('ui', 'quiet') 111 self.quiet = not self.debugflag and self.configbool('ui', 'quiet')
112 if self.verbose and self.quiet: 112 if self.verbose and self.quiet:
113 self.quiet = self.verbose = False 113 self.quiet = self.verbose = False
114 self.report_untrusted = self.configbool("ui", "report_untrusted", True) 114 self._reportuntrusted = self.configbool("ui", "report_untrusted", True)
115 self.interactive = self.configbool("ui", "interactive", self.isatty()) 115 self.interactive = self.configbool("ui", "interactive", self.isatty())
116 self.traceback = self.configbool('ui', 'traceback', False) 116 self.traceback = self.configbool('ui', 'traceback', False)
117 117
118 # update trust information 118 # update trust information
119 for user in self.configlist('trusted', 'users'): 119 for user in self.configlist('trusted', 'users'):
132 def configsource(self, section, name, untrusted=False): 132 def configsource(self, section, name, untrusted=False):
133 return self._data(untrusted).source(section, name) or 'none' 133 return self._data(untrusted).source(section, name) or 'none'
134 134
135 def config(self, section, name, default=None, untrusted=False): 135 def config(self, section, name, default=None, untrusted=False):
136 value = self._data(untrusted).get(section, name, default) 136 value = self._data(untrusted).get(section, name, default)
137 if self.debugflag and not untrusted: 137 if self.debugflag and not untrusted and self._reportuntrusted:
138 uvalue = self._ucfg.get(section, name) 138 uvalue = self._ucfg.get(section, name)
139 if uvalue is not None and uvalue != value: 139 if uvalue is not None and uvalue != value:
140 self.warn(_("Ignoring untrusted configuration option " 140 self.debug(_("ignoring untrusted configuration option "
141 "%s.%s = %s\n") % (section, name, uvalue)) 141 "%s.%s = %s\n") % (section, name, uvalue))
142 return value 142 return value
143 143
144 def configbool(self, section, name, default=False, untrusted=False): 144 def configbool(self, section, name, default=False, untrusted=False):
145 v = self.config(section, name, None, untrusted) 145 v = self.config(section, name, None, untrusted)
163 '''tell whether section exists in config.''' 163 '''tell whether section exists in config.'''
164 return section in self._data(untrusted) 164 return section in self._data(untrusted)
165 165
166 def configitems(self, section, untrusted=False): 166 def configitems(self, section, untrusted=False):
167 items = self._data(untrusted).items(section) 167 items = self._data(untrusted).items(section)
168 if self.debugflag and not untrusted: 168 if self.debugflag and not untrusted and self._reportuntrusted:
169 for k,v in self._ucfg.items(section): 169 for k,v in self._ucfg.items(section):
170 if self._tcfg.get(section, k) != v: 170 if self._tcfg.get(section, k) != v:
171 self.warn(_("Ignoring untrusted configuration option " 171 self.debug(_("ignoring untrusted configuration option "
172 "%s.%s = %s\n") % (section, k, v)) 172 "%s.%s = %s\n") % (section, k, v))
173 return items 173 return items
174 174
175 def walkconfig(self, untrusted=False): 175 def walkconfig(self, untrusted=False):
176 cfg = self._data(untrusted) 176 cfg = self._data(untrusted)