Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 51868:0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
These were pretty clean changes in the pyi files from earlier in this series, so
add them to the code to make it more understandable.
There's one more trivial hint that can be added to the return of
`mercurial.revlogutils.rewrite._filelog_from_filename()`, however it needs to be
imported from '..' under the conditional of `typing.TYPE_CHECKING`, and that
seems to confuse the import checker- possibly because there's already an import
block from that level. (I would have expected a message about multiple import
statements in this case, but got one about higher level imports should come
first, no matter where I put the import statement.)
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 21 Aug 2024 22:15:05 -0400 |
parents | 766c55492258 |
children | eb9dea148233 |
comparison
equal
deleted
inserted
replaced
51867:766c55492258 | 51868:0338fb200a30 |
---|---|
23 import typing | 23 import typing |
24 import weakref | 24 import weakref |
25 import zlib | 25 import zlib |
26 | 26 |
27 from typing import ( | 27 from typing import ( |
28 Iterable, | |
29 Iterator, | |
28 Optional, | 30 Optional, |
29 Tuple, | 31 Tuple, |
30 ) | 32 ) |
31 | 33 |
32 # import stuff from node for others to import from revlog | 34 # import stuff from node for others to import from revlog |
1824 return 0 <= rev < len(self) | 1826 return 0 <= rev < len(self) |
1825 | 1827 |
1826 def __len__(self): | 1828 def __len__(self): |
1827 return len(self.index) | 1829 return len(self.index) |
1828 | 1830 |
1829 def __iter__(self): | 1831 def __iter__(self) -> Iterator[int]: |
1830 return iter(range(len(self))) | 1832 return iter(range(len(self))) |
1831 | 1833 |
1832 def revs(self, start=0, stop=None): | 1834 def revs(self, start=0, stop=None): |
1833 """iterate over all rev in this revlog (from start to stop)""" | 1835 """iterate over all rev in this revlog (from start to stop)""" |
1834 return storageutil.iterrevs(len(self), start=start, stop=stop) | 1836 return storageutil.iterrevs(len(self), start=start, stop=stop) |
3900 elif self._format_version == REVLOGV1: | 3902 elif self._format_version == REVLOGV1: |
3901 rewrite.v1_censor(self, tr, censor_nodes, tombstone) | 3903 rewrite.v1_censor(self, tr, censor_nodes, tombstone) |
3902 else: | 3904 else: |
3903 rewrite.v2_censor(self, tr, censor_nodes, tombstone) | 3905 rewrite.v2_censor(self, tr, censor_nodes, tombstone) |
3904 | 3906 |
3905 def verifyintegrity(self, state): | 3907 def verifyintegrity(self, state) -> Iterable[RevLogProblem]: |
3906 """Verifies the integrity of the revlog. | 3908 """Verifies the integrity of the revlog. |
3907 | 3909 |
3908 Yields ``revlogproblem`` instances describing problems that are | 3910 Yields ``revlogproblem`` instances describing problems that are |
3909 found. | 3911 found. |
3910 """ | 3912 """ |