Submitter | Christian Ebert |
---|---|
Date | Dec. 29, 2013, 1:57 p.m. |
Message ID | <716491387f2aead12b9a.1388325476@1.0.0.127.in-addr.arpa> |
Download | mbox | patch |
Permalink | /patch/3240/ |
State | Accepted |
Commit | a6014018ec2846070e5e8eb3c4235199df686258 |
Headers | show |
Comments
On Sun, Dec 29, 2013 at 01:57:56PM +0000, Christian Ebert wrote: > # HG changeset patch > # User Christian Ebert <blacktrash@gmx.net> > # Date 1388325244 0 > # Sun Dec 29 13:54:04 2013 +0000 > # Node ID 716491387f2aead12b9a3be1f67c2f3748719e78 > # Parent 532fa12033e1ddf9cbe0d5507263a2c9cfbfddf9 > util: remove unused realpath (issue4063) queued, thanks > > util.realpath was in use for only 5 days from dbdb777502dc > until it was backed out in c519cd8f0169 because it caused > issue3077 and issue3071. > > diff --git a/mercurial/posix.py b/mercurial/posix.py > --- a/mercurial/posix.py > +++ b/mercurial/posix.py > @@ -197,7 +197,6 @@ > return path.lower() > > if sys.platform == 'darwin': > - import fcntl # only needed on darwin, missing on jython > > def normcase(path): > ''' > @@ -265,51 +264,6 @@ > # Decompose then lowercase (HFS+ technote specifies lower) > return unicodedata.normalize('NFD', u).lower().encode('utf-8') > > - def realpath(path): > - ''' > - Returns the true, canonical file system path equivalent to the given > - path. > - > - Equivalent means, in this case, resulting in the same, unique > - file system link to the path. Every file system entry, whether a file, > - directory, hard link or symbolic link or special, will have a single > - path preferred by the system, but may allow multiple, differing path > - lookups to point to it. > - > - Most regular UNIX file systems only allow a file system entry to be > - looked up by its distinct path. Obviously, this does not apply to case > - insensitive file systems, whether case preserving or not. The most > - complex issue to deal with is file systems transparently reencoding the > - path, such as the non-standard Unicode normalisation required for HFS+ > - and HFSX. > - ''' > - # Constants copied from /usr/include/sys/fcntl.h > - F_GETPATH = 50 > - O_SYMLINK = 0x200000 > - > - try: > - fd = os.open(path, O_SYMLINK) > - except OSError, err: > - if err.errno == errno.ENOENT: > - return path > - raise > - > - try: > - return fcntl.fcntl(fd, F_GETPATH, '\0' * 1024).rstrip('\0') > - finally: > - os.close(fd) > -elif sys.version_info < (2, 4, 2, 'final'): > - # Workaround for http://bugs.python.org/issue1213894 (os.path.realpath > - # didn't resolve symlinks that were the first component of the path.) > - def realpath(path): > - if os.path.isabs(path): > - return os.path.realpath(path) > - else: > - return os.path.realpath('./' + path) > -else: > - # Fallback to the likely inadequate Python builtin function. > - realpath = os.path.realpath > - > if sys.platform == 'cygwin': > # workaround for cygwin, in which mount point part of path is > # treated as case sensitive, even though underlying NTFS is case > diff --git a/mercurial/util.py b/mercurial/util.py > --- a/mercurial/util.py > +++ b/mercurial/util.py > @@ -52,7 +52,6 @@ > popen = platform.popen > posixfile = platform.posixfile > quotecommand = platform.quotecommand > -realpath = platform.realpath > rename = platform.rename > samedevice = platform.samedevice > samefile = platform.samefile > diff --git a/mercurial/windows.py b/mercurial/windows.py > --- a/mercurial/windows.py > +++ b/mercurial/windows.py > @@ -133,15 +133,6 @@ > def normcase(path): > return encoding.upper(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(normcase(os.path.realpath(path))) > - > def samestat(s1, s2): > return False > > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -197,7 +197,6 @@ return path.lower() if sys.platform == 'darwin': - import fcntl # only needed on darwin, missing on jython def normcase(path): ''' @@ -265,51 +264,6 @@ # Decompose then lowercase (HFS+ technote specifies lower) return unicodedata.normalize('NFD', u).lower().encode('utf-8') - def realpath(path): - ''' - Returns the true, canonical file system path equivalent to the given - path. - - Equivalent means, in this case, resulting in the same, unique - file system link to the path. Every file system entry, whether a file, - directory, hard link or symbolic link or special, will have a single - path preferred by the system, but may allow multiple, differing path - lookups to point to it. - - Most regular UNIX file systems only allow a file system entry to be - looked up by its distinct path. Obviously, this does not apply to case - insensitive file systems, whether case preserving or not. The most - complex issue to deal with is file systems transparently reencoding the - path, such as the non-standard Unicode normalisation required for HFS+ - and HFSX. - ''' - # Constants copied from /usr/include/sys/fcntl.h - F_GETPATH = 50 - O_SYMLINK = 0x200000 - - try: - fd = os.open(path, O_SYMLINK) - except OSError, err: - if err.errno == errno.ENOENT: - return path - raise - - try: - return fcntl.fcntl(fd, F_GETPATH, '\0' * 1024).rstrip('\0') - finally: - os.close(fd) -elif sys.version_info < (2, 4, 2, 'final'): - # Workaround for http://bugs.python.org/issue1213894 (os.path.realpath - # didn't resolve symlinks that were the first component of the path.) - def realpath(path): - if os.path.isabs(path): - return os.path.realpath(path) - else: - return os.path.realpath('./' + path) -else: - # Fallback to the likely inadequate Python builtin function. - realpath = os.path.realpath - if sys.platform == 'cygwin': # workaround for cygwin, in which mount point part of path is # treated as case sensitive, even though underlying NTFS is case diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -52,7 +52,6 @@ popen = platform.popen posixfile = platform.posixfile quotecommand = platform.quotecommand -realpath = platform.realpath rename = platform.rename samedevice = platform.samedevice samefile = platform.samefile diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -133,15 +133,6 @@ def normcase(path): return encoding.upper(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(normcase(os.path.realpath(path))) - def samestat(s1, s2): return False