changeset 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 93c4da6c4416
children 5eed9ceebd64
files mercurial/ui.py
diffstat 1 files changed, 32 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- 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