Commit 4888aecc authored by Yuya Nishihara's avatar Yuya Nishihara

wconfig: don't remember access to unknown section

Follows behavior of Mercurial's config.config.
parent 8106b9e458f9
......@@ -86,6 +86,14 @@ def check_getitem_empty_then_set_no_effect():
c['unknown']['bar'] = 'baz'
assert not c.get('unknown', 'bar')
@with_both
def check_set_followed_by_getitem_empty():
c = newwconfig()
c['unknown']
c.set('unknown', 'foo', 'bar')
assert_equals('bar', c.get('unknown', 'foo'))
assert_equals('bar', c['unknown']['foo'])
@with_both
def check_dict_contains():
c = newwconfig({'foo.bar': 'x'})
......
......@@ -134,8 +134,11 @@ class _wconfig(object):
try:
return self._sections[section]
except KeyError:
self._sections[section] = _wsortdict(self._config[section])
return self._sections[section]
if self._config[section]:
self._sections[section] = _wsortdict(self._config[section])
return self._sections[section]
else:
return {}
def __iter__(self):
return iter(self._config)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment