##// END OF EJS Templates
rcutil: extract rc directory listing logic...
Jun Wu -
r31681:294728f2 default
parent child Browse files
Show More
@@ -24,14 +24,20 b' else:'
24 24 systemrcpath = scmplatform.systemrcpath
25 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 35 def defaultrcpath():
28 36 '''return rc paths in default.d'''
29 37 path = []
30 38 defaultpath = os.path.join(util.datapath, 'default.d')
31 39 if os.path.isdir(defaultpath):
32 for f, kind in osutil.listdir(defaultpath):
33 if f.endswith('.rc'):
34 path.append(os.path.join(defaultpath, f))
40 path = _expandrcpath(defaultpath)
35 41 return path
36 42
37 43 _rcpath = None
@@ -49,13 +55,7 b' def rcpath():'
49 55 for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep):
50 56 if not p:
51 57 continue
52 p = util.expandpath(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)
58 _rcpath.extend(_expandrcpath(p))
59 59 else:
60 60 paths = defaultrcpath() + systemrcpath() + userrcpath()
61 61 _rcpath = pycompat.maplist(os.path.normpath, paths)
General Comments 0
You need to be logged in to leave comments. Login now