py3: add b suffix to make sure file is opened in bytes mode
Differential Revision: https://phab.mercurial-scm.org/D5263
--- a/hgext/remotefilelog/basepack.py Tue Nov 13 18:08:17 2018 +0300
+++ b/hgext/remotefilelog/basepack.py Tue Nov 13 18:08:55 2018 +0300
@@ -373,8 +373,8 @@
suffix=self.PACKSUFFIX + '-tmp')
self.idxfp, self.idxpath = opener.mkstemp(
suffix=self.INDEXSUFFIX + '-tmp')
- self.packfp = os.fdopen(self.packfp, r'w+')
- self.idxfp = os.fdopen(self.idxfp, r'w+')
+ self.packfp = os.fdopen(self.packfp, r'wb+')
+ self.idxfp = os.fdopen(self.idxfp, r'wb+')
self.sha = hashlib.sha1()
self._closed = False
--- a/hgext/remotefilelog/basestore.py Tue Nov 13 18:08:17 2018 +0300
+++ b/hgext/remotefilelog/basestore.py Tue Nov 13 18:08:55 2018 +0300
@@ -255,7 +255,7 @@
they want to be kept alive in the store.
"""
repospath = os.path.join(self._path, "repos")
- with open(repospath, 'a') as reposfile:
+ with open(repospath, 'ab') as reposfile:
reposfile.write(os.path.dirname(path) + "\n")
repospathstat = os.stat(repospath)
@@ -270,7 +270,7 @@
return True
if self._validatecachelog:
- with open(self._validatecachelog, 'a+') as f:
+ with open(self._validatecachelog, 'ab+') as f:
f.write("corrupt %s during %s\n" % (path, action))
os.rename(path, path + ".corrupt")
--- a/hgext/remotefilelog/debugcommands.py Tue Nov 13 18:08:17 2018 +0300
+++ b/hgext/remotefilelog/debugcommands.py Tue Nov 13 18:08:55 2018 +0300
@@ -176,7 +176,7 @@
def parsefileblob(path, decompress):
raw = None
- f = open(path, "r")
+ f = open(path, "rb")
try:
raw = f.read()
finally:
--- a/hgext/remotefilelog/fileserverclient.py Tue Nov 13 18:08:17 2018 +0300
+++ b/hgext/remotefilelog/fileserverclient.py Tue Nov 13 18:08:55 2018 +0300
@@ -482,7 +482,7 @@
def close(self):
if fetches:
- msg = ("%s files fetched over %d fetches - " +
+ msg = ("%d files fetched over %d fetches - " +
"(%d misses, %0.2f%% hit ratio) over %0.2fs\n") % (
fetched,
fetches,
--- a/hgext/remotefilelog/remotefilelogserver.py Tue Nov 13 18:08:17 2018 +0300
+++ b/hgext/remotefilelog/remotefilelogserver.py Tue Nov 13 18:08:55 2018 +0300
@@ -234,7 +234,7 @@
f = None
try:
- f = util.atomictempfile(filecachepath, "w")
+ f = util.atomictempfile(filecachepath, "wb")
f.write(text)
except (IOError, OSError):
# Don't abort if the user only has permission to read,
@@ -246,7 +246,7 @@
finally:
os.umask(oldumask)
else:
- with open(filecachepath, "r") as f:
+ with open(filecachepath, "rb") as f:
text = f.read()
return text