mercurial/rcutil.py
changeset 31684 0be96ac9199a
parent 31683 00e569a2da97
child 31685 d83e51654c8a
equal deleted inserted replaced
31683:00e569a2da97 31684:0be96ac9199a
    29     p = util.expandpath(path)
    29     p = util.expandpath(path)
    30     if os.path.isdir(p):
    30     if os.path.isdir(p):
    31         join = os.path.join
    31         join = os.path.join
    32         return [join(p, f) for f, k in osutil.listdir(p) if f.endswith('.rc')]
    32         return [join(p, f) for f, k in osutil.listdir(p) if f.endswith('.rc')]
    33     return [p]
    33     return [p]
       
    34 
       
    35 def envrcitems(env=None):
       
    36     '''Return [(section, name, value, source)] config items.
       
    37 
       
    38     The config items are extracted from environment variables specified by env,
       
    39     used to override systemrc, but not userrc.
       
    40 
       
    41     If env is not provided, encoding.environ will be used.
       
    42     '''
       
    43     if env is None:
       
    44         env = encoding.environ
       
    45     checklist = [
       
    46         ('EDITOR', 'ui', 'editor'),
       
    47         ('VISUAL', 'ui', 'editor'),
       
    48         ('PAGER', 'pager', 'pager'),
       
    49     ]
       
    50     result = []
       
    51     for envname, section, configname in checklist:
       
    52         if envname not in env:
       
    53             continue
       
    54         result.append((section, configname, env[envname], '$%s' % envname))
       
    55     return result
    34 
    56 
    35 def defaultrcpath():
    57 def defaultrcpath():
    36     '''return rc paths in default.d'''
    58     '''return rc paths in default.d'''
    37     path = []
    59     path = []
    38     defaultpath = os.path.join(util.datapath, 'default.d')
    60     defaultpath = os.path.join(util.datapath, 'default.d')