Mercurial > hg
changeset 8184:9189afe1eba3
config: add %unset name support
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:43 -0500 |
parents | 2858ab754995 |
children | dc10a7a3f1d4 |
files | mercurial/config.py |
diffstat | 1 files changed, 12 insertions(+), 1 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 @@ -2,7 +2,7 @@ import re, error, os class sortdict(dict): - 'a simple append-only sorted dictionary' + 'a simple sorted dictionary' def __init__(self, data=None): self._list = [] if data: @@ -23,6 +23,9 @@ self[k] = src[k] def items(self): return [(k,self[k]) for k in self._list] + def __delitem__(self, key): + dict.__delitem__(self, key) + self._list.remove(key) class config: def __init__(self, data=None): @@ -62,6 +65,7 @@ itemre = re.compile(r'([^=\s]+)\s*=\s*(.*)') contre = re.compile(r'\s+(\S.*)') emptyre = re.compile(r'(;|#|\s*$)') + unsetre = re.compile(r'%unset\s+(\S.*)') includere = re.compile(r'%include\s+(\S.*)') section = "" item = None @@ -102,5 +106,12 @@ self.set(section, item, m.group(2), "%s:%d" % (path, line)) cont = 1 continue + m = unsetre.match(l) + if m: + name = m.group(1) + if self.get(section, name) != None: + del self._data[section][name] + continue + raise error.ConfigError(_('config error at %s:%d: \'%s\'') % (path, line, l.rstrip()))