38 defaultpath = os.path.join(util.datapath, 'default.d') |
38 defaultpath = os.path.join(util.datapath, 'default.d') |
39 if os.path.isdir(defaultpath): |
39 if os.path.isdir(defaultpath): |
40 path = _expandrcpath(defaultpath) |
40 path = _expandrcpath(defaultpath) |
41 return path |
41 return path |
42 |
42 |
43 _rcpath = None |
43 _rccomponents = None |
44 |
44 |
45 def rcpath(): |
45 def rccomponents(): |
46 '''return hgrc search path. if env var HGRCPATH is set, use it. |
46 '''return hgrc search path. if env var HGRCPATH is set, use it. |
47 for each item in path, if directory, use files ending in .rc, |
47 for each item in path, if directory, use files ending in .rc, |
48 else use item. |
48 else use item. |
49 make HGRCPATH empty to only look in .hg/hgrc of current repo. |
49 make HGRCPATH empty to only look in .hg/hgrc of current repo. |
50 if no HGRCPATH, use default os-specific path.''' |
50 if no HGRCPATH, use default os-specific path.''' |
51 global _rcpath |
51 global _rccomponents |
52 if _rcpath is None: |
52 if _rccomponents is None: |
53 if 'HGRCPATH' in encoding.environ: |
53 if 'HGRCPATH' in encoding.environ: |
54 _rcpath = [] |
54 _rccomponents = [] |
55 for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep): |
55 for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep): |
56 if not p: |
56 if not p: |
57 continue |
57 continue |
58 _rcpath.extend(_expandrcpath(p)) |
58 _rccomponents.extend(_expandrcpath(p)) |
59 else: |
59 else: |
60 paths = defaultrcpath() + systemrcpath() + userrcpath() |
60 paths = defaultrcpath() + systemrcpath() + userrcpath() |
61 _rcpath = pycompat.maplist(os.path.normpath, paths) |
61 _rccomponents = pycompat.maplist(os.path.normpath, paths) |
62 return _rcpath |
62 return _rccomponents |