# HG changeset patch # User Matt Harbison # Date 2024-12-05 17:46:21 # Node ID 51df2bf7c40b56a4db00dd171a3044d3b275b823 # Parent ea79fa8a36ae4970a4715385c123e0ed4eebc411 remotefilelog: stop using the `pycompat.open()` shim diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py --- a/hgext/remotefilelog/__init__.py +++ b/hgext/remotefilelog/__init__.py @@ -136,7 +136,6 @@ from mercurial.node import ( wdirrev, ) from mercurial.i18n import _ -from mercurial.pycompat import open from mercurial import ( changegroup, changelog, @@ -868,7 +867,7 @@ def gcclient(ui, cachepath): 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 @@ def gcclient(ui, cachepath): # 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 @@ def readytofetch(repo): 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: diff --git a/hgext/remotefilelog/basestore.py b/hgext/remotefilelog/basestore.py --- a/hgext/remotefilelog/basestore.py +++ b/hgext/remotefilelog/basestore.py @@ -7,7 +7,6 @@ import time from mercurial.i18n import _ from mercurial.node import bin, hex -from mercurial.pycompat import open from mercurial import ( error, pycompat, @@ -224,7 +223,7 @@ class basestore: 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 @@ class basestore: 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 @@ class basestore: 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") diff --git a/hgext/remotefilelog/debugcommands.py b/hgext/remotefilelog/debugcommands.py --- a/hgext/remotefilelog/debugcommands.py +++ b/hgext/remotefilelog/debugcommands.py @@ -17,7 +17,6 @@ from mercurial.node import ( short, ) from mercurial.i18n import _ -from mercurial.pycompat import open from mercurial import ( error, filelog, @@ -228,7 +227,7 @@ def _decompressblob(raw): def parsefileblob(path, decompress): - f = open(path, b"rb") + f = open(path, "rb") try: raw = f.read() finally: diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py --- a/hgext/remotefilelog/remotefilelogserver.py +++ b/hgext/remotefilelog/remotefilelogserver.py @@ -14,7 +14,6 @@ import zlib from mercurial.i18n import _ from mercurial.node import bin, hex -from mercurial.pycompat import open from mercurial import ( changegroup, changelog, @@ -282,7 +281,7 @@ def _loadfileblob(repo, cachepath, path, finally: os.umask(oldumask) else: - with open(filecachepath, b"rb") as f: + with open(filecachepath, "rb") as f: text = f.read() return text diff --git a/hgext/remotefilelog/shallowutil.py b/hgext/remotefilelog/shallowutil.py --- a/hgext/remotefilelog/shallowutil.py +++ b/hgext/remotefilelog/shallowutil.py @@ -14,7 +14,6 @@ import struct 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 ancestormap(raw): def readfile(path): - f = open(path, b'rb') + f = open(path, 'rb') try: result = f.read()