# HG changeset patch # User Volker Kleinfeld # Date 1147675490 25200 # Node ID d6392a7c03ddcc49e481c13af5e949fdc6ff20fb # Parent e506c14382fd25ba1911a5abdf5e9bf3f714b5ee On win98 os.path.expanuser('~') does not result in a useable directory. The MSDN recommendation for user specific directories is the use of shell.ShGetSpecialFolder, so use it. For details see: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetspecialfolderpath.asp diff -r e506c14382fd -r d6392a7c03dd mercurial/util.py --- a/mercurial/util.py Sun May 14 21:07:34 2006 -0700 +++ b/mercurial/util.py Sun May 14 23:44:50 2006 -0700 @@ -536,12 +536,16 @@ def os_rcpath(): '''return default os-specific hgrc search path''' path = system_rcpath() - path.append(os.path.join(os.path.expanduser('~'), 'mercurial.ini')) + path.append(user_rcpath()) userprofile = os.environ.get('USERPROFILE') if userprofile: path.append(os.path.join(userprofile, 'mercurial.ini')) return path + def user_rcpath(): + '''return os-specific hgrc search path to the user dir''' + return os.path.join(os.path.expanduser('~'), 'mercurial.ini') + def parse_patch_output(output_line): """parses the output produced by patch and returns the file name""" pf = output_line[14:] diff -r e506c14382fd -r d6392a7c03dd mercurial/util_win32.py --- a/mercurial/util_win32.py Sun May 14 21:07:34 2006 -0700 +++ b/mercurial/util_win32.py Sun May 14 23:44:50 2006 -0700 @@ -16,7 +16,7 @@ from demandload import * from i18n import gettext as _ demandload(globals(), 'errno os pywintypes win32con win32file win32process') -demandload(globals(), 'cStringIO winerror') +demandload(globals(), 'cStringIO win32com.shell:shell,shellcon winerror') class WinError: winerror_map = { @@ -183,6 +183,17 @@ filename = win32process.GetModuleFileNameEx(proc, 0) return [os.path.join(os.path.dirname(filename), 'mercurial.ini')] +def user_rcpath(): + '''return os-specific hgrc search path to the user dir''' + userdir = os.path.expanduser('~') + if userdir == '~': + # We are on win < nt: fetch the APPDATA directory location and use + # the parent directory as the user home dir. + appdir = shell.SHGetPathFromIDList( + qshell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_APPDATA)) + userdir = os.path.dirname(appdir) + return os.path.join(userdir, 'mercurial.ini') + class posixfile_nt(object): '''file object with posix-like semantics. on windows, normal files can not be deleted or renamed if they are open. must open