# HG changeset patch # User Pulkit Goyal # Date 2018-11-13 15:08:55 # Node ID aa588bf40a0800c8a408a7e5a941923d73adb607 # Parent 9769e0f6ffe098dd19ebd799e876078f44bced61 py3: add b suffix to make sure file is opened in bytes mode Differential Revision: https://phab.mercurial-scm.org/D5263 diff --git a/hgext/remotefilelog/basepack.py b/hgext/remotefilelog/basepack.py --- a/hgext/remotefilelog/basepack.py +++ b/hgext/remotefilelog/basepack.py @@ -373,8 +373,8 @@ class mutablebasepack(versionmixin): 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 diff --git a/hgext/remotefilelog/basestore.py b/hgext/remotefilelog/basestore.py --- a/hgext/remotefilelog/basestore.py +++ b/hgext/remotefilelog/basestore.py @@ -255,7 +255,7 @@ class basestore(object): 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 @@ class basestore(object): 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") diff --git a/hgext/remotefilelog/debugcommands.py b/hgext/remotefilelog/debugcommands.py --- a/hgext/remotefilelog/debugcommands.py +++ b/hgext/remotefilelog/debugcommands.py @@ -176,7 +176,7 @@ def _decompressblob(raw): def parsefileblob(path, decompress): raw = None - f = open(path, "r") + f = open(path, "rb") try: raw = f.read() finally: diff --git a/hgext/remotefilelog/fileserverclient.py b/hgext/remotefilelog/fileserverclient.py --- a/hgext/remotefilelog/fileserverclient.py +++ b/hgext/remotefilelog/fileserverclient.py @@ -482,7 +482,7 @@ class fileserverclient(object): 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, diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py --- a/hgext/remotefilelog/remotefilelogserver.py +++ b/hgext/remotefilelog/remotefilelogserver.py @@ -234,7 +234,7 @@ def _loadfileblob(repo, cachepath, path, 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 @@ def _loadfileblob(repo, cachepath, path, finally: os.umask(oldumask) else: - with open(filecachepath, "r") as f: + with open(filecachepath, "rb") as f: text = f.read() return text