comparison mercurial/match.py @ 51675:bc94cbb49b30

typing: add some trivial type hints to `mercurial/match.py` These were new methods since hg 3dbc7b1ecaba, but surprisingly pytype couldn't figure them out.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 10 Jul 2024 17:55:14 -0400
parents aa23b19e6da4
children a1e4fa9330d8
comparison
equal deleted inserted replaced
51674:e8f58714bcf0 51675:bc94cbb49b30
397 def __init__(self, badfn=None): 397 def __init__(self, badfn=None):
398 self._was_tampered_with = False 398 self._was_tampered_with = False
399 if badfn is not None: 399 if badfn is not None:
400 self.bad = badfn 400 self.bad = badfn
401 401
402 def was_tampered_with_nonrec(self): 402 def was_tampered_with_nonrec(self) -> bool:
403 # [_was_tampered_with] is used to track if when extensions changed the matcher 403 # [_was_tampered_with] is used to track if when extensions changed the matcher
404 # behavior (crazy stuff!), so we disable the rust fast path. 404 # behavior (crazy stuff!), so we disable the rust fast path.
405 return self._was_tampered_with 405 return self._was_tampered_with
406 406
407 def was_tampered_with(self): 407 def was_tampered_with(self) -> bool:
408 return self.was_tampered_with_nonrec() 408 return self.was_tampered_with_nonrec()
409 409
410 def __call__(self, fn): 410 def __call__(self, fn):
411 return self.matchfn(fn) 411 return self.matchfn(fn)
412 412
892 self._m1 = m1 892 self._m1 = m1
893 self._m2 = m2 893 self._m2 = m2
894 self.bad = m1.bad 894 self.bad = m1.bad
895 self.traversedir = m1.traversedir 895 self.traversedir = m1.traversedir
896 896
897 def was_tampered_with(self): 897 def was_tampered_with(self) -> bool:
898 return ( 898 return (
899 self.was_tampered_with_nonrec() 899 self.was_tampered_with_nonrec()
900 or self._m1.was_tampered_with() 900 or self._m1.was_tampered_with()
901 or self._m2.was_tampered_with() 901 or self._m2.was_tampered_with()
902 ) 902 )
982 self._m1 = m1 982 self._m1 = m1
983 self._m2 = m2 983 self._m2 = m2
984 self.bad = m1.bad 984 self.bad = m1.bad
985 self.traversedir = m1.traversedir 985 self.traversedir = m1.traversedir
986 986
987 def was_tampered_with(self): 987 def was_tampered_with(self) -> bool:
988 return ( 988 return (
989 self.was_tampered_with_nonrec() 989 self.was_tampered_with_nonrec()
990 or self._m1.was_tampered_with() 990 or self._m1.was_tampered_with()
991 or self._m2.was_tampered_with() 991 or self._m2.was_tampered_with()
992 ) 992 )
1086 # If the parent repo had a path to this subrepo and the matcher is 1086 # If the parent repo had a path to this subrepo and the matcher is
1087 # a prefix matcher, this submatcher always matches. 1087 # a prefix matcher, this submatcher always matches.
1088 if matcher.prefix(): 1088 if matcher.prefix():
1089 self._always = any(f == path for f in matcher._files) 1089 self._always = any(f == path for f in matcher._files)
1090 1090
1091 def was_tampered_with(self): 1091 def was_tampered_with(self) -> bool:
1092 return ( 1092 return (
1093 self.was_tampered_with_nonrec() or self._matcher.was_tampered_with() 1093 self.was_tampered_with_nonrec() or self._matcher.was_tampered_with()
1094 ) 1094 )
1095 1095
1096 def bad(self, f, msg): 1096 def bad(self, f, msg):
1225 m1 = matchers[0] 1225 m1 = matchers[0]
1226 super(unionmatcher, self).__init__() 1226 super(unionmatcher, self).__init__()
1227 self.traversedir = m1.traversedir 1227 self.traversedir = m1.traversedir
1228 self._matchers = matchers 1228 self._matchers = matchers
1229 1229
1230 def was_tampered_with(self): 1230 def was_tampered_with(self) -> bool:
1231 return self.was_tampered_with_nonrec() or any( 1231 return self.was_tampered_with_nonrec() or any(
1232 map(lambda m: m.was_tampered_with(), self._matchers) 1232 map(lambda m: m.was_tampered_with(), self._matchers)
1233 ) 1233 )
1234 1234
1235 def matchfn(self, f): 1235 def matchfn(self, f):