[PATCH 1 of 4] py3: read/write plain lock file in binary mode

Yuya Nishihara yuya at tcha.org
Tue Mar 6 12:54:46 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1520205676 18000
#      Sun Mar 04 18:21:16 2018 -0500
# Node ID faea088aebdbda2e32e5339cbb6df51283fe2f56
# Parent  4c71a26a4009d88590c9ae3d64a5912fd556d82e
py3: read/write plain lock file in binary mode

A lock file shouldn't contain '\n', so this isn't a BC.

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -373,6 +373,7 @@ test-subrepo-deep-nested-change.t
 test-subrepo.t
 test-symlinks.t
 test-tag.t
+test-tags.t
 test-treemanifest.t
 test-unamend.t
 test-uncommit.t
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1689,7 +1689,8 @@ def makelock(info, pathname):
     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)
 
@@ -1701,7 +1702,7 @@ def readlock(pathname):
             raise
     except AttributeError: # no symlink in os
         pass
-    fp = posixfile(pathname)
+    fp = posixfile(pathname, 'rb')
     r = fp.read()
     fp.close()
     return r


More information about the Mercurial-devel mailing list