Mercurial > public > mercurial-scm > hg
changeset 52389:aa3261b40492
largefiles: stop using the `pycompat.open()` shim
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 05 Dec 2024 13:08:04 -0500 |
parents | aa31c8566fb8 |
children | e21485f51402 |
files | hgext/largefiles/lfutil.py hgext/largefiles/localstore.py hgext/largefiles/overrides.py hgext/largefiles/proto.py |
diffstat | 4 files changed, 7 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py Thu Dec 05 13:00:59 2024 -0500 +++ b/hgext/largefiles/lfutil.py Thu Dec 05 13:08:04 2024 -0500 @@ -17,7 +17,6 @@ from mercurial.i18n import _ from mercurial.node import hex -from mercurial.pycompat import open from mercurial import ( dirstate, @@ -75,7 +74,7 @@ util.oslink(src, dest) except OSError: # if hardlinks fail, fallback on atomic copy - with open(src, b'rb') as srcf, util.atomictempfile(dest) as dstf: + with open(src, 'rb') as srcf, util.atomictempfile(dest) as dstf: for chunk in util.filechunkiter(srcf): dstf.write(chunk) os.chmod(dest, os.stat(src).st_mode) @@ -328,7 +327,7 @@ wvfs.makedirs(wvfs.dirname(wvfs.join(filename))) # The write may fail before the file is fully written, but we # don't use atomic writes in the working copy. - with open(path, b'rb') as srcfd, wvfs(filename, b'wb') as destfd: + with open(path, 'rb') as srcfd, wvfs(filename, b'wb') as destfd: gothash = copyandhash(util.filechunkiter(srcfd), destfd) if gothash != hash: repo.ui.warn( @@ -369,7 +368,7 @@ link(usercachepath(repo.ui, hash), storepath(repo, hash)) else: util.makedirs(os.path.dirname(storepath(repo, hash))) - with open(file, b'rb') as srcf: + with open(file, 'rb') as srcf: with util.atomictempfile( storepath(repo, hash), createmode=repo.store.createmode ) as dstf: @@ -489,7 +488,7 @@ def hashfile(file): if not os.path.exists(file): return b'' - with open(file, b'rb') as fd: + with open(file, 'rb') as fd: return hexsha1(fd)
--- a/hgext/largefiles/localstore.py Thu Dec 05 13:00:59 2024 -0500 +++ b/hgext/largefiles/localstore.py Thu Dec 05 13:08:04 2024 -0500 @@ -11,7 +11,6 @@ from __future__ import annotations from mercurial.i18n import _ -from mercurial.pycompat import open from mercurial import util from . import ( @@ -46,7 +45,7 @@ raise basestore.StoreError( filename, hash, self.url, _(b"can't get file locally") ) - with open(path, b'rb') as fd: + with open(path, 'rb') as fd: return lfutil.copyandhash(util.filechunkiter(fd), tmpfile) def _verifyfiles(self, contents, filestocheck):
--- a/hgext/largefiles/overrides.py Thu Dec 05 13:00:59 2024 -0500 +++ b/hgext/largefiles/overrides.py Thu Dec 05 13:08:04 2024 -0500 @@ -19,8 +19,6 @@ from mercurial.i18n import _ -from mercurial.pycompat import open - from mercurial.hgweb import webcommands from mercurial import ( @@ -1829,7 +1827,7 @@ % lf ) path = lfutil.usercachepath(repo.ui, hash) - with open(path, b"rb") as fpin: + with open(path, "rb") as fpin: for chunk in util.filechunkiter(fpin): fp.write(chunk) err = 0
--- a/hgext/largefiles/proto.py Thu Dec 05 13:00:59 2024 -0500 +++ b/hgext/largefiles/proto.py Thu Dec 05 13:08:04 2024 -0500 @@ -8,7 +8,6 @@ import os from mercurial.i18n import _ -from mercurial.pycompat import open from mercurial import ( error, @@ -72,7 +71,7 @@ raise error.Abort( _(b'requested largefile %s not present in cache') % sha ) - f = open(filename, b'rb') + f = open(filename, 'rb') length = os.fstat(f.fileno())[6] # Since we can't set an HTTP content-length header here, and