[PATCH 09 of 11] win32: realpath and normcase with win32 functions

Simon Heimberg simohe at besonet.ch
Fri Aug 7 14:43:07 CDT 2009


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1248871445 -7200
# Node ID 7111ac2bf7c978859746e3ab4f2f92c7d9b8fae7
# Parent  675061c3cf9196402db8602159c4f7943fc69231
win32: realpath and normcase with win32 functions

diff -r 675061c3cf91 -r 7111ac2bf7c9 mercurial/win32.py
--- a/mercurial/win32.py	Fre Aug 07 21:05:53 2009 +0200
+++ b/mercurial/win32.py	Mit Jul 29 14:44:05 2009 +0200
@@ -142,3 +142,19 @@
         win32process.ExitProcess(1)
     win32api.SetConsoleCtrlHandler(handler)
 
+def realpath(path, root):
+    '''
+    Returns the true, canonical file system path equivalent to the given
+    path.
+    '''
+    fullpath = win32api.GetFullPathName(path)
+    # fullpath is absolute, normalized, some folding done (remove trailing dot and space)
+
+    try:
+        return win32api.GetLongPathName(fullpath)
+    except pywintypes.error:
+        # file does not exist
+        return os.path.normcase(fullpath)
+
+def normcase(path):
+    return os.path.normcase(win32api.GetFullPathName(path))


More information about the Mercurial-devel mailing list