Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/posix.py @ 15353:ab600a25dfc0 stable
posix: workaround for os.path.realpath bug in Python 2.4.1 and before
os.path.realpath didn't resolve symlinks that were the first component of
the path, see http://bugs.python.org/issue1213894
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 24 Oct 2011 13:32:23 +0200 |
parents | 8413916df816 |
children | 6eff984d8e76 |
comparison
equal
deleted
inserted
replaced
15352:b74f74b482d8 | 15353:ab600a25dfc0 |
---|---|
197 | 197 |
198 try: | 198 try: |
199 return fcntl.fcntl(fd, F_GETPATH, '\0' * 1024).rstrip('\0') | 199 return fcntl.fcntl(fd, F_GETPATH, '\0' * 1024).rstrip('\0') |
200 finally: | 200 finally: |
201 os.close(fd) | 201 os.close(fd) |
202 elif sys.version_info < (2, 4, 2, 'final'): | |
203 # Workaround for http://bugs.python.org/issue1213894 (os.path.realpath | |
204 # didn't resolve symlinks that were the first component of the path.) | |
205 def realpath(path): | |
206 if os.path.isabs(path): | |
207 return os.path.realpath(path) | |
208 else: | |
209 return os.path.realpath('./' + path) | |
202 else: | 210 else: |
203 # Fallback to the likely inadequate Python builtin function. | 211 # Fallback to the likely inadequate Python builtin function. |
204 realpath = os.path.realpath | 212 realpath = os.path.realpath |
205 | 213 |
206 def shellquote(s): | 214 def shellquote(s): |