# HG changeset patch # User Nicolas Dumazet # Date 1287378636 -32400 # Node ID ad2506f097d31c97800e938458779310bb971e85 # Parent 93c4da6c44169592b6276392d2921b9cc0a561c2 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. diff -r 93c4da6c4416 -r ad2506f097d3 mercurial/ui.py --- a/mercurial/ui.py Tue Oct 19 23:15:31 2010 +0900 +++ b/mercurial/ui.py Mon Oct 18 14:10:36 2010 +0900 @@ -97,42 +97,46 @@ root = os.path.expanduser('~') self.fixconfig(root=root) - def fixconfig(self, root=None): - # expand vars and ~ - # translate paths relative to root (or home) into absolute paths - root = root or os.getcwd() - for c in self._tcfg, self._ucfg, self._ocfg: - for n, p in c.items('paths'): - if not p: - continue - if '%%' in p: - self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") - % (n, p, self.configsource('paths', n))) - p = p.replace('%%', '%') - p = util.expandpath(p) - if '://' not in p and not os.path.isabs(p): - p = os.path.normpath(os.path.join(root, p)) - c.set("paths", n, p) + def fixconfig(self, root=None, section=None): + if section in (None, 'paths'): + # expand vars and ~ + # translate paths relative to root (or home) into absolute paths + root = root or os.getcwd() + for c in self._tcfg, self._ucfg, self._ocfg: + for n, p in c.items('paths'): + if not p: + continue + if '%%' in p: + self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") + % (n, p, self.configsource('paths', n))) + p = p.replace('%%', '%') + p = util.expandpath(p) + if '://' not in p and not os.path.isabs(p): + p = os.path.normpath(os.path.join(root, p)) + c.set("paths", n, p) - # update ui options - self.debugflag = self.configbool('ui', 'debug') - self.verbose = self.debugflag or self.configbool('ui', 'verbose') - self.quiet = not self.debugflag and self.configbool('ui', 'quiet') - if self.verbose and self.quiet: - self.quiet = self.verbose = False - self._reportuntrusted = self.configbool("ui", "report_untrusted", True) - self.tracebackflag = self.configbool('ui', 'traceback', False) + if section in (None, 'ui'): + # update ui options + self.debugflag = self.configbool('ui', 'debug') + self.verbose = self.debugflag or self.configbool('ui', 'verbose') + self.quiet = not self.debugflag and self.configbool('ui', 'quiet') + if self.verbose and self.quiet: + self.quiet = self.verbose = False + self._reportuntrusted = self.configbool("ui", "report_untrusted", + True) + self.tracebackflag = self.configbool('ui', 'traceback', False) - # update trust information - self._trustusers.update(self.configlist('trusted', 'users')) - self._trustgroups.update(self.configlist('trusted', 'groups')) + if section in (None, 'trusted'): + # update trust information + self._trustusers.update(self.configlist('trusted', 'users')) + self._trustgroups.update(self.configlist('trusted', 'groups')) def setconfig(self, section, name, value, overlay=True): if overlay: self._ocfg.set(section, name, value) self._tcfg.set(section, name, value) self._ucfg.set(section, name, value) - self.fixconfig() + self.fixconfig(section=section) def _data(self, untrusted): return untrusted and self._ucfg or self._tcfg