Mercurial > public > mercurial-scm > hg-stable
changeset 52670:4cb75772818d
pyupgrade: drop the quoting around type annotations
This is the `typing_pep563` fixer in `pyupgrade`. Quoting to delay evaluation
hasn't been necessary since adding `from __future__ import annotations` in
1c5810ce737e.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 06 Jan 2025 00:30:55 -0500 |
parents | e627cc25b6f3 |
children | cb769c0ffe35 |
files | hgext/convert/common.py hgext/convert/convcmd.py hgext/convert/filemap.py hgext/extdiff.py hgext/git/manifest.py mercurial/archival.py mercurial/branchmap.py mercurial/bundle2.py mercurial/cmdutil.py mercurial/diffutil.py mercurial/dirstatemap.py mercurial/hg.py mercurial/interfaces/repository.py mercurial/lock.py mercurial/manifest.py mercurial/phases.py mercurial/policy.py mercurial/revlog.py mercurial/scmposix.py mercurial/scmutil.py mercurial/scmwindows.py mercurial/shelve.py mercurial/statprof.py mercurial/store.py mercurial/subrepoutil.py mercurial/ui.py mercurial/upgrade_utils/actions.py mercurial/url.py mercurial/utils/resourceutil.py mercurial/utils/urlutil.py mercurial/wireprotov1peer.py |
diffstat | 31 files changed, 142 insertions(+), 146 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/common.py Sun Jan 05 22:26:16 2025 -0500 +++ b/hgext/convert/common.py Mon Jan 06 00:30:55 2025 -0500 @@ -180,7 +180,7 @@ def __init__( self, - ui: "uimod.ui", + ui: uimod.ui, repotype: bytes, path: Optional[bytes] = None, revs=None, @@ -336,7 +336,7 @@ class converter_sink: """Conversion sink (target) interface""" - def __init__(self, ui: "uimod.ui", repotype: bytes, path: bytes) -> None: + def __init__(self, ui: uimod.ui, repotype: bytes, path: bytes) -> None: """Initialize conversion sink (or raise NoRepo("message") exception if path is not a valid repository) @@ -430,7 +430,7 @@ class commandline: - def __init__(self, ui: "uimod.ui", command: bytes) -> None: + def __init__(self, ui: uimod.ui, command: bytes) -> None: self.ui = ui self.command = command @@ -561,7 +561,7 @@ class mapfile(dict): - def __init__(self, ui: "uimod.ui", path: bytes) -> None: + def __init__(self, ui: uimod.ui, path: bytes) -> None: super().__init__() self.ui = ui self.path = path
--- a/hgext/convert/convcmd.py Sun Jan 05 22:26:16 2025 -0500 +++ b/hgext/convert/convcmd.py Mon Jan 06 00:30:55 2025 -0500 @@ -72,7 +72,7 @@ orig_encoding: bytes = b'ascii' -def readauthormap(ui: "uimod.ui", authorfile, authors=None): +def readauthormap(ui: uimod.ui, authorfile, authors=None): if authors is None: authors = {} with open(authorfile, 'rb') as afile: @@ -162,7 +162,7 @@ ] -def convertsource(ui: "uimod.ui", path: bytes, type: bytes, revs): +def convertsource(ui: uimod.ui, path: bytes, type: bytes, revs): exceptions = [] if type and type not in [s[0] for s in source_converters]: raise error.Abort(_(b'%s: invalid source repository type') % type) @@ -179,7 +179,7 @@ def convertsink( - ui: "uimod.ui", path: bytes, type: bytes + ui: uimod.ui, path: bytes, type: bytes ) -> Union[hgconvert.mercurial_sink, subversion.svn_sink]: if type and type not in [s[0] for s in sink_converters]: raise error.Abort(_(b'%s: invalid destination repository type') % type) @@ -195,9 +195,7 @@ class progresssource: - def __init__( - self, ui: "uimod.ui", source, filecount: Optional[int] - ) -> None: + def __init__(self, ui: uimod.ui, source, filecount: Optional[int]) -> None: self.ui = ui self.source = source self.progress = ui.makeprogress( @@ -272,7 +270,7 @@ class converter: - def __init__(self, ui: "uimod.ui", source, dest, revmapfile, opts) -> None: + def __init__(self, ui: uimod.ui, source, dest, revmapfile, opts) -> None: self.source = source self.dest = dest self.ui = ui @@ -654,7 +652,7 @@ def convert( - ui: "uimod.ui", src, dest: Optional[bytes] = None, revmapfile=None, **opts + ui: uimod.ui, src, dest: Optional[bytes] = None, revmapfile=None, **opts ) -> None: opts = pycompat.byteskwargs(opts) global orig_encoding
--- a/hgext/convert/filemap.py Sun Jan 05 22:26:16 2025 -0500 +++ b/hgext/convert/filemap.py Mon Jan 06 00:30:55 2025 -0500 @@ -77,7 +77,7 @@ rename: MutableMapping[bytes, bytes] targetprefixes: Optional[Set[bytes]] - def __init__(self, ui: "uimod.ui", path: Optional[bytes] = None) -> None: + def __init__(self, ui: uimod.ui, path: Optional[bytes] = None) -> None: self.ui = ui self.include = {} self.exclude = {} @@ -219,7 +219,7 @@ class filemap_source(common.converter_source): def __init__( - self, ui: "uimod.ui", baseconverter, filemap: Optional[bytes] + self, ui: uimod.ui, baseconverter, filemap: Optional[bytes] ) -> None: super().__init__(ui, baseconverter.repotype) self.base = baseconverter
--- a/hgext/extdiff.py Sun Jan 05 22:26:16 2025 -0500 +++ b/hgext/extdiff.py Mon Jan 06 00:30:55 2025 -0500 @@ -164,8 +164,8 @@ def snapshot( - ui: "uimod.ui", - repo: "localrepo.localrepository", + ui: uimod.ui, + repo: localrepo.localrepository, files, node: Optional[bytes], tmproot: bytes,
--- a/hgext/git/manifest.py Sun Jan 05 22:26:16 2025 -0500 +++ b/hgext/git/manifest.py Mon Jan 06 00:30:55 2025 -0500 @@ -245,7 +245,7 @@ except KeyError: return b'' - def copy(self) -> 'gittreemanifest': + def copy(self) -> gittreemanifest: return gittreemanifest( self._git_repo, self._tree, dict(self._pending_changes) )
--- a/mercurial/archival.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/archival.py Mon Jan 06 00:30:55 2025 -0500 @@ -282,7 +282,7 @@ def archive( - repo: "localrepo.localrepository", + repo: localrepo.localrepository, dest, # TODO: should be bytes, but could be Callable node, kind: bytes,
--- a/mercurial/branchmap.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/branchmap.py Mon Jan 06 00:30:55 2025 -0500 @@ -202,7 +202,7 @@ def __init__( self, - repo: "localrepo.localrepository", + repo: localrepo.localrepository, entries: Union[ Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]] ] = (), @@ -437,7 +437,7 @@ def __init__( self, - repo: "localrepo.localrepository", + repo: localrepo.localrepository, entries: Union[ Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]] ] = (), @@ -545,7 +545,7 @@ return bcache @classmethod - def _load_header(cls, repo, lineiter) -> "dict[str, Any]": + def _load_header(cls, repo, lineiter) -> dict[str, Any]: raise NotImplementedError def _load_heads(self, repo, lineiter): @@ -788,7 +788,7 @@ _base_filename = b"branch2" @classmethod - def _load_header(cls, repo, lineiter) -> "dict[str, Any]": + def _load_header(cls, repo, lineiter) -> dict[str, Any]: """parse the head of a branchmap file return parameters to pass to a newly created class instance. @@ -1079,7 +1079,7 @@ def __init__( self, - repo: "localrepo.localrepository", + repo: localrepo.localrepository, entries: Union[ Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]] ] = (),
--- a/mercurial/bundle2.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/bundle2.py Mon Jan 06 00:30:55 2025 -0500 @@ -615,7 +615,7 @@ ) -def decodecaps(blob: bytes) -> "Capabilities": +def decodecaps(blob: bytes) -> Capabilities: """decode a bundle2 caps bytes blob into a dictionary The blob is a list of capabilities (one per line) @@ -675,14 +675,14 @@ _magicstring = b'HG20' - def __init__(self, ui, capabilities: "Optional[Capabilities]" = None): + def __init__(self, ui, capabilities: Optional[Capabilities] = None): if capabilities is None: capabilities = {} self.ui = ui self._params = [] self._parts = [] - self.capabilities: "Capabilities" = dict(capabilities) + self.capabilities: Capabilities = dict(capabilities) self._compengine = util.compengines.forbundletype(b'UN') self._compopts = None # If compression is being handled by a consumer of the raw @@ -1625,7 +1625,7 @@ # These are only the static capabilities. # Check the 'getrepocaps' function for the rest. -capabilities: "Capabilities" = { +capabilities: Capabilities = { b'HG20': (), b'bookmarks': (), b'error': (b'abort', b'unsupportedcontent', b'pushraced', b'pushkey'), @@ -1640,7 +1640,7 @@ # TODO: drop the default value for 'role' -def getrepocaps(repo, allowpushback: bool = False, role=None) -> "Capabilities": +def getrepocaps(repo, allowpushback: bool = False, role=None) -> Capabilities: """return the bundle2 capabilities for a given repo Exists to allow extensions (like evolution) to mutate the capabilities. @@ -1689,7 +1689,7 @@ return caps -def bundle2caps(remote) -> "Capabilities": +def bundle2caps(remote) -> Capabilities: """return the bundle capabilities of a peer as dict""" raw = remote.capable(b'bundle2') if not raw and raw != b'': @@ -1698,7 +1698,7 @@ return decodecaps(capsblob) -def obsmarkersversion(caps: "Capabilities"): +def obsmarkersversion(caps: Capabilities): """extract the list of supported obsmarkers versions from a bundle2caps dict""" obscaps = caps.get(b'obsmarkers', ()) return [int(c[1:]) for c in obscaps if c.startswith(b'V')] @@ -1739,7 +1739,7 @@ msg %= count raise error.ProgrammingError(msg) - caps: "Capabilities" = {} + caps: Capabilities = {} if opts.get(b'obsolescence', False): caps[b'obsmarkers'] = (b'V1',) stream_version = opts.get(b'stream', b"")
--- a/mercurial/cmdutil.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/cmdutil.py Mon Jan 06 00:30:55 2025 -0500 @@ -324,7 +324,7 @@ check_at_most_one_arg(opts, first, other) -def resolve_commit_options(ui: "uimod.ui", opts: Dict[str, Any]) -> bool: +def resolve_commit_options(ui: uimod.ui, opts: Dict[str, Any]) -> bool: """modify commit options dict to handle related options The return value indicates that ``rewrite.update-timestamp`` is the reason @@ -1147,7 +1147,7 @@ ctx.sub(s).bailifchanged(hint=hint) -def logmessage(ui: "uimod.ui", opts: Dict[bytes, Any]) -> Optional[bytes]: +def logmessage(ui: uimod.ui, opts: Dict[bytes, Any]) -> Optional[bytes]: """get the log message according to -m and -l option""" check_at_most_one_arg(opts, b'message', b'logfile')
--- a/mercurial/diffutil.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/diffutil.py Mon Jan 06 00:30:55 2025 -0500 @@ -33,7 +33,7 @@ def diffallopts( - ui: "uimod.ui", + ui: uimod.ui, opts: Optional[_Opts] = None, untrusted: bool = False, section: bytes = b'diff', @@ -53,7 +53,7 @@ def difffeatureopts( - ui: "uimod.ui", + ui: uimod.ui, opts: Optional[_Opts] = None, untrusted: bool = False, section: bytes = b'diff',
--- a/mercurial/dirstatemap.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/dirstatemap.py Mon Jan 06 00:30:55 2025 -0500 @@ -62,12 +62,12 @@ _use_dirstate_v2: bool _nodeconstants: typelib.NodeConstants - _ui: "uimod.ui" + _ui: uimod.ui _root: bytes _filename: bytes _nodelen: int _dirtyparents: bool - _docket: Optional["docketmod.DirstateDocket"] + _docket: Optional[docketmod.DirstateDocket] _write_mode: int _pendingmode: Optional[bool] identity: Optional[typelib.CacheStat] @@ -79,7 +79,7 @@ def __init__( self, - ui: "uimod.ui", + ui: uimod.ui, opener, root: bytes, nodeconstants: typelib.NodeConstants, @@ -182,7 +182,7 @@ return b'' @property - def docket(self) -> "docketmod.DirstateDocket": + def docket(self) -> docketmod.DirstateDocket: testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file') if not self._docket: if not self._use_dirstate_v2:
--- a/mercurial/hg.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/hg.py Mon Jan 06 00:30:55 2025 -0500 @@ -1612,7 +1612,7 @@ # Files of interest # Used to check if the repository has changed looking at mtime and size of # these files. -foi: "List[Tuple[str, bytes]]" = [ +foi: List[Tuple[str, bytes]] = [ ('spath', b'00changelog.i'), ('spath', b'phaseroots'), # ! phase can change content at the same size ('spath', b'obsstore'),
--- a/mercurial/interfaces/repository.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/interfaces/repository.py Mon Jan 06 00:30:55 2025 -0500 @@ -1234,7 +1234,7 @@ """Return the flags value for a path (default: empty bytestring).""" @abc.abstractmethod - def copy(self) -> 'imanifestdict': + def copy(self) -> imanifestdict: """Return a copy of this manifest.""" @abc.abstractmethod
--- a/mercurial/lock.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/lock.py Mon Jan 06 00:30:55 2025 -0500 @@ -111,7 +111,7 @@ raiseinterrupt(assertedsigs[0]) -def trylock(ui, vfs, lockname, timeout, warntimeout, *args, **kwargs) -> "lock": +def trylock(ui, vfs, lockname, timeout, warntimeout, *args, **kwargs) -> lock: """return an acquired lock or raise an a LockHeld exception This function is responsible to issue warnings and or debug messages about
--- a/mercurial/manifest.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/manifest.py Mon Jan 06 00:30:55 2025 -0500 @@ -105,11 +105,11 @@ class lazymanifestiter: - def __init__(self, lm: '_LazyManifest') -> None: + def __init__(self, lm: _LazyManifest) -> None: self.pos = 0 self.lm = lm - def __iter__(self) -> 'lazymanifestiter': + def __iter__(self) -> lazymanifestiter: return self def next(self) -> bytes: @@ -130,11 +130,11 @@ class lazymanifestiterentries: - def __init__(self, lm: '_LazyManifest') -> None: + def __init__(self, lm: _LazyManifest) -> None: self.lm = lm self.pos = 0 - def __iter__(self) -> 'lazymanifestiterentries': + def __iter__(self) -> lazymanifestiterentries: return self def next(self) -> Tuple[bytes, bytes, bytes]: @@ -374,7 +374,7 @@ self.extrainfo[:needle] + [0] + self.extrainfo[needle:] ) - def copy(self) -> '_LazyManifest': + def copy(self) -> _LazyManifest: # XXX call _compact like in C? return _lazymanifest( self._nodelen, @@ -454,7 +454,7 @@ return self.data def diff( - self, m2: '_LazyManifest', clean: bool = False + self, m2: _LazyManifest, clean: bool = False ) -> Dict[ bytes, Optional[ @@ -493,7 +493,7 @@ def __len__(self) -> int: return len(self.positions) - def filtercopy(self, filterfn: Callable[[bytes], bool]) -> '_LazyManifest': + def filtercopy(self, filterfn: Callable[[bytes], bool]) -> _LazyManifest: # XXX should be optimized c = _lazymanifest(self._nodelen, b'') for f, n, fl in self.iterentries(): @@ -615,7 +615,7 @@ if not self.hasdir(fn): match.bad(fn, None) - def _matches(self, match: matchmod.basematcher) -> 'manifestdict': + def _matches(self, match: matchmod.basematcher) -> manifestdict: '''generate a new manifest filtered by the match argument''' if match.always(): return self.copy() @@ -634,7 +634,7 @@ def diff( self, - m2: 'manifestdict', + m2: manifestdict, match: Optional[matchmod.basematcher] = None, clean: bool = False, ) -> Dict[ @@ -680,7 +680,7 @@ except KeyError: return b'' - def copy(self) -> 'manifestdict': + def copy(self) -> manifestdict: c = manifestdict(self._nodelen) c._lm = self._lm.copy() return c @@ -849,7 +849,7 @@ class treemanifest: # (repository.imanifestdict) _dir: bytes - _dirs: Dict[bytes, 'treemanifest'] + _dirs: Dict[bytes, treemanifest] _dirty: bool _files: Dict[bytes, bytes] _flags: Dict[bytes, bytes] @@ -865,7 +865,7 @@ self._dirs = {} self._lazydirs: Dict[ bytes, - Tuple[bytes, Callable[[bytes, bytes], 'treemanifest'], bool], + Tuple[bytes, Callable[[bytes, bytes], treemanifest], bool], ] = {} # Using _lazymanifest here is a little slower than plain old dicts self._files = {} @@ -919,7 +919,7 @@ loadlazy(k + b'/') return visit - def _loaddifflazy(self, t1: 'treemanifest', t2: 'treemanifest'): + def _loaddifflazy(self, t1: treemanifest, t2: treemanifest): """load items in t1 and t2 if they're needed for diffing. The criteria currently is: @@ -996,7 +996,7 @@ def iterentries( self, - ) -> Iterator[Tuple[bytes, Union[bytes, 'treemanifest'], bytes]]: + ) -> Iterator[Tuple[bytes, Union[bytes, treemanifest], bytes]]: self._load() self._loadalllazy() for p, n in sorted( @@ -1007,7 +1007,7 @@ else: yield from n.iterentries() - def items(self) -> Iterator[Tuple[bytes, Union[bytes, 'treemanifest']]]: + def items(self) -> Iterator[Tuple[bytes, Union[bytes, treemanifest]]]: self._load() self._loadalllazy() for p, n in sorted( @@ -1176,7 +1176,7 @@ self._flags[f] = flags self._dirty = True - def copy(self) -> 'treemanifest': + def copy(self) -> treemanifest: copy = treemanifest(self.nodeconstants, self._dir) copy._node = self._node copy._dirty = self._dirty @@ -1202,7 +1202,7 @@ return copy def filesnotin( - self, m2: 'treemanifest', match: Optional[matchmod.basematcher] = None + self, m2: treemanifest, match: Optional[matchmod.basematcher] = None ) -> Set[bytes]: '''Set of files in this manifest that are not in the other''' if match and not match.always(): @@ -1293,13 +1293,13 @@ if not visit or p[:-1] in visit: yield from self._dirs[p]._walk(match) - def _matches(self, match: matchmod.basematcher) -> 'treemanifest': + def _matches(self, match: matchmod.basematcher) -> treemanifest: """recursively generate a new manifest filtered by the match argument.""" if match.always(): return self.copy() return self._matches_inner(match) - def _matches_inner(self, match: matchmod.basematcher) -> 'treemanifest': + def _matches_inner(self, match: matchmod.basematcher) -> treemanifest: if match.always(): return self.copy() @@ -1347,7 +1347,7 @@ def diff( self, - m2: 'treemanifest', + m2: treemanifest, match: Optional[matchmod.basematcher] = None, clean: bool = False, ) -> Dict[ @@ -1416,13 +1416,13 @@ _iterativediff(t1, t2, stackls) return result - def unmodifiedsince(self, m2: 'treemanifest') -> bool: + def unmodifiedsince(self, m2: treemanifest) -> bool: return not self._dirty and not m2._dirty and self._node == m2._node def parse( self, text: bytes, - readsubtree: Callable[[bytes, bytes], 'treemanifest'], + readsubtree: Callable[[bytes, bytes], treemanifest], ) -> None: selflazy = self._lazydirs for f, n, fl in _parse(self._nodelen, text): @@ -1465,7 +1465,7 @@ def read( self, gettext: Callable[[], ByteString], - readsubtree: Callable[[bytes, bytes], 'treemanifest'], + readsubtree: Callable[[bytes, bytes], treemanifest], ) -> None: def _load_for_read(s): s.parse(gettext(), readsubtree) @@ -1475,11 +1475,11 @@ def writesubtrees( self, - m1: 'treemanifest', - m2: 'treemanifest', + m1: treemanifest, + m2: treemanifest, writesubtree: Callable[ [ - Callable[['treemanifest'], None], + Callable[[treemanifest], None], bytes, bytes, matchmod.basematcher, @@ -1517,7 +1517,7 @@ def walksubtrees( self, matcher: Optional[matchmod.basematcher] = None - ) -> Iterator['treemanifest']: + ) -> Iterator[treemanifest]: """Returns an iterator of the subtrees of this manifest, including this manifest itself. @@ -2162,12 +2162,12 @@ def _storage(self) -> manifestrevlog: return self._manifestlog.getstorage(b'') - def copy(self) -> 'memmanifestctx': + def copy(self) -> memmanifestctx: memmf = memmanifestctx(self._manifestlog) memmf._manifestdict = self.read().copy() return memmf - def read(self) -> 'manifestdict': + def read(self) -> manifestdict: return self._manifestdict def write(self, transaction, link, p1, p2, added, removed, match=None): @@ -2203,7 +2203,7 @@ # rev = store.rev(node) # self.linkrev = store.linkrev(rev) - def _storage(self) -> 'manifestrevlog': + def _storage(self) -> manifestrevlog: return self._manifestlog.getstorage(b'') def node(self) -> bytes: @@ -2218,7 +2218,7 @@ def parents(self) -> Tuple[bytes, bytes]: return self._storage().parents(self._node) - def read(self) -> 'manifestdict': + def read(self) -> manifestdict: if self._data is None: nc = self._manifestlog.nodeconstants if self._node == nc.nullid: @@ -2234,7 +2234,7 @@ self._data = manifestdict(nc.nodelen, text) return self._data - def readfast(self, shallow: bool = False) -> 'manifestdict': + def readfast(self, shallow: bool = False) -> manifestdict: """Calls either readdelta or read, based on which would be less work. readdelta is called if the delta is against the p1, and therefore can be read quickly. @@ -2253,7 +2253,7 @@ return self.readdelta() return self.read() - def readdelta(self, shallow: bool = False) -> 'manifestdict': + def readdelta(self, shallow: bool = False) -> manifestdict: """Returns a manifest containing just the entries that are present in this manifest, but not in its p1 manifest. This is efficient to read if the revlog delta is already p1. @@ -2354,12 +2354,12 @@ def _storage(self) -> manifestrevlog: return self._manifestlog.getstorage(b'') - def copy(self) -> 'memtreemanifestctx': + def copy(self) -> memtreemanifestctx: memmf = memtreemanifestctx(self._manifestlog, dir=self._dir) memmf._treemanifest = self._treemanifest.copy() return memmf - def read(self) -> 'treemanifest': + def read(self) -> treemanifest: return self._treemanifest def write(self, transaction, link, p1, p2, added, removed, match=None): @@ -2405,7 +2405,7 @@ ) return self._manifestlog.getstorage(self._dir) - def read(self) -> 'treemanifest': + def read(self) -> treemanifest: if self._data is None: store = self._storage() if self._node == self._manifestlog.nodeconstants.nullid: @@ -2441,7 +2441,7 @@ def node(self) -> bytes: return self._node - def copy(self) -> 'memtreemanifestctx': + def copy(self) -> memtreemanifestctx: memmf = memtreemanifestctx(self._manifestlog, dir=self._dir) memmf._treemanifest = self.read().copy() return memmf @@ -2527,7 +2527,7 @@ d = mdiff.patchtext(store.revdiff(store.deltaparent(r), r)) return manifestdict(store.nodeconstants.nodelen, d) - def _read_storage_slow_delta(self, base) -> 'treemanifest': + def _read_storage_slow_delta(self, base) -> treemanifest: store = self._storage() if base is None: base = store.deltaparent(store.rev(self._node))
--- a/mercurial/phases.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/phases.py Mon Jan 06 00:30:55 2025 -0500 @@ -190,19 +190,19 @@ no_bundle_phases = all_internal_phases -def supportinternal(repo: "localrepo.localrepository") -> bool: +def supportinternal(repo: localrepo.localrepository) -> bool: """True if the internal phase can be used on a repository""" return requirements.INTERNAL_PHASE_REQUIREMENT in repo.requirements -def supportarchived(repo: "localrepo.localrepository") -> bool: +def supportarchived(repo: localrepo.localrepository) -> bool: """True if the archived phase can be used on a repository""" return requirements.ARCHIVED_PHASE_REQUIREMENT in repo.requirements def _readroots( - repo: "localrepo.localrepository", - phasedefaults: Optional["Phasedefaults"] = None, + repo: localrepo.localrepository, + phasedefaults: Optional[Phasedefaults] = None, ) -> Tuple[Phaseroots, bool]: """Read phase roots from disk @@ -394,8 +394,8 @@ @overload def __init__( self, - repo: "localrepo.localrepository", - phasedefaults: Optional["Phasedefaults"], + repo: localrepo.localrepository, + phasedefaults: Optional[Phasedefaults], _load: bool = True, ) -> None: pass @@ -414,16 +414,14 @@ self._loadedrevslen = 0 self._phasesets: Optional[PhaseSets] = None - def hasnonpublicphases(self, repo: "localrepo.localrepository") -> bool: + def hasnonpublicphases(self, repo: localrepo.localrepository) -> bool: """detect if there are revisions with non-public phase""" # XXX deprecate the unused repo argument return any( revs for phase, revs in self._phaseroots.items() if phase != public ) - def nonpublicphaseroots( - self, repo: "localrepo.localrepository" - ) -> Set[int]: + def nonpublicphaseroots(self, repo: localrepo.localrepository) -> Set[int]: """returns the roots of all non-public phases The roots are not minimized, so if the secret revisions are @@ -441,7 +439,7 @@ def get_raw_set( self, - repo: "localrepo.localrepository", + repo: localrepo.localrepository, phase: int, ) -> Set[int]: """return the set of revision in that phase @@ -462,7 +460,7 @@ def getrevset( self, - repo: "localrepo.localrepository", + repo: localrepo.localrepository, phases: Iterable[int], subset: Optional[Any] = None, ) -> Any: @@ -562,7 +560,7 @@ self._phasesets[phase] = ps self._loadedrevslen = len(cl) - def _ensure_phase_sets(self, repo: "localrepo.localrepository") -> None: + def _ensure_phase_sets(self, repo: localrepo.localrepository) -> None: """ensure phase information is loaded in the object""" assert repo.filtername is None update = -1 @@ -634,7 +632,7 @@ self._loadedrevslen = 0 self._phasesets = None - def phase(self, repo: "localrepo.localrepository", rev: int) -> int: + def phase(self, repo: localrepo.localrepository, rev: int) -> int: # We need a repo argument here to be able to build _phasesets # if necessary. The repository instance is not stored in # phasecache to avoid reference cycles. The changelog instance @@ -1056,7 +1054,7 @@ repo._phasecache.replace(phcache) -def listphases(repo: "localrepo.localrepository") -> Dict[bytes, bytes]: +def listphases(repo: localrepo.localrepository) -> Dict[bytes, bytes]: """List phases root for serialization over pushkey""" # Use ordered dictionary so behavior is deterministic. keys = util.sortdict() @@ -1089,7 +1087,7 @@ def pushphase( - repo: "localrepo.localrepository", + repo: localrepo.localrepository, nhex: bytes, oldphasestr: bytes, newphasestr: bytes, @@ -1249,7 +1247,7 @@ return sorted(new_heads) -def newcommitphase(ui: "uimod.ui") -> int: +def newcommitphase(ui: uimod.ui) -> int: """helper to get the target phase of new commit Handle all possible values for the phases.new-commit options. @@ -1264,7 +1262,7 @@ ) -def hassecret(repo: "localrepo.localrepository") -> bool: +def hassecret(repo: localrepo.localrepository) -> bool: """utility function that check if a repo have any secret changeset.""" return bool(repo._phasecache._phaseroots[secret])
--- a/mercurial/policy.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/policy.py Mon Jan 06 00:30:55 2025 -0500 @@ -33,7 +33,7 @@ # run without recompiling the C extensions. This will be overridden by # __modulepolicy__ generated by setup.py. policy: bytes = b'allow' -_packageprefs: "Dict[bytes, Tuple[Optional[str], Optional[str]]]" = { +_packageprefs: Dict[bytes, Tuple[Optional[str], Optional[str]]] = { # policy: (versioned package, pure package) b'c': ('cext', None), b'allow': ('cext', 'pure'), @@ -78,7 +78,7 @@ # keep in sync with "version" in C modules -_cextversions: "Dict[Tuple[str, str], int]" = { +_cextversions: Dict[Tuple[str, str], int] = { ('cext', 'base85'): 1, ('cext', 'bdiff'): 3, ('cext', 'mpatch'): 1, @@ -87,7 +87,7 @@ } # map import request to other package or module -_modredirects: "Dict[Tuple[str, str], Tuple[str, str]]" = { +_modredirects: Dict[Tuple[str, str], Tuple[str, str]] = { ('cext', 'charencode'): ('cext', 'parsers'), ('cffi', 'base85'): ('pure', 'base85'), ('cffi', 'charencode'): ('pure', 'charencode'), @@ -133,7 +133,7 @@ def importrust( - modname: str, member: "Optional[str]" = None, default=None, pyo3=False + modname: str, member: Optional[str] = None, default=None, pyo3=False ): """Import Rust module according to policy and availability.
--- a/mercurial/revlog.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/revlog.py Mon Jan 06 00:30:55 2025 -0500 @@ -1360,7 +1360,7 @@ """ _flagserrorclass = error.RevlogError - _inner: "_InnerRevlog" + _inner: _InnerRevlog opener: vfsmod.vfs
--- a/mercurial/scmposix.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/scmposix.py Mon Jan 06 00:30:55 2025 -0500 @@ -73,7 +73,7 @@ ] -def termsize(ui: "uimod.ui") -> Tuple[int, int]: +def termsize(ui: uimod.ui) -> Tuple[int, int]: try: import termios
--- a/mercurial/scmutil.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/scmutil.py Mon Jan 06 00:30:55 2025 -0500 @@ -146,7 +146,7 @@ yield subpath, ctx2.nullsub(subpath, ctx1) -def nochangesfound(ui: "uimod.ui", repo, excluded=None) -> None: +def nochangesfound(ui: uimod.ui, repo, excluded=None) -> None: """Report no changes for push/pull, excluded is None or a list of nodes excluded from the push/pull. """ @@ -166,7 +166,7 @@ ui.status(_(b"no changes found\n")) -def callcatch(ui: "uimod.ui", func: Callable[[], int]) -> int: +def callcatch(ui: uimod.ui, func: Callable[[], int]) -> int: """call func() with global exception handling return func() if no exception happens. otherwise do some error handling @@ -323,7 +323,7 @@ ) -def checkportable(ui: "uimod.ui", f: bytes) -> None: +def checkportable(ui: uimod.ui, f: bytes) -> None: '''Check if filename f is portable and warn or abort depending on config''' checkfilename(f) abort, warn = checkportabilityalert(ui) @@ -336,7 +336,7 @@ ui.warn(_(b"warning: %s\n") % msg) -def checkportabilityalert(ui: "uimod.ui") -> Tuple[bool, bool]: +def checkportabilityalert(ui: uimod.ui) -> Tuple[bool, bool]: """check if the user's config requests nothing, a warning, or abort for non-portable filenames""" val = ui.config(b'ui', b'portablefilenames') @@ -352,7 +352,7 @@ class casecollisionauditor: - def __init__(self, ui: "uimod.ui", abort: bool, dirstate) -> None: + def __init__(self, ui: uimod.ui, abort: bool, dirstate) -> None: self._ui = ui self._abort = abort allfiles = b'\0'.join(dirstate) @@ -544,7 +544,7 @@ return formatrevnode(repo.ui, intrev(ctx), binnode(ctx)) -def formatrevnode(ui: "uimod.ui", rev: int, node: bytes) -> bytes: +def formatrevnode(ui: uimod.ui, rev: int, node: bytes) -> bytes: """Format given revision and node depending on the current verbosity""" if ui.debugflag: hexfunc = hex @@ -1080,7 +1080,7 @@ return files[0] -def getorigvfs(ui: "uimod.ui", repo): +def getorigvfs(ui: uimod.ui, repo): """return a vfs suitable to save 'orig' file return None if no special directory is configured""" @@ -1090,7 +1090,7 @@ return vfs.vfs(repo.wvfs.join(origbackuppath)) -def backuppath(ui: "uimod.ui", repo, filepath: bytes) -> bytes: +def backuppath(ui: uimod.ui, repo, filepath: bytes) -> bytes: """customize where working copy backup files (.orig files) are created Fetch user defined path from config file: [ui] origbackuppath = <path> @@ -1580,7 +1580,7 @@ def dirstatecopy( - ui: "uimod.ui", + ui: uimod.ui, repo, wctx, src, @@ -1956,7 +1956,7 @@ class progress: - ui: "uimod.ui" + ui: uimod.ui pos: Optional[int] # None once complete topic: bytes unit: bytes @@ -1965,7 +1965,7 @@ def __init__( self, - ui: "uimod.ui", + ui: uimod.ui, updatebar, topic: bytes, unit: bytes = b"", @@ -2024,7 +2024,7 @@ self.ui.debug(b'%s:%s %d%s\n' % (self.topic, item, self.pos, unit)) -def gdinitconfig(ui: "uimod.ui"): +def gdinitconfig(ui: uimod.ui): """helper function to know if a repo should be created as general delta""" # experimental config: format.generaldelta return ui.configbool(b'format', b'generaldelta') or ui.configbool( @@ -2032,7 +2032,7 @@ ) -def gddeltaconfig(ui: "uimod.ui"): +def gddeltaconfig(ui: uimod.ui): """helper function to know if incoming deltas should be optimized The `format.generaldelta` config is an old form of the config that also @@ -2485,7 +2485,7 @@ ) -def ismember(ui: "uimod.ui", username: bytes, userlist: List[bytes]) -> bool: +def ismember(ui: uimod.ui, username: bytes, userlist: List[bytes]) -> bool: """Check if username is a member of userlist. If userlist has a single '*' member, all users are considered members. @@ -2511,7 +2511,7 @@ def get_resource_profile( - ui: "uimod.ui", dimension: Optional[bytes] = None + ui: uimod.ui, dimension: Optional[bytes] = None ) -> int: """return the resource profile for a dimension
--- a/mercurial/scmwindows.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/scmwindows.py Mon Jan 06 00:30:55 2025 -0500 @@ -115,5 +115,5 @@ return userhome + path[i:] -def termsize(ui: "uimod.ui") -> Tuple[int, int]: +def termsize(ui: uimod.ui) -> Tuple[int, int]: return win32.termsize()
--- a/mercurial/shelve.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/shelve.py Mon Jan 06 00:30:55 2025 -0500 @@ -88,7 +88,7 @@ else: self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir)) - def get(self, name: bytes) -> "Shelf": + def get(self, name: bytes) -> Shelf: return Shelf(self.vfs, name) def listshelves(self) -> List[Tuple[float, bytes]]:
--- a/mercurial/statprof.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/statprof.py Mon Jan 06 00:30:55 2025 -0500 @@ -159,7 +159,7 @@ class ProfileState: - samples: List["Sample"] + samples: List[Sample] def __init__(self, frequency=None): self.reset(frequency)
--- a/mercurial/store.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/store.py Mon Jan 06 00:30:55 2025 -0500 @@ -54,7 +54,7 @@ fncache_chunksize = 10**6 -def _match_tracked_entry(entry: "BaseStoreEntry", matcher): +def _match_tracked_entry(entry: BaseStoreEntry, matcher): """parses a fncache entry and returns whether the entry is tracking a path matched by matcher or not.
--- a/mercurial/subrepoutil.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/subrepoutil.py Mon Jan 06 00:30:55 2025 -0500 @@ -70,7 +70,7 @@ Substate = Dict[bytes, Tuple[bytes, bytes, bytes]] -def state(ctx: "context.changectx", ui: "uimod.ui") -> Substate: +def state(ctx: context.changectx, ui: uimod.ui) -> Substate: """return a state dict, mapping subrepo paths configured in .hgsub to tuple: (source from .hgsub, revision from .hgsubstate, kind (key in types dict)) @@ -174,7 +174,7 @@ return state -def writestate(repo: "localrepo.localrepository", state: Substate) -> None: +def writestate(repo: localrepo.localrepository, state: Substate) -> None: """rewrite .hgsubstate in (outer) repo with these subrepo states""" lines = [ b'%s %s\n' % (state[s][1], s) @@ -185,10 +185,10 @@ def submerge( - repo: "localrepo.localrepository", - wctx: "context.workingctx", - mctx: "context.changectx", - actx: "context.changectx", + repo: localrepo.localrepository, + wctx: context.workingctx, + mctx: context.changectx, + actx: context.changectx, overwrite: bool, labels: Optional[Any] = None, ) -> Substate: @@ -332,10 +332,10 @@ def precommit( - ui: "uimod.ui", - wctx: "context.workingcommitctx", - status: "istatus.Status", - match: "matchmod.basematcher", + ui: uimod.ui, + wctx: context.workingcommitctx, + status: istatus.Status, + match: matchmod.basematcher, force: bool = False, ) -> Tuple[List[bytes], Set[bytes], Substate]: """Calculate .hgsubstate changes that should be applied before committing @@ -436,7 +436,7 @@ return normalized_path -def reporelpath(repo: "localrepo.localrepository") -> bytes: +def reporelpath(repo: localrepo.localrepository) -> bytes: """return path to this (sub)repo as seen from outermost repo""" parent = repo while hasattr(parent, '_subparent'): @@ -444,13 +444,13 @@ return repo.root[len(pathutil.normasprefix(parent.root)) :] -def subrelpath(sub: "subrepo.abstractsubrepo") -> bytes: +def subrelpath(sub: subrepo.abstractsubrepo) -> bytes: """return path to this subrepo as seen from outermost repo""" return sub._relpath def _abssource( - repo: "localrepo.localrepository", + repo: localrepo.localrepository, push: bool = False, abort: bool = True, ) -> Optional[bytes]: @@ -501,7 +501,7 @@ raise error.Abort(_(b"default path for subrepository not found")) -def newcommitphase(ui: "uimod.ui", ctx: "context.changectx") -> int: +def newcommitphase(ui: uimod.ui, ctx: context.changectx) -> int: commitphase = phases.newcommitphase(ui) substate = getattr(ctx, "substate", None) if not substate:
--- a/mercurial/ui.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/ui.py Mon Jan 06 00:30:55 2025 -0500 @@ -230,7 +230,7 @@ class ui: - def __init__(self, src: Optional["ui"] = None) -> None: + def __init__(self, src: Optional[ui] = None) -> None: """Create a fresh new ui object if no src given Use uimod.ui.load() to create a ui which knows global and user configs.
--- a/mercurial/upgrade_utils/actions.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/upgrade_utils/actions.py Mon Jan 06 00:30:55 2025 -0500 @@ -110,7 +110,7 @@ compatible_with_share = False -allformatvariant: List[Type['formatvariant']] = [] +allformatvariant: List[Type[formatvariant]] = [] def registerformatvariant(cls):
--- a/mercurial/url.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/url.py Mon Jan 06 00:30:55 2025 -0500 @@ -261,7 +261,7 @@ if has_https: - def _generic_proxytunnel(self: "httpsconnection"): + def _generic_proxytunnel(self: httpsconnection): headers = self.headers # pytype: disable=attribute-error proxyheaders = { pycompat.bytestr(x): pycompat.bytestr(headers[x])
--- a/mercurial/utils/resourceutil.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/utils/resourceutil.py Mon Jan 06 00:30:55 2025 -0500 @@ -86,7 +86,7 @@ # importlib.resources was not found (almost definitely because we're on a # Python version before 3.7) - def open_resource(package: bytes, name: bytes) -> "BinaryIO": + def open_resource(package: bytes, name: bytes) -> BinaryIO: path = os.path.join(_package_path(package), name) return open(path, "rb") @@ -98,7 +98,7 @@ except OSError: return False - def contents(package: bytes) -> "Iterator[bytes]": + def contents(package: bytes) -> Iterator[bytes]: path = pycompat.fsdecode(_package_path(package)) for p in os.listdir(path): @@ -107,7 +107,7 @@ else: from .. import encoding - def open_resource(package: bytes, name: bytes) -> "BinaryIO": + def open_resource(package: bytes, name: bytes) -> BinaryIO: if hasattr(resources, 'files'): return ( resources.files( # pytype: disable=module-attr @@ -133,7 +133,7 @@ pycompat.sysstr(package), encoding.strfromlocal(name) ) - def contents(package: bytes) -> "Iterator[bytes]": + def contents(package: bytes) -> Iterator[bytes]: if hasattr(resources, 'files'): # Introduced in Python 3.9 for path in resources.files(pycompat.sysstr(package)).iterdir(): if path.is_file():
--- a/mercurial/utils/urlutil.py Sun Jan 05 22:26:16 2025 -0500 +++ b/mercurial/utils/urlutil.py Mon Jan 06 00:30:55 2025 -0500 @@ -658,7 +658,7 @@ self[name] = new_paths -_pathsuboptions: "Dict[bytes, Tuple[str, Callable]]" = {} +_pathsuboptions: Dict[bytes, Tuple[str, Callable]] = {} # a dictionnary of methods that can be used to format a sub-option value path_suboptions_display = {}