Show More
@@ -1,45 +1,46 b'' | |||
|
1 | 1 | import os |
|
2 | 2 | import osutil |
|
3 | import util | |
|
3 | 4 | import _winreg |
|
4 | 5 | |
|
5 | 6 | def systemrcpath(): |
|
6 | 7 | '''return default os-specific hgrc search path''' |
|
7 | 8 | rcpath = [] |
|
8 | 9 | filename = util.executablepath() |
|
9 | 10 | # Use mercurial.ini found in directory with hg.exe |
|
10 | 11 | progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') |
|
11 | 12 | if os.path.isfile(progrc): |
|
12 | 13 | rcpath.append(progrc) |
|
13 | 14 | return rcpath |
|
14 | 15 | # Use hgrc.d found in directory with hg.exe |
|
15 | 16 | progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d') |
|
16 | 17 | if os.path.isdir(progrcd): |
|
17 | 18 | for f, kind in osutil.listdir(progrcd): |
|
18 | 19 | if f.endswith('.rc'): |
|
19 | 20 | rcpath.append(os.path.join(progrcd, f)) |
|
20 | 21 | return rcpath |
|
21 | 22 | # else look for a system rcpath in the registry |
|
22 | 23 | value = util.lookupreg('SOFTWARE\\Mercurial', None, |
|
23 | 24 | _winreg.HKEY_LOCAL_MACHINE) |
|
24 | 25 | if not isinstance(value, str) or not value: |
|
25 | 26 | return rcpath |
|
26 | 27 | value = util.localpath(value) |
|
27 | 28 | for p in value.split(os.pathsep): |
|
28 | 29 | if p.lower().endswith('mercurial.ini'): |
|
29 | 30 | rcpath.append(p) |
|
30 | 31 | elif os.path.isdir(p): |
|
31 | 32 | for f, kind in osutil.listdir(p): |
|
32 | 33 | if f.endswith('.rc'): |
|
33 | 34 | rcpath.append(os.path.join(p, f)) |
|
34 | 35 | return rcpath |
|
35 | 36 | |
|
36 | 37 | def userrcpath(): |
|
37 | 38 | '''return os-specific hgrc search path to the user dir''' |
|
38 | 39 | home = os.path.expanduser('~') |
|
39 | 40 | path = [os.path.join(home, 'mercurial.ini'), |
|
40 | 41 | os.path.join(home, '.hgrc')] |
|
41 | 42 | userprofile = os.environ.get('USERPROFILE') |
|
42 | 43 | if userprofile: |
|
43 | 44 | path.append(os.path.join(userprofile, 'mercurial.ini')) |
|
44 | 45 | path.append(os.path.join(userprofile, '.hgrc')) |
|
45 | 46 | return path |
General Comments 0
You need to be logged in to leave comments.
Login now