diff mercurial/config.py @ 19087:7d82ad4b3727 stable

config: discard "%unset" values defined in the other files read in previously Before this patch, "%unset" can't unset values defined in the other files read in previously, even though online help document says that it can. It can unset only values defined in the same configuration file. For example, the value defined in "~/.hgrc" can't be unset by "%unset" in ".hg/hgrc" of the repository. This patch records "%unset"-ed values in "config.parse()", and discards corresponding values in "config.update()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 26 Apr 2013 23:36:12 +0900
parents 31f32a96e1e3
children d19c9bdbbf35
line wrap: on
line diff
--- a/mercurial/config.py	Fri Apr 26 23:16:25 2013 +0900
+++ b/mercurial/config.py	Fri Apr 26 23:36:12 2013 +0900
@@ -44,6 +44,7 @@
     def __init__(self, data=None):
         self._data = {}
         self._source = {}
+        self._unset = []
         if data:
             for k in data._data:
                 self._data[k] = data[k].copy()
@@ -58,6 +59,10 @@
         for d in self.sections():
             yield d
     def update(self, src):
+        for s, n in src._unset:
+            if s in self and n in self._data[s]:
+                del self._data[s][n]
+                del self._source[(s, n)]
         for s in src:
             if s not in self:
                 self._data[s] = sortdict()
@@ -173,6 +178,7 @@
                     continue
                 if self.get(section, name) is not None:
                     del self._data[section][name]
+                self._unset.append((section, name))
                 continue
 
             raise error.ParseError(l.rstrip(), ("%s:%s" % (src, line)))