[PATCH 4 of 6 V2] win32: move system_rcpath_win32() to windows.py
Adrian Buehlmann
adrian at cadifra.com
Mon Feb 14 07:44:32 CST 2011
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1297678355 -3600
# Node ID 4ac565a30e84a15d3bbf9cb8a6bc42ff9a1e6da5
# Parent 60b5c6c3fd12b198235bb26f79808f0a8f3c7bd6
win32: move system_rcpath_win32() to windows.py
no code change in system_rcpath_win32
This breaks the dependency from the win32 module on osutil
diff --git a/mercurial/win32.py b/mercurial/win32.py
--- a/mercurial/win32.py
+++ b/mercurial/win32.py
@@ -5,7 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-import osutil, encoding
+import encoding
import ctypes, errno, os, struct, subprocess
_kernel32 = ctypes.windll.kernel32
@@ -222,36 +222,6 @@ def executable_path():
raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER)
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):
- rcpath.append(progrc)
- return rcpath
- # Use hgrc.d found in directory with hg.exe
- progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d')
- if os.path.isdir(progrcd):
- for f, kind in osutil.listdir(progrcd):
- if f.endswith('.rc'):
- rcpath.append(os.path.join(progrcd, f))
- return rcpath
- # else look for a system rcpath in the registry
- value = lookup_reg('SOFTWARE\\Mercurial', None, _HKEY_LOCAL_MACHINE)
- if not isinstance(value, str) or not value:
- return rcpath
- value = value.replace('/', os.sep)
- for p in value.split(os.pathsep):
- if p.lower().endswith('mercurial.ini'):
- rcpath.append(p)
- elif os.path.isdir(p):
- for f, kind in osutil.listdir(p):
- if f.endswith('.rc'):
- rcpath.append(os.path.join(p, f))
- return rcpath
-
def user_rcpath_win32():
'''return os-specific hgrc search path to the user dir'''
userdir = os.path.expanduser('~')
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -73,6 +73,38 @@ def _is_win_9x():
def openhardlinks():
return not _is_win_9x()
+_HKEY_LOCAL_MACHINE = 0x80000002L
+
+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):
+ rcpath.append(progrc)
+ return rcpath
+ # Use hgrc.d found in directory with hg.exe
+ progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d')
+ if os.path.isdir(progrcd):
+ for f, kind in osutil.listdir(progrcd):
+ if f.endswith('.rc'):
+ rcpath.append(os.path.join(progrcd, f))
+ return rcpath
+ # else look for a system rcpath in the registry
+ value = lookup_reg('SOFTWARE\\Mercurial', None, _HKEY_LOCAL_MACHINE)
+ if not isinstance(value, str) or not value:
+ return rcpath
+ value = value.replace('/', os.sep)
+ for p in value.split(os.pathsep):
+ if p.lower().endswith('mercurial.ini'):
+ rcpath.append(p)
+ elif os.path.isdir(p):
+ for f, kind in osutil.listdir(p):
+ if f.endswith('.rc'):
+ rcpath.append(os.path.join(p, f))
+ return rcpath
+
def system_rcpath():
try:
return system_rcpath_win32()
More information about the Mercurial-devel
mailing list