##// END OF EJS Templates
win32: move system_rcpath_win32() to windows.py...
Adrian Buehlmann -
r13377:4ac565a3 default
parent child Browse files
Show More
@@ -5,7 +5,7 b''
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import osutil, encoding
8 import encoding
9 import ctypes, errno, os, struct, subprocess
9 import ctypes, errno, os, struct, subprocess
10
10
11 _kernel32 = ctypes.windll.kernel32
11 _kernel32 = ctypes.windll.kernel32
@@ -222,36 +222,6 b' def executable_path():'
222 raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER)
222 raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER)
223 return buf.value
223 return buf.value
224
224
225 def system_rcpath_win32():
226 '''return default os-specific hgrc search path'''
227 rcpath = []
228 filename = executable_path()
229 # Use mercurial.ini found in directory with hg.exe
230 progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini')
231 if os.path.isfile(progrc):
232 rcpath.append(progrc)
233 return rcpath
234 # Use hgrc.d found in directory with hg.exe
235 progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d')
236 if os.path.isdir(progrcd):
237 for f, kind in osutil.listdir(progrcd):
238 if f.endswith('.rc'):
239 rcpath.append(os.path.join(progrcd, f))
240 return rcpath
241 # else look for a system rcpath in the registry
242 value = lookup_reg('SOFTWARE\\Mercurial', None, _HKEY_LOCAL_MACHINE)
243 if not isinstance(value, str) or not value:
244 return rcpath
245 value = value.replace('/', os.sep)
246 for p in value.split(os.pathsep):
247 if p.lower().endswith('mercurial.ini'):
248 rcpath.append(p)
249 elif os.path.isdir(p):
250 for f, kind in osutil.listdir(p):
251 if f.endswith('.rc'):
252 rcpath.append(os.path.join(p, f))
253 return rcpath
254
255 def user_rcpath_win32():
225 def user_rcpath_win32():
256 '''return os-specific hgrc search path to the user dir'''
226 '''return os-specific hgrc search path to the user dir'''
257 userdir = os.path.expanduser('~')
227 userdir = os.path.expanduser('~')
@@ -73,6 +73,38 b' def _is_win_9x():'
73 def openhardlinks():
73 def openhardlinks():
74 return not _is_win_9x()
74 return not _is_win_9x()
75
75
76 _HKEY_LOCAL_MACHINE = 0x80000002L
77
78 def system_rcpath_win32():
79 '''return default os-specific hgrc search path'''
80 rcpath = []
81 filename = executable_path()
82 # Use mercurial.ini found in directory with hg.exe
83 progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini')
84 if os.path.isfile(progrc):
85 rcpath.append(progrc)
86 return rcpath
87 # Use hgrc.d found in directory with hg.exe
88 progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d')
89 if os.path.isdir(progrcd):
90 for f, kind in osutil.listdir(progrcd):
91 if f.endswith('.rc'):
92 rcpath.append(os.path.join(progrcd, f))
93 return rcpath
94 # else look for a system rcpath in the registry
95 value = lookup_reg('SOFTWARE\\Mercurial', None, _HKEY_LOCAL_MACHINE)
96 if not isinstance(value, str) or not value:
97 return rcpath
98 value = value.replace('/', os.sep)
99 for p in value.split(os.pathsep):
100 if p.lower().endswith('mercurial.ini'):
101 rcpath.append(p)
102 elif os.path.isdir(p):
103 for f, kind in osutil.listdir(p):
104 if f.endswith('.rc'):
105 rcpath.append(os.path.join(p, f))
106 return rcpath
107
76 def system_rcpath():
108 def system_rcpath():
77 try:
109 try:
78 return system_rcpath_win32()
110 return system_rcpath_win32()
General Comments 0
You need to be logged in to leave comments. Login now