# HG changeset patch # User Matt Harbison # Date 1537924572 14400 # Node ID 5fe0b880200e006006322c52ccd623ef1daa1469 # Parent 803b7569c9eab3d98b952878777e5dae19451658 py3: convert os.readlink() path to native strings on Windows Windows insisted that it needs to be str. I skipped the stuff in the posix module, and left `tests/f` and `run-tests.py` alone for now. diff -r 803b7569c9ea -r 5fe0b880200e hgext/convert/gnuarch.py --- a/hgext/convert/gnuarch.py Sat Sep 29 02:02:35 2018 -0400 +++ b/hgext/convert/gnuarch.py Tue Sep 25 21:16:12 2018 -0400 @@ -223,7 +223,7 @@ def _getfile(self, name, rev): mode = os.lstat(os.path.join(self.tmppath, name)).st_mode if stat.S_ISLNK(mode): - data = os.readlink(os.path.join(self.tmppath, name)) + data = util.readlink(os.path.join(self.tmppath, name)) if mode: mode = 'l' else: diff -r 803b7569c9ea -r 5fe0b880200e mercurial/posix.py --- a/mercurial/posix.py Sat Sep 29 02:02:35 2018 -0400 +++ b/mercurial/posix.py Tue Sep 25 21:16:12 2018 -0400 @@ -43,6 +43,7 @@ def oslink(src, dst): raise OSError(errno.EINVAL, 'hardlinks not supported: %s to %s' % (src, dst)) +readlink = os.readlink unlink = os.unlink rename = os.rename removedirs = os.removedirs diff -r 803b7569c9ea -r 5fe0b880200e mercurial/util.py --- a/mercurial/util.py Sat Sep 29 02:02:35 2018 -0400 +++ b/mercurial/util.py Tue Sep 25 21:16:12 2018 -0400 @@ -112,6 +112,7 @@ pconvert = platform.pconvert poll = platform.poll posixfile = platform.posixfile +readlink = platform.readlink rename = platform.rename removedirs = platform.removedirs samedevice = platform.samedevice @@ -1841,7 +1842,7 @@ def readlock(pathname): try: - return os.readlink(pathname) + return readlink(pathname) except OSError as why: if why.errno not in (errno.EINVAL, errno.ENOSYS): raise diff -r 803b7569c9ea -r 5fe0b880200e mercurial/vfs.py --- a/mercurial/vfs.py Sat Sep 29 02:02:35 2018 -0400 +++ b/mercurial/vfs.py Tue Sep 25 21:16:12 2018 -0400 @@ -206,7 +206,7 @@ return util.rename(srcpath, dstpath) def readlink(self, path): - return os.readlink(self.join(path)) + return util.readlink(self.join(path)) def removedirs(self, path=None): """Remove a leaf directory and all empty intermediate ones diff -r 803b7569c9ea -r 5fe0b880200e mercurial/windows.py --- a/mercurial/windows.py Sat Sep 29 02:02:35 2018 -0400 +++ b/mercurial/windows.py Tue Sep 25 21:16:12 2018 -0400 @@ -519,6 +519,9 @@ If gid is None, return the name of the current group.""" return None +def readlink(pathname): + return pycompat.fsencode(os.readlink(pycompat.fsdecode(pathname))) + def removedirs(name): """special version of os.removedirs that does not remove symlinked directories or junction points if they actually contain files"""