comparison mercurial/rcutil.py @ 42093:edbcf5b239f9

config: read configs from directories in lexicographical order Mercurial currently reads the .rc files specified in HGRCPATH (and the system-default paths) in directory order, which is unspecified. My team at work maintains a set of .rc files. So far there has been no overlap between them, so we had not noticed this behavior. However, we would now like to release some common .rc files and then have another one per plaform with platform-specific overrides. It would be nice if we can determine the load order by choosing names carefully. This patch enables that by loading the .rc files in lexicographical order. Before this patch, the added test case would consistently say "30" on my file system (whatever I have -- some Linux FS). Differential Revision: https://phab.mercurial-scm.org/D6193
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 03 Apr 2019 16:03:41 -0700
parents 75979c8d4572
children 57875cf423c9
comparison
equal deleted inserted replaced
42092:91cc8dc866ed 42093:edbcf5b239f9
27 def _expandrcpath(path): 27 def _expandrcpath(path):
28 '''path could be a file or a directory. return a list of file paths''' 28 '''path could be a file or a directory. return a list of file paths'''
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 util.listdir(p) if f.endswith('.rc')] 32 return sorted(join(p, f) for f, k in util.listdir(p)
33 if f.endswith('.rc'))
33 return [p] 34 return [p]
34 35
35 def envrcitems(env=None): 36 def envrcitems(env=None):
36 '''Return [(section, name, value, source)] config items. 37 '''Return [(section, name, value, source)] config items.
37 38