mercurial/config.py
changeset 31306 c920efa9d34b
parent 31176 99c5843b228d
child 31374 d30fb3de4b40
equal deleted inserted replaced
31305:dc9842a7017c 31306:c920efa9d34b
    11 import os
    11 import os
    12 
    12 
    13 from .i18n import _
    13 from .i18n import _
    14 from . import (
    14 from . import (
    15     error,
    15     error,
       
    16     pycompat,
    16     util,
    17     util,
    17 )
    18 )
    18 
    19 
    19 class config(object):
    20 class config(object):
    20     def __init__(self, data=None, includepaths=[]):
    21     def __init__(self, data=None, includepaths=[]):
    67     def sections(self):
    68     def sections(self):
    68         return sorted(self._data.keys())
    69         return sorted(self._data.keys())
    69     def items(self, section):
    70     def items(self, section):
    70         return self._data.get(section, {}).items()
    71         return self._data.get(section, {}).items()
    71     def set(self, section, item, value, source=""):
    72     def set(self, section, item, value, source=""):
       
    73         if pycompat.ispy3:
       
    74             assert not isinstance(value, str), (
       
    75                 'config values may not be unicode strings on Python 3')
    72         if section not in self:
    76         if section not in self:
    73             self._data[section] = util.sortdict()
    77             self._data[section] = util.sortdict()
    74         self._data[section][item] = value
    78         self._data[section][item] = value
    75         if source:
    79         if source:
    76             self._source[(section, item)] = source
    80             self._source[(section, item)] = source