changeset 31680:448889f9a36c

rcutil: split osrcpath to return default.d paths (API) After this change, there are 3 rcpath functions: - defaultrcpath - systemrcpath - userrcpath This will allow us to insert another config layer in the middle.
author Jun Wu <quark@fb.com>
date Sun, 26 Mar 2017 20:21:32 -0700
parents 0f8ba0bc1154
children 294728f2a908
files mercurial/rcutil.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/rcutil.py	Sun Mar 26 20:18:42 2017 -0700
+++ b/mercurial/rcutil.py	Sun Mar 26 20:21:32 2017 -0700
@@ -24,17 +24,14 @@
 systemrcpath = scmplatform.systemrcpath
 userrcpath = scmplatform.userrcpath
 
-def osrcpath():
-    '''return default os-specific hgrc search path'''
+def defaultrcpath():
+    '''return rc paths in default.d'''
     path = []
     defaultpath = os.path.join(util.datapath, 'default.d')
     if os.path.isdir(defaultpath):
         for f, kind in osutil.listdir(defaultpath):
             if f.endswith('.rc'):
                 path.append(os.path.join(defaultpath, f))
-    path.extend(systemrcpath())
-    path.extend(userrcpath())
-    path = [os.path.normpath(f) for f in path]
     return path
 
 _rcpath = None
@@ -60,5 +57,6 @@
                 else:
                     _rcpath.append(p)
         else:
-            _rcpath = osrcpath()
+            paths = defaultrcpath() + systemrcpath() + userrcpath()
+            _rcpath = pycompat.maplist(os.path.normpath, paths)
     return _rcpath