mercurial/rcutil.py
changeset 45942 89a2afe31e82
parent 44243 238790674d69
child 48875 6000f5b25c9b
equal deleted inserted replaced
45941:346af7687c6f 45942:89a2afe31e82
    37         )
    37         )
    38     return [p]
    38     return [p]
    39 
    39 
    40 
    40 
    41 def envrcitems(env=None):
    41 def envrcitems(env=None):
    42     '''Return [(section, name, value, source)] config items.
    42     """Return [(section, name, value, source)] config items.
    43 
    43 
    44     The config items are extracted from environment variables specified by env,
    44     The config items are extracted from environment variables specified by env,
    45     used to override systemrc, but not userrc.
    45     used to override systemrc, but not userrc.
    46 
    46 
    47     If env is not provided, encoding.environ will be used.
    47     If env is not provided, encoding.environ will be used.
    48     '''
    48     """
    49     if env is None:
    49     if env is None:
    50         env = encoding.environ
    50         env = encoding.environ
    51     checklist = [
    51     checklist = [
    52         (b'EDITOR', b'ui', b'editor'),
    52         (b'EDITOR', b'ui', b'editor'),
    53         (b'VISUAL', b'ui', b'editor'),
    53         (b'VISUAL', b'ui', b'editor'),
    71         and r.endswith(b'.rc')
    71         and r.endswith(b'.rc')
    72     ]
    72     ]
    73 
    73 
    74 
    74 
    75 def rccomponents():
    75 def rccomponents():
    76     '''return an ordered [(type, obj)] about where to load configs.
    76     """return an ordered [(type, obj)] about where to load configs.
    77 
    77 
    78     respect $HGRCPATH. if $HGRCPATH is empty, only .hg/hgrc of current repo is
    78     respect $HGRCPATH. if $HGRCPATH is empty, only .hg/hgrc of current repo is
    79     used. if $HGRCPATH is not set, the platform default will be used.
    79     used. if $HGRCPATH is not set, the platform default will be used.
    80 
    80 
    81     if a directory is provided, *.rc files under it will be used.
    81     if a directory is provided, *.rc files under it will be used.
    82 
    82 
    83     type could be either 'path', 'items' or 'resource'. If type is 'path',
    83     type could be either 'path', 'items' or 'resource'. If type is 'path',
    84     obj is a string, and is the config file path. if type is 'items', obj is a
    84     obj is a string, and is the config file path. if type is 'items', obj is a
    85     list of (section, name, value, source) that should fill the config directly.
    85     list of (section, name, value, source) that should fill the config directly.
    86     If type is 'resource', obj is a tuple of (package name, resource name).
    86     If type is 'resource', obj is a tuple of (package name, resource name).
    87     '''
    87     """
    88     envrc = (b'items', envrcitems())
    88     envrc = (b'items', envrcitems())
    89 
    89 
    90     if b'HGRCPATH' in encoding.environ:
    90     if b'HGRCPATH' in encoding.environ:
    91         # assume HGRCPATH is all about user configs so environments can be
    91         # assume HGRCPATH is all about user configs so environments can be
    92         # overridden.
    92         # overridden.
   106         _rccomponents.extend(normpaths(userrcpath()))
   106         _rccomponents.extend(normpaths(userrcpath()))
   107     return _rccomponents
   107     return _rccomponents
   108 
   108 
   109 
   109 
   110 def defaultpagerenv():
   110 def defaultpagerenv():
   111     '''return a dict of default environment variables and their values,
   111     """return a dict of default environment variables and their values,
   112     intended to be set before starting a pager.
   112     intended to be set before starting a pager.
   113     '''
   113     """
   114     return {b'LESS': b'FRX', b'LV': b'-c'}
   114     return {b'LESS': b'FRX', b'LV': b'-c'}
   115 
   115 
   116 
   116 
   117 def use_repo_hgrc():
   117 def use_repo_hgrc():
   118     """True if repositories `.hg/hgrc` config should be read"""
   118     """True if repositories `.hg/hgrc` config should be read"""