comparison mercurial/rcutil.py @ 31692:cf052cc5c2c2

rcutil: do not cache rccomponents The function is only called once except for "hg debugconfig", where it is called twice. So there is no need to cache it. Caching it will cause issues with chgserver. Instead of dropping the cache in chgserver, it seems cleaner to just avoid the cache.
author Jun Wu <quark@fb.com>
date Tue, 28 Mar 2017 07:54:00 -0700
parents d83e51654c8a
children 67f0377bd24b
comparison
equal deleted inserted replaced
31691:c3ca0ad8ab9c 31692:cf052cc5c2c2
60 defaultpath = os.path.join(util.datapath, 'default.d') 60 defaultpath = os.path.join(util.datapath, 'default.d')
61 if os.path.isdir(defaultpath): 61 if os.path.isdir(defaultpath):
62 path = _expandrcpath(defaultpath) 62 path = _expandrcpath(defaultpath)
63 return path 63 return path
64 64
65 _rccomponents = None
66
67 def rccomponents(): 65 def rccomponents():
68 '''return an ordered [(type, obj)] about where to load configs. 66 '''return an ordered [(type, obj)] about where to load configs.
69 67
70 respect $HGRCPATH. if $HGRCPATH is empty, only .hg/hgrc of current repo is 68 respect $HGRCPATH. if $HGRCPATH is empty, only .hg/hgrc of current repo is
71 used. if $HGRCPATH is not set, the platform default will be used. 69 used. if $HGRCPATH is not set, the platform default will be used.
76 and is the config file path. if type is 'items', obj is a list of (section, 74 and is the config file path. if type is 'items', obj is a list of (section,
77 name, value, source) that should fill the config directly. 75 name, value, source) that should fill the config directly.
78 ''' 76 '''
79 envrc = ('items', envrcitems()) 77 envrc = ('items', envrcitems())
80 78
81 global _rccomponents 79 _rccomponents = None
82 if _rccomponents is None: 80 if _rccomponents is None:
83 if 'HGRCPATH' in encoding.environ: 81 if 'HGRCPATH' in encoding.environ:
84 # assume HGRCPATH is all about user configs so environments can be 82 # assume HGRCPATH is all about user configs so environments can be
85 # overridden. 83 # overridden.
86 _rccomponents = [envrc] 84 _rccomponents = [envrc]