Show More
@@ -24,14 +24,20 b' else:' | |||||
24 | systemrcpath = scmplatform.systemrcpath |
|
24 | systemrcpath = scmplatform.systemrcpath | |
25 | userrcpath = scmplatform.userrcpath |
|
25 | userrcpath = scmplatform.userrcpath | |
26 |
|
26 | |||
|
27 | def _expandrcpath(path): | |||
|
28 | '''path could be a file or a directory. return a list of file paths''' | |||
|
29 | p = util.expandpath(path) | |||
|
30 | if os.path.isdir(p): | |||
|
31 | join = os.path.join | |||
|
32 | return [join(p, f) for f, k in osutil.listdir(p) if f.endswith('.rc')] | |||
|
33 | return [p] | |||
|
34 | ||||
27 | def defaultrcpath(): |
|
35 | def defaultrcpath(): | |
28 | '''return rc paths in default.d''' |
|
36 | '''return rc paths in default.d''' | |
29 | path = [] |
|
37 | path = [] | |
30 | defaultpath = os.path.join(util.datapath, 'default.d') |
|
38 | defaultpath = os.path.join(util.datapath, 'default.d') | |
31 | if os.path.isdir(defaultpath): |
|
39 | if os.path.isdir(defaultpath): | |
32 | for f, kind in osutil.listdir(defaultpath): |
|
40 | path = _expandrcpath(defaultpath) | |
33 | if f.endswith('.rc'): |
|
|||
34 | path.append(os.path.join(defaultpath, f)) |
|
|||
35 | return path |
|
41 | return path | |
36 |
|
42 | |||
37 | _rcpath = None |
|
43 | _rcpath = None | |
@@ -49,13 +55,7 b' def rcpath():' | |||||
49 | for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep): |
|
55 | for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep): | |
50 | if not p: |
|
56 | if not p: | |
51 | continue |
|
57 | continue | |
52 |
|
|
58 | _rcpath.extend(_expandrcpath(p)) | |
53 | if os.path.isdir(p): |
|
|||
54 | for f, kind in osutil.listdir(p): |
|
|||
55 | if f.endswith('.rc'): |
|
|||
56 | _rcpath.append(os.path.join(p, f)) |
|
|||
57 | else: |
|
|||
58 | _rcpath.append(p) |
|
|||
59 | else: |
|
59 | else: | |
60 | paths = defaultrcpath() + systemrcpath() + userrcpath() |
|
60 | paths = defaultrcpath() + systemrcpath() + userrcpath() | |
61 | _rcpath = pycompat.maplist(os.path.normpath, paths) |
|
61 | _rcpath = pycompat.maplist(os.path.normpath, paths) |
General Comments 0
You need to be logged in to leave comments.
Login now