Mercurial > public > mercurial-scm > hg-stable
diff mercurial/windows.py @ 13377:4ac565a30e84
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
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Mon, 14 Feb 2011 11:12:35 +0100 |
parents | f1fa8f481c7c |
children | 244772f67ac1 |
line wrap: on
line diff
--- a/mercurial/windows.py Mon Feb 14 11:12:31 2011 +0100 +++ b/mercurial/windows.py Mon Feb 14 11:12:35 2011 +0100 @@ -73,6 +73,38 @@ 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()