Show More
@@ -1,39 +1,40 b'' | |||||
1 | from __future__ import absolute_import |
|
1 | from __future__ import absolute_import | |
2 |
|
2 | |||
3 | import os |
|
3 | import os | |
4 | import sys |
|
4 | import sys | |
5 |
|
5 | |||
6 | from . import ( |
|
6 | from . import ( | |
|
7 | encoding, | |||
7 | osutil, |
|
8 | osutil, | |
8 | ) |
|
9 | ) | |
9 |
|
10 | |||
10 | def _rcfiles(path): |
|
11 | def _rcfiles(path): | |
11 | rcs = [os.path.join(path, 'hgrc')] |
|
12 | rcs = [os.path.join(path, 'hgrc')] | |
12 | rcdir = os.path.join(path, 'hgrc.d') |
|
13 | rcdir = os.path.join(path, 'hgrc.d') | |
13 | try: |
|
14 | try: | |
14 | rcs.extend([os.path.join(rcdir, f) |
|
15 | rcs.extend([os.path.join(rcdir, f) | |
15 | for f, kind in osutil.listdir(rcdir) |
|
16 | for f, kind in osutil.listdir(rcdir) | |
16 | if f.endswith(".rc")]) |
|
17 | if f.endswith(".rc")]) | |
17 | except OSError: |
|
18 | except OSError: | |
18 | pass |
|
19 | pass | |
19 | return rcs |
|
20 | return rcs | |
20 |
|
21 | |||
21 | def systemrcpath(): |
|
22 | def systemrcpath(): | |
22 | path = [] |
|
23 | path = [] | |
23 | if sys.platform == 'plan9': |
|
24 | if sys.platform == 'plan9': | |
24 | root = 'lib/mercurial' |
|
25 | root = 'lib/mercurial' | |
25 | else: |
|
26 | else: | |
26 | root = 'etc/mercurial' |
|
27 | root = 'etc/mercurial' | |
27 | # old mod_python does not set sys.argv |
|
28 | # old mod_python does not set sys.argv | |
28 | if len(getattr(sys, 'argv', [])) > 0: |
|
29 | if len(getattr(sys, 'argv', [])) > 0: | |
29 | p = os.path.dirname(os.path.dirname(sys.argv[0])) |
|
30 | p = os.path.dirname(os.path.dirname(sys.argv[0])) | |
30 | if p != '/': |
|
31 | if p != '/': | |
31 | path.extend(_rcfiles(os.path.join(p, root))) |
|
32 | path.extend(_rcfiles(os.path.join(p, root))) | |
32 | path.extend(_rcfiles('/' + root)) |
|
33 | path.extend(_rcfiles('/' + root)) | |
33 | return path |
|
34 | return path | |
34 |
|
35 | |||
35 | def userrcpath(): |
|
36 | def userrcpath(): | |
36 | if sys.platform == 'plan9': |
|
37 | if sys.platform == 'plan9': | |
37 |
return [ |
|
38 | return [encoding.environ['home'] + '/lib/hgrc'] | |
38 | else: |
|
39 | else: | |
39 | return [os.path.expanduser('~/.hgrc')] |
|
40 | return [os.path.expanduser('~/.hgrc')] |
General Comments 0
You need to be logged in to leave comments.
Login now