changeset 8185:dc10a7a3f1d4

config: split source data out into separate map
author Matt Mackall <mpm@selenic.com>
date Sun, 26 Apr 2009 16:50:43 -0500
parents 9189afe1eba3
children 6a0018cdb2fe
files mercurial/config.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/config.py	Sun Apr 26 16:50:43 2009 -0500
+++ b/mercurial/config.py	Sun Apr 26 16:50:43 2009 -0500
@@ -30,9 +30,11 @@
 class config:
     def __init__(self, data=None):
         self._data = {}
+        self._source = {}
         if data:
             for k in data._data:
                 self._data[k] = data[k].copy()
+            self._source = data._source.copy()
     def copy(self):
         return config(self)
     def __contains__(self, section):
@@ -47,18 +49,20 @@
                 self._data[s] = sortdict()
             for k in src._data[s]:
                 self._data[s][k] = src._data[s][k]
+                self._source[(s, k)] = src._source[(s, k)]
     def get(self, section, item, default=None):
-        return self._data.get(section, {}).get(item, (default, ""))[0]
+        return self._data.get(section, {}).get(item, default)
     def getsource(self, section, item):
-        return self._data.get(section, {}).get(item, (None, ""))[1]
+        return self._source.get((section, item), "")
     def sections(self):
         return sorted(self._data.keys())
     def items(self, section):
-        return [(k, v[0]) for k,v in self._data.get(section, {}).items()]
+        return self._data.get(section, {}).items()
     def set(self, section, item, value, source=""):
         if section not in self:
             self._data[section] = sortdict()
-        self._data[section][item] = (value, source)
+        self._data[section][item] = value
+        self._source[(section, item)] = source
 
     def read(self, path, fp=None):
         sectionre = re.compile(r'\[([^\[]+)\]')