[PATCH 04 of 13 V3] scmutil: copy rcpath to rcpath2

Jun Wu quark at fb.com
Wed Mar 22 13:23:36 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1490200924 25200
#      Wed Mar 22 09:42:04 2017 -0700
# Node ID 8d3521684a9a290d547a90c5ecf6ebdccb72de57
# Parent  ca711190cb22ea50baac89c75f1a621c67d5754f
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 8d3521684a9a
scmutil: copy rcpath to rcpath2

This is temporary and makes the next patch easier to review.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -450,4 +450,29 @@ def rcpath():
     return _rcpath
 
+def rcpath2():
+    '''return hgrc search path. if env var HGRCPATH is set, use it.
+    for each item in path, if directory, use files ending in .rc,
+    else use item.
+    make HGRCPATH empty to only look in .hg/hgrc of current repo.
+    if no HGRCPATH, use default os-specific path.'''
+    global _rcpath
+    if _rcpath is None:
+        if 'HGRCPATH' in encoding.environ:
+            _rcpath = []
+            for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep):
+                if not p:
+                    continue
+                p = util.expandpath(p)
+                if os.path.isdir(p):
+                    for f, kind in osutil.listdir(p):
+                        if f.endswith('.rc'):
+                            _rcpath.append(os.path.join(p, f))
+                else:
+                    _rcpath.append(p)
+        else:
+            paths = defaultrcpath() + systemrcpath() + userrcpath()
+            _rcpath = map(os.path.normpath, paths)
+    return _rcpath
+
 def intrev(rev):
     """Return integer for a given revision that can be used in comparison or


More information about the Mercurial-devel mailing list