comparison mercurial/store.py @ 51728:2e9e62242451

typing: disable some pytype errors in `mercurial.store` These seem to be legitimate errors, since one of the two callers (`encodedstore.data_entries()`) was previously typed to generate `BaseStoreEntry`. However, that and the other caller only pass `RevlogStoreEntry` objects. I can't tell if this was a WIP or what, but don't want to get side tracked on this. So flag as a TODO for later.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 23 Jul 2024 19:14:16 -0400
parents ca7bde5dbafb
children 278af66e6595
comparison
equal deleted inserted replaced
51727:a65c2dddbf5d 51728:2e9e62242451
38 # how much bytes should be read from fncache in one read 38 # how much bytes should be read from fncache in one read
39 # It is done to prevent loading large fncache files into memory 39 # It is done to prevent loading large fncache files into memory
40 fncache_chunksize = 10**6 40 fncache_chunksize = 10**6
41 41
42 42
43 def _match_tracked_entry(entry, matcher): 43 def _match_tracked_entry(entry: "BaseStoreEntry", matcher):
44 """parses a fncache entry and returns whether the entry is tracking a path 44 """parses a fncache entry and returns whether the entry is tracking a path
45 matched by matcher or not. 45 matched by matcher or not.
46 46
47 If matcher is None, returns True""" 47 If matcher is None, returns True"""
48 48
49 if matcher is None: 49 if matcher is None:
50 return True 50 return True
51
52 # TODO: make this safe for other entry types. Currently, the various
53 # store.data_entry generators only yield RevlogStoreEntry, so the
54 # attributes do exist on `entry`.
55 # pytype: disable=attribute-error
51 if entry.is_filelog: 56 if entry.is_filelog:
52 return matcher(entry.target_id) 57 return matcher(entry.target_id)
53 elif entry.is_manifestlog: 58 elif entry.is_manifestlog:
54 return matcher.visitdir(entry.target_id.rstrip(b'/')) 59 return matcher.visitdir(entry.target_id.rstrip(b'/'))
60 # pytype: enable=attribute-error
55 raise error.ProgrammingError(b"cannot process entry %r" % entry) 61 raise error.ProgrammingError(b"cannot process entry %r" % entry)
56 62
57 63
58 # This avoids a collision between a file named foo and a dir named 64 # This avoids a collision between a file named foo and a dir named
59 # foo.i or foo.d 65 # foo.i or foo.d