Mercurial > public > mercurial-scm > hg
changeset 52383:51df2bf7c40b
remotefilelog: stop using the `pycompat.open()` shim
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 05 Dec 2024 12:46:21 -0500 |
parents | ea79fa8a36ae |
children | d075b300504b |
files | hgext/remotefilelog/__init__.py hgext/remotefilelog/basestore.py hgext/remotefilelog/debugcommands.py hgext/remotefilelog/remotefilelogserver.py hgext/remotefilelog/shallowutil.py |
diffstat | 5 files changed, 10 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/remotefilelog/__init__.py Thu Dec 05 12:40:16 2024 -0500 +++ b/hgext/remotefilelog/__init__.py Thu Dec 05 12:46:21 2024 -0500 @@ -136,7 +136,6 @@ wdirrev, ) from mercurial.i18n import _ -from mercurial.pycompat import open from mercurial import ( changegroup, changelog, @@ -868,7 +867,7 @@ ui.warn(_(b"no known cache at %s\n") % cachepath) return - reposfile = open(repospath, b'rb') + reposfile = open(repospath, 'rb') repos = {r[:-1] for r in reposfile.readlines()} reposfile.close() @@ -942,7 +941,7 @@ # write list of valid repos back oldumask = os.umask(0o002) try: - reposfile = open(repospath, b'wb') + reposfile = open(repospath, 'wb') reposfile.writelines([(b"%s\n" % r) for r in validrepos]) reposfile.close() finally: @@ -1010,7 +1009,7 @@ fname = repo.vfs.join(b'lastprefetch') ready = False - with open(fname, b'a'): + with open(fname, 'a'): # the with construct above is used to avoid race conditions modtime = os.path.getmtime(fname) if (time.time() - modtime) > timeout:
--- a/hgext/remotefilelog/basestore.py Thu Dec 05 12:40:16 2024 -0500 +++ b/hgext/remotefilelog/basestore.py Thu Dec 05 12:46:21 2024 -0500 @@ -7,7 +7,6 @@ from mercurial.i18n import _ from mercurial.node import bin, hex -from mercurial.pycompat import open from mercurial import ( error, pycompat, @@ -224,7 +223,7 @@ data = shallowutil.readfile(filepath) if self._validatecache and not self._validatedata(data, filepath): if self._validatecachelog: - with open(self._validatecachelog, b'ab+') as f: + with open(self._validatecachelog, 'ab+') as f: f.write(b"corrupt %s during read\n" % filepath) os.rename(filepath, filepath + b".corrupt") raise KeyError(b"corrupt local cache file %s" % filepath) @@ -268,7 +267,7 @@ they want to be kept alive in the store. """ repospath = os.path.join(self._path, b"repos") - with open(repospath, b'ab') as reposfile: + with open(repospath, 'ab') as reposfile: reposfile.write(os.path.dirname(path) + b"\n") repospathstat = os.stat(repospath) @@ -276,14 +275,14 @@ os.chmod(repospath, 0o0664) def _validatekey(self, path, action): - with open(path, b'rb') as f: + with open(path, 'rb') as f: data = f.read() if self._validatedata(data, path): return True if self._validatecachelog: - with open(self._validatecachelog, b'ab+') as f: + with open(self._validatecachelog, 'ab+') as f: f.write(b"corrupt %s during %s\n" % (path, action)) os.rename(path, path + b".corrupt")
--- a/hgext/remotefilelog/debugcommands.py Thu Dec 05 12:40:16 2024 -0500 +++ b/hgext/remotefilelog/debugcommands.py Thu Dec 05 12:46:21 2024 -0500 @@ -17,7 +17,6 @@ short, ) from mercurial.i18n import _ -from mercurial.pycompat import open from mercurial import ( error, filelog, @@ -228,7 +227,7 @@ def parsefileblob(path, decompress): - f = open(path, b"rb") + f = open(path, "rb") try: raw = f.read() finally:
--- a/hgext/remotefilelog/remotefilelogserver.py Thu Dec 05 12:40:16 2024 -0500 +++ b/hgext/remotefilelog/remotefilelogserver.py Thu Dec 05 12:46:21 2024 -0500 @@ -14,7 +14,6 @@ from mercurial.i18n import _ from mercurial.node import bin, hex -from mercurial.pycompat import open from mercurial import ( changegroup, changelog, @@ -282,7 +281,7 @@ finally: os.umask(oldumask) else: - with open(filecachepath, b"rb") as f: + with open(filecachepath, "rb") as f: text = f.read() return text
--- a/hgext/remotefilelog/shallowutil.py Thu Dec 05 12:40:16 2024 -0500 +++ b/hgext/remotefilelog/shallowutil.py Thu Dec 05 12:46:21 2024 -0500 @@ -14,7 +14,6 @@ import tempfile from mercurial.i18n import _ -from mercurial.pycompat import open from mercurial.node import hex from mercurial import ( error, @@ -322,7 +321,7 @@ def readfile(path): - f = open(path, b'rb') + f = open(path, 'rb') try: result = f.read()