[PATCH 03 of 11 V2] scmutil: split osrcpath to return default.d paths

Jun Wu quark at fb.com
Wed Mar 22 03:50:52 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1490165660 25200
#      Tue Mar 21 23:54:20 2017 -0700
# Node ID 7775943a59cfaaae77e2143cbfa0bf0d8d95a447
# Parent  5de0f85888f87c705bcbc38d3e92e97b7e23d1d9
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 7775943a59cf
scmutil: split osrcpath to return default.d paths

After this change, there are 3 rcpath functions:

  - defaultrcpath
  - systemrcpath
  - userrcpath

This will allow us to insert another config layer in the middle.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -392,6 +392,6 @@ def walkrepos(path, followsym=False, see
             dirs[:] = newdirs
 
-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')
@@ -400,7 +400,4 @@ def osrcpath():
             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
 
@@ -449,5 +446,6 @@ def rcpath():
                     _rcpath.append(p)
         else:
-            _rcpath = osrcpath()
+            paths = defaultrcpath() + systemrcpath() + userrcpath()
+            _rcpath = map(os.path.normpath, paths)
     return _rcpath
 


More information about the Mercurial-devel mailing list