[PATCH 03 of 11] util: use util.fspath as fallback for realpath

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


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1249656991 -7200
# Node ID 6aad3d33602f990c179f901df3474babf784fc84
# Parent  2c63a9b4845fbdee8a2def68e0f43dac69146089
util: use util.fspath as fallback for realpath

delete fallback implementations of realpath in posix and windows
introduce root argument

diff -r 2c63a9b4845f -r 6aad3d33602f mercurial/posix.py
--- a/mercurial/posix.py	Fre Aug 07 15:40:51 2009 +0200
+++ b/mercurial/posix.py	Fre Aug 07 16:56:31 2009 +0200
@@ -105,7 +105,7 @@
     return path
 
 if sys.platform == 'darwin':
-    def realpath(path):
+    def realpath(path, root):
         '''
         Returns the true, canonical file system path equivalent to the given
         path.
@@ -138,9 +138,6 @@
             return fcntl.fcntl(fd, F_GETPATH, '\0' * 1024).rstrip('\0')
         finally:
             os.close(fd)
-else:
-    # Fallback to the likely inadequate Python builtin function.
-    realpath = os.path.realpath
 
 def shellquote(s):
     if os.sys.platform == 'OpenVMS':
diff -r 2c63a9b4845f -r 6aad3d33602f mercurial/util.py
--- a/mercurial/util.py	Fre Aug 07 15:40:51 2009 +0200
+++ b/mercurial/util.py	Fre Aug 07 16:56:31 2009 +0200
@@ -570,6 +570,13 @@
 def lookup_reg(key, name=None, scope=None):
     return None
 
+def realpath(path, root):
+    '''
+    Returns the true, canonical file system path equivalent to the given
+    path.
+    '''
+    return fspath(path, root)
+
 if os.name == 'nt':
     from windows import *
 else:
diff -r 2c63a9b4845f -r 6aad3d33602f mercurial/windows.py
--- a/mercurial/windows.py	Fre Aug 07 15:40:51 2009 +0200
+++ b/mercurial/windows.py	Fre Aug 07 16:56:31 2009 +0200
@@ -126,15 +126,6 @@
 def normpath(path):
     return pconvert(os.path.normpath(path))
 
-def realpath(path):
-    '''
-    Returns the true, canonical file system path equivalent to the given
-    path.
-    '''
-    # TODO: There may be a more clever way to do this that also handles other,
-    # less common file systems.
-    return os.path.normpath(os.path.normcase(os.path.realpath(path)))
-
 def samestat(s1, s2):
     return False
 


More information about the Mercurial-devel mailing list