# HG changeset patch # User Matt Mackall # Date 2009-04-26 21:50:43 # Node ID 6a0018cdb2fe45cc5c7aa8e06380ffb707f972d2 # Parent dc10a7a3f1d41737b1229956d93f993cca7484d3 config: add some helper methods diff --git a/mercurial/config.py b/mercurial/config.py --- a/mercurial/config.py +++ b/mercurial/config.py @@ -27,7 +27,7 @@ class sortdict(dict): dict.__delitem__(self, key) self._list.remove(key) -class config: +class config(object): def __init__(self, data=None): self._data = {} self._source = {} @@ -39,6 +39,11 @@ class config: return config(self) def __contains__(self, section): return section in self._data + def __getitem__(self, section): + return self._data.get(section, {}) + def __iter__(self): + for d in self.sections(): + yield d def update(self, src, sections=None): if not sections: sections = src.sections()