mercurial/rcutil.py
changeset 31683 00e569a2da97
parent 31682 07d62fa518a4
child 31684 0be96ac9199a
equal deleted inserted replaced
31682:07d62fa518a4 31683:00e569a2da97
    41     return path
    41     return path
    42 
    42 
    43 _rccomponents = None
    43 _rccomponents = None
    44 
    44 
    45 def rccomponents():
    45 def rccomponents():
    46     '''return hgrc search path. if env var HGRCPATH is set, use it.
    46     '''return an ordered [(type, obj)] about where to load configs.
    47     for each item in path, if directory, use files ending in .rc,
    47 
    48     else use item.
    48     respect $HGRCPATH. if $HGRCPATH is empty, only .hg/hgrc of current repo is
    49     make HGRCPATH empty to only look in .hg/hgrc of current repo.
    49     used. if $HGRCPATH is not set, the platform default will be used.
    50     if no HGRCPATH, use default os-specific path.'''
    50 
       
    51     if a directory is provided, *.rc files under it will be used.
       
    52 
       
    53     type could be either 'path' or 'items', if type is 'path', obj is a string,
       
    54     and is the config file path. if type is 'items', obj is a list of (section,
       
    55     name, value, source) that should fill the config directly.
       
    56     '''
    51     global _rccomponents
    57     global _rccomponents
    52     if _rccomponents is None:
    58     if _rccomponents is None:
    53         if 'HGRCPATH' in encoding.environ:
    59         if 'HGRCPATH' in encoding.environ:
    54             _rccomponents = []
    60             _rccomponents = []
    55             for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep):
    61             for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep):
    56                 if not p:
    62                 if not p:
    57                     continue
    63                     continue
    58                 _rccomponents.extend(_expandrcpath(p))
    64                 _rccomponents.extend(('path', p) for p in _expandrcpath(p))
    59         else:
    65         else:
    60             paths = defaultrcpath() + systemrcpath() + userrcpath()
    66             paths = defaultrcpath() + systemrcpath() + userrcpath()
    61             _rccomponents = pycompat.maplist(os.path.normpath, paths)
    67             _rccomponents = [('path', os.path.normpath(p)) for p in paths]
    62     return _rccomponents
    68     return _rccomponents