comparison mercurial/ui.py @ 12764:ad2506f097d3

ui: only fix config if the relevant section has changed In particular, when extensions add hooks, or add non-ui and non-paths configuration items during their setups, we really have no reason to re-"fix" the config dictionaries.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Mon, 18 Oct 2010 14:10:36 +0900
parents c52c629ce19e
children 3da456d0c885
comparison
equal deleted inserted replaced
12763:93c4da6c4416 12764:ad2506f097d3
95 95
96 if root is None: 96 if root is None:
97 root = os.path.expanduser('~') 97 root = os.path.expanduser('~')
98 self.fixconfig(root=root) 98 self.fixconfig(root=root)
99 99
100 def fixconfig(self, root=None): 100 def fixconfig(self, root=None, section=None):
101 # expand vars and ~ 101 if section in (None, 'paths'):
102 # translate paths relative to root (or home) into absolute paths 102 # expand vars and ~
103 root = root or os.getcwd() 103 # translate paths relative to root (or home) into absolute paths
104 for c in self._tcfg, self._ucfg, self._ocfg: 104 root = root or os.getcwd()
105 for n, p in c.items('paths'): 105 for c in self._tcfg, self._ucfg, self._ocfg:
106 if not p: 106 for n, p in c.items('paths'):
107 continue 107 if not p:
108 if '%%' in p: 108 continue
109 self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") 109 if '%%' in p:
110 % (n, p, self.configsource('paths', n))) 110 self.warn(_("(deprecated '%%' in path %s=%s from %s)\n")
111 p = p.replace('%%', '%') 111 % (n, p, self.configsource('paths', n)))
112 p = util.expandpath(p) 112 p = p.replace('%%', '%')
113 if '://' not in p and not os.path.isabs(p): 113 p = util.expandpath(p)
114 p = os.path.normpath(os.path.join(root, p)) 114 if '://' not in p and not os.path.isabs(p):
115 c.set("paths", n, p) 115 p = os.path.normpath(os.path.join(root, p))
116 116 c.set("paths", n, p)
117 # update ui options 117
118 self.debugflag = self.configbool('ui', 'debug') 118 if section in (None, 'ui'):
119 self.verbose = self.debugflag or self.configbool('ui', 'verbose') 119 # update ui options
120 self.quiet = not self.debugflag and self.configbool('ui', 'quiet') 120 self.debugflag = self.configbool('ui', 'debug')
121 if self.verbose and self.quiet: 121 self.verbose = self.debugflag or self.configbool('ui', 'verbose')
122 self.quiet = self.verbose = False 122 self.quiet = not self.debugflag and self.configbool('ui', 'quiet')
123 self._reportuntrusted = self.configbool("ui", "report_untrusted", True) 123 if self.verbose and self.quiet:
124 self.tracebackflag = self.configbool('ui', 'traceback', False) 124 self.quiet = self.verbose = False
125 125 self._reportuntrusted = self.configbool("ui", "report_untrusted",
126 # update trust information 126 True)
127 self._trustusers.update(self.configlist('trusted', 'users')) 127 self.tracebackflag = self.configbool('ui', 'traceback', False)
128 self._trustgroups.update(self.configlist('trusted', 'groups')) 128
129 if section in (None, 'trusted'):
130 # update trust information
131 self._trustusers.update(self.configlist('trusted', 'users'))
132 self._trustgroups.update(self.configlist('trusted', 'groups'))
129 133
130 def setconfig(self, section, name, value, overlay=True): 134 def setconfig(self, section, name, value, overlay=True):
131 if overlay: 135 if overlay:
132 self._ocfg.set(section, name, value) 136 self._ocfg.set(section, name, value)
133 self._tcfg.set(section, name, value) 137 self._tcfg.set(section, name, value)
134 self._ucfg.set(section, name, value) 138 self._ucfg.set(section, name, value)
135 self.fixconfig() 139 self.fixconfig(section=section)
136 140
137 def _data(self, untrusted): 141 def _data(self, untrusted):
138 return untrusted and self._ucfg or self._tcfg 142 return untrusted and self._ucfg or self._tcfg
139 143
140 def configsource(self, section, name, untrusted=False): 144 def configsource(self, section, name, untrusted=False):