Show More
@@ -1,65 +1,67 | |||
|
1 | 1 | from __future__ import absolute_import |
|
2 | 2 | |
|
3 | 3 | import os |
|
4 | 4 | |
|
5 | 5 | from . import ( |
|
6 | 6 | encoding, |
|
7 | 7 | pycompat, |
|
8 | 8 | util, |
|
9 | 9 | win32, |
|
10 | 10 | ) |
|
11 | 11 | |
|
12 | 12 | try: |
|
13 | 13 | import _winreg as winreg # pytype: disable=import-error |
|
14 | 14 | |
|
15 | 15 | winreg.CloseKey |
|
16 | 16 | except ImportError: |
|
17 | 17 | # py2 only |
|
18 | 18 | import winreg # pytype: disable=import-error |
|
19 | 19 | |
|
20 | 20 | # MS-DOS 'more' is the only pager available by default on Windows. |
|
21 | 21 | fallbackpager = b'more' |
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | def systemrcpath(): |
|
25 | 25 | '''return default os-specific hgrc search path''' |
|
26 | 26 | rcpath = [] |
|
27 | 27 | filename = win32.executablepath() |
|
28 | 28 | # Use mercurial.ini found in directory with hg.exe |
|
29 | 29 | progrc = os.path.join(os.path.dirname(filename), b'mercurial.ini') |
|
30 | 30 | rcpath.append(progrc) |
|
31 | ||
|
32 | def _processdir(progrcd): | |
|
33 | if os.path.isdir(progrcd): | |
|
34 | for f, kind in util.listdir(progrcd): | |
|
35 | if f.endswith(b'.rc'): | |
|
36 | rcpath.append(os.path.join(progrcd, f)) | |
|
37 | ||
|
31 | 38 | # Use hgrc.d found in directory with hg.exe |
|
32 |
|
|
|
33 | if os.path.isdir(progrcd): | |
|
34 | for f, kind in util.listdir(progrcd): | |
|
35 | if f.endswith(b'.rc'): | |
|
36 | rcpath.append(os.path.join(progrcd, f)) | |
|
39 | _processdir(os.path.join(os.path.dirname(filename), b'hgrc.d')) | |
|
40 | ||
|
37 | 41 | # next look for a system rcpath in the registry |
|
38 | 42 | value = util.lookupreg( |
|
39 | 43 | b'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE |
|
40 | 44 | ) |
|
41 | 45 | if value and isinstance(value, bytes): |
|
42 | 46 | value = util.localpath(value) |
|
43 | 47 | for p in value.split(pycompat.ospathsep): |
|
44 | 48 | if p.lower().endswith(b'mercurial.ini'): |
|
45 | 49 | rcpath.append(p) |
|
46 |
el |
|
|
47 |
|
|
|
48 | if f.endswith(b'.rc'): | |
|
49 | rcpath.append(os.path.join(p, f)) | |
|
50 | else: | |
|
51 | _processdir(p) | |
|
50 | 52 | return rcpath |
|
51 | 53 | |
|
52 | 54 | |
|
53 | 55 | def userrcpath(): |
|
54 | 56 | '''return os-specific hgrc search path to the user dir''' |
|
55 | 57 | home = os.path.expanduser(b'~') |
|
56 | 58 | path = [os.path.join(home, b'mercurial.ini'), os.path.join(home, b'.hgrc')] |
|
57 | 59 | userprofile = encoding.environ.get(b'USERPROFILE') |
|
58 | 60 | if userprofile and userprofile != home: |
|
59 | 61 | path.append(os.path.join(userprofile, b'mercurial.ini')) |
|
60 | 62 | path.append(os.path.join(userprofile, b'.hgrc')) |
|
61 | 63 | return path |
|
62 | 64 | |
|
63 | 65 | |
|
64 | 66 | def termsize(ui): |
|
65 | 67 | return win32.termsize() |
General Comments 0
You need to be logged in to leave comments.
Login now