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