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