comparison mercurial/subrepo.py @ 51753:a1e4fa9330d8

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 01 Aug 2024 11:43:10 -0400
parents a53162bd73ed
children 3b8d92f71d92
comparison
equal deleted inserted replaced
51752:a53162bd73ed 51753:a1e4fa9330d8
361 361
362 def printfiles(self, ui, m, uipathfn, fm, fmt, subrepos): 362 def printfiles(self, ui, m, uipathfn, fm, fmt, subrepos):
363 """handle the files command for this subrepo""" 363 """handle the files command for this subrepo"""
364 return 1 364 return 1
365 365
366 def archive(self, archiver, prefix, match, decode=True): 366 def archive(
367 self, archiver, prefix, match: matchmod.basematcher, decode=True
368 ):
367 files = [f for f in self.files() if match(f)] 369 files = [f for f in self.files() if match(f)]
368 total = len(files) 370 total = len(files)
369 relpath = subrelpath(self) 371 relpath = subrelpath(self)
370 progress = self.ui.makeprogress( 372 progress = self.ui.makeprogress(
371 _(b'archiving (%s)') % relpath, unit=_(b'files'), total=total 373 _(b'archiving (%s)') % relpath, unit=_(b'files'), total=total
647 _(b'warning: error "%s" in subrepository "%s"\n') 649 _(b'warning: error "%s" in subrepository "%s"\n')
648 % (inst, subrelpath(self)) 650 % (inst, subrelpath(self))
649 ) 651 )
650 652
651 @annotatesubrepoerror 653 @annotatesubrepoerror
652 def archive(self, archiver, prefix, match, decode=True): 654 def archive(
655 self, archiver, prefix, match: matchmod.basematcher, decode=True
656 ):
653 self._get(self._state + (b'hg',)) 657 self._get(self._state + (b'hg',))
654 files = [f for f in self.files() if match(f)] 658 files = [f for f in self.files() if match(f)]
655 rev = self._state[1] 659 rev = self._state[1]
656 ctx = self._repo[rev] 660 ctx = self._repo[rev]
657 scmutil.prefetchfiles( 661 scmutil.prefetchfiles(
1904 if kind == stat.S_IFDIR: 1908 if kind == stat.S_IFDIR:
1905 self.wvfs.rmtree(f) 1909 self.wvfs.rmtree(f)
1906 else: 1910 else:
1907 self.wvfs.unlink(f) 1911 self.wvfs.unlink(f)
1908 1912
1909 def archive(self, archiver, prefix, match, decode=True): 1913 def archive(
1914 self, archiver, prefix, match: matchmod.basematcher, decode=True
1915 ):
1910 total = 0 1916 total = 0
1911 source, revision = self._state 1917 source, revision = self._state
1912 if not revision: 1918 if not revision:
1913 return total 1919 return total
1914 self._fetch(source, revision) 1920 self._fetch(source, revision)