# HG changeset patch # User Matt Harbison # Date 1722526990 14400 # Node ID a1e4fa9330d8e2a95f43aca568b8caa698372e39 # Parent a53162bd73edf2da71cbac55cd6ff013dc01fa84 typing: add type hints around the matcher for subrepo archiving Mostly this is meant to try to smoke out any other potential issues around the matcher, since these args were mostly previously treated as `Any`, and therefore checking wasn't done. diff -r a53162bd73ed -r a1e4fa9330d8 hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py Thu Aug 01 01:52:11 2024 -0400 +++ b/hgext/largefiles/overrides.py Thu Aug 01 11:43:10 2024 -0400 @@ -11,6 +11,9 @@ import contextlib import copy import os +from typing import ( + Optional, +) from mercurial.i18n import _ @@ -1224,7 +1227,7 @@ node, kind, decode=True, - match=None, + match: Optional[matchmod.basematcher] = None, prefix=b'', mtime=None, subrepos=None, @@ -1317,7 +1320,9 @@ @eh.wrapfunction(subrepo.hgsubrepo, 'archive') -def hgsubrepoarchive(orig, repo, archiver, prefix, match, decode=True): +def hgsubrepoarchive( + orig, repo, archiver, prefix, match: matchmod.basematcher, decode=True +): lfenabled = hasattr(repo._repo, '_largefilesenabled') if not lfenabled or not repo._repo.lfstatus: return orig(repo, archiver, prefix, match, decode) diff -r a53162bd73ed -r a1e4fa9330d8 mercurial/match.py --- a/mercurial/match.py Thu Aug 01 01:52:11 2024 -0400 +++ b/mercurial/match.py Thu Aug 01 11:43:10 2024 -0400 @@ -1071,7 +1071,7 @@ sub/x.txt: No such file """ - def __init__(self, path, matcher): + def __init__(self, path: bytes, matcher: basematcher) -> None: super(subdirmatcher, self).__init__() self._path = path self._matcher = matcher diff -r a53162bd73ed -r a1e4fa9330d8 mercurial/subrepo.py --- a/mercurial/subrepo.py Thu Aug 01 01:52:11 2024 -0400 +++ b/mercurial/subrepo.py Thu Aug 01 11:43:10 2024 -0400 @@ -363,7 +363,9 @@ """handle the files command for this subrepo""" return 1 - def archive(self, archiver, prefix, match, decode=True): + def archive( + self, archiver, prefix, match: matchmod.basematcher, decode=True + ): files = [f for f in self.files() if match(f)] total = len(files) relpath = subrelpath(self) @@ -649,7 +651,9 @@ ) @annotatesubrepoerror - def archive(self, archiver, prefix, match, decode=True): + def archive( + self, archiver, prefix, match: matchmod.basematcher, decode=True + ): self._get(self._state + (b'hg',)) files = [f for f in self.files() if match(f)] rev = self._state[1] @@ -1906,7 +1910,9 @@ else: self.wvfs.unlink(f) - def archive(self, archiver, prefix, match, decode=True): + def archive( + self, archiver, prefix, match: matchmod.basematcher, decode=True + ): total = 0 source, revision = self._state if not revision: