py3: read/write plain lock file in binary mode
authorYuya Nishihara <yuya@tcha.org>
Sun, 04 Mar 2018 18:21:16 -0500
changeset 36783 1fbbb8e83392
parent 36782 86ba6e3eba4e
child 36784 e3732c3ab92d
py3: read/write plain lock file in binary mode A lock file shouldn't contain '\n', so this isn't a BC.
contrib/python3-whitelist
mercurial/util.py
--- a/contrib/python3-whitelist	Mon Mar 05 12:31:08 2018 -0500
+++ b/contrib/python3-whitelist	Sun Mar 04 18:21:16 2018 -0500
@@ -373,6 +373,7 @@
 test-subrepo.t
 test-symlinks.t
 test-tag.t
+test-tags.t
 test-treemanifest.t
 test-unamend.t
 test-uncommit.t
--- a/mercurial/util.py	Mon Mar 05 12:31:08 2018 -0500
+++ b/mercurial/util.py	Sun Mar 04 18:21:16 2018 -0500
@@ -1685,7 +1685,8 @@
     except AttributeError: # no symlink in os
         pass
 
-    ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL)
+    flags = os.O_CREAT | os.O_WRONLY | os.O_EXCL | getattr(os, 'O_BINARY', 0)
+    ld = os.open(pathname, flags)
     os.write(ld, info)
     os.close(ld)
 
@@ -1697,7 +1698,7 @@
             raise
     except AttributeError: # no symlink in os
         pass
-    fp = posixfile(pathname)
+    fp = posixfile(pathname, 'rb')
     r = fp.read()
     fp.close()
     return r