win32: new function executable_path
authorAdrian Buehlmann <adrian@cadifra.com>
Mon, 14 Feb 2011 11:12:31 +0100
changeset 13376 60b5c6c3fd12
parent 13375 f1fa8f481c7c
child 13377 4ac565a30e84
win32: new function executable_path
mercurial/win32.py
--- a/mercurial/win32.py	Mon Feb 14 11:12:26 2011 +0100
+++ b/mercurial/win32.py	Mon Feb 14 11:12:31 2011 +0100
@@ -211,9 +211,8 @@
         finally:
             adv.RegCloseKey(kh.value)
 
-def system_rcpath_win32():
-    '''return default os-specific hgrc search path'''
-    rcpath = []
+def executable_path():
+    '''return full path of hg.exe'''
     size = 600
     buf = ctypes.create_string_buffer(size + 1)
     len = _kernel32.GetModuleFileNameA(None, ctypes.byref(buf), size)
@@ -221,7 +220,12 @@
         raise ctypes.WinError()
     elif len == size:
         raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER)
-    filename = buf.value
+    return buf.value
+
+def system_rcpath_win32():
+    '''return default os-specific hgrc search path'''
+    rcpath = []
+    filename = executable_path()
     # Use mercurial.ini found in directory with hg.exe
     progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini')
     if os.path.isfile(progrc):