# HG changeset patch # User Matt Harbison # Date 2024-12-05 18:11:41 # Node ID 6baf4c6ee14b8d0d7565d96b299cade8b508b801 # Parent e21485f51402affb5ec78458030868bc4fc2f41c fastannotate: stop using the `pycompat.open()` shim diff --git a/hgext/fastannotate/protocol.py b/hgext/fastannotate/protocol.py --- a/hgext/fastannotate/protocol.py +++ b/hgext/fastannotate/protocol.py @@ -10,7 +10,6 @@ import contextlib import os from mercurial.i18n import _ -from mercurial.pycompat import open from mercurial import ( error, extensions, @@ -84,7 +83,7 @@ def _getannotate(repo, proto, path, last for p in [actx.revmappath, actx.linelogpath]: if not os.path.exists(p): continue - with open(p, b'rb') as f: + with open(p, 'rb') as f: content = f.read() vfsbaselen = len(repo.vfs.base + b'/') relpath = p[vfsbaselen:] diff --git a/hgext/fastannotate/revmap.py b/hgext/fastannotate/revmap.py --- a/hgext/fastannotate/revmap.py +++ b/hgext/fastannotate/revmap.py @@ -13,7 +13,6 @@ import os import struct from mercurial.node import hex -from mercurial.pycompat import open from mercurial import ( error as hgerror, ) @@ -163,12 +162,12 @@ class revmap: if not self.path: return if self._lastmaxrev == -1: # write the entire file - with open(self.path, b'wb') as f: + with open(self.path, 'wb') as f: f.write(self.HEADER) for i in range(1, len(self._rev2hsh)): self._writerev(i, f) else: # append incrementally - with open(self.path, b'ab') as f: + with open(self.path, 'ab') as f: for i in range(self._lastmaxrev + 1, len(self._rev2hsh)): self._writerev(i, f) self._lastmaxrev = self.maxrev @@ -181,7 +180,7 @@ class revmap: # which is faster than both LOAD_CONST and LOAD_GLOBAL. flaglen = 1 hshlen = _hshlen - with open(self.path, b'rb') as f: + with open(self.path, 'rb') as f: if f.read(len(self.HEADER)) != self.HEADER: raise error.CorruptedFileError() self.clear(flush=False) @@ -251,7 +250,7 @@ def getlastnode(path): """ hsh = None try: - with open(path, b'rb') as f: + with open(path, 'rb') as f: f.seek(-_hshlen, io.SEEK_END) if f.tell() > len(revmap.HEADER): hsh = f.read(_hshlen)