On win98 os.path.expanuser('~') does not result in a useable directory.
authorVolker Kleinfeld <Volker.Kleinfeld@gmx.de>
Sun, 14 May 2006 23:44:50 -0700
changeset 2284 d6392a7c03dd
parent 2283 e506c14382fd
child 2285 0912f807b7ff
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
mercurial/util.py
mercurial/util_win32.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:]
--- 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