Mercurial > hg
comparison mercurial/win32.py @ 13376:60b5c6c3fd12
win32: new function executable_path
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Mon, 14 Feb 2011 11:12:31 +0100 |
parents | f1fa8f481c7c |
children | 4ac565a30e84 |
comparison
equal
deleted
inserted
replaced
13375:f1fa8f481c7c | 13376:60b5c6c3fd12 |
---|---|
209 s = ctypes.string_at(byref(buf), struct.calcsize(fmt)) | 209 s = ctypes.string_at(byref(buf), struct.calcsize(fmt)) |
210 return struct.unpack(fmt, s)[0] | 210 return struct.unpack(fmt, s)[0] |
211 finally: | 211 finally: |
212 adv.RegCloseKey(kh.value) | 212 adv.RegCloseKey(kh.value) |
213 | 213 |
214 def system_rcpath_win32(): | 214 def executable_path(): |
215 '''return default os-specific hgrc search path''' | 215 '''return full path of hg.exe''' |
216 rcpath = [] | |
217 size = 600 | 216 size = 600 |
218 buf = ctypes.create_string_buffer(size + 1) | 217 buf = ctypes.create_string_buffer(size + 1) |
219 len = _kernel32.GetModuleFileNameA(None, ctypes.byref(buf), size) | 218 len = _kernel32.GetModuleFileNameA(None, ctypes.byref(buf), size) |
220 if len == 0: | 219 if len == 0: |
221 raise ctypes.WinError() | 220 raise ctypes.WinError() |
222 elif len == size: | 221 elif len == size: |
223 raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER) | 222 raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER) |
224 filename = buf.value | 223 return buf.value |
224 | |
225 def system_rcpath_win32(): | |
226 '''return default os-specific hgrc search path''' | |
227 rcpath = [] | |
228 filename = executable_path() | |
225 # Use mercurial.ini found in directory with hg.exe | 229 # Use mercurial.ini found in directory with hg.exe |
226 progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') | 230 progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') |
227 if os.path.isfile(progrc): | 231 if os.path.isfile(progrc): |
228 rcpath.append(progrc) | 232 rcpath.append(progrc) |
229 return rcpath | 233 return rcpath |