Mercurial > public > mercurial-scm > hg-stable
changeset 52516:3daaa5195a30
typing: align the signatures of `repository.ifilestorage` overrides
This is the same as 048c11993d6a for `imanifestrevisionstored`, with the same
belated realization about missing the Protocol marker.
Since I've been jumping around to the various subclasses and copying extant
hints to places where they're missing, do that here too. This also covers the 3
interfaces subclassed by `repository.ifilestorage` (`repository.ifileindex`,
`repository.ifiledata`, and `repository.ifilemutation`). Obviously the whole
base class needs hints, but I don't want to get side tracked here- it doesn't
look like any of the implementing classes have any additional hints.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 23 Oct 2024 12:21:52 -0400 |
parents | c0d9fda9f5f5 |
children | 8c89e978375c |
files | hgext/git/gitlog.py hgext/sqlitestore.py mercurial/interfaces/repository.py tests/simplestorerepo.py |
diffstat | 4 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/git/gitlog.py Tue Dec 10 23:36:14 2024 -0500 +++ b/hgext/git/gitlog.py Wed Oct 23 12:21:52 2024 -0400 @@ -1,5 +1,9 @@ from __future__ import annotations +from typing import ( + Iterator, +) + from mercurial.i18n import _ from mercurial.node import ( @@ -34,7 +38,7 @@ self.gitrepo = gr self._db = db - def __len__(self): + def __len__(self) -> int: return int( self._db.execute('SELECT COUNT(*) FROM changelog').fetchone()[0] ) @@ -500,7 +504,7 @@ assert not meta # Should we even try to handle this? return self.gitrepo.create_blob(text).raw - def __iter__(self): + def __iter__(self) -> Iterator[int]: for clrev in self._db.execute( ''' SELECT rev FROM changelog
--- a/hgext/sqlitestore.py Tue Dec 10 23:36:14 2024 -0500 +++ b/hgext/sqlitestore.py Wed Oct 23 12:21:52 2024 -0400 @@ -52,6 +52,8 @@ import zlib from typing import ( + Iterable, + Iterator, Optional, ) @@ -402,10 +404,10 @@ # Start of ifileindex interface. - def __len__(self): + def __len__(self) -> int: return len(self._revisions) - def __iter__(self): + def __iter__(self) -> Iterator[int]: return iter(range(len(self._revisions))) def hasnode(self, node): @@ -986,7 +988,7 @@ return d - def verifyintegrity(self, state): + def verifyintegrity(self, state) -> Iterable[repository.iverifyproblem]: state[b'skipread'] = set() for rev in self:
--- a/mercurial/interfaces/repository.py Tue Dec 10 23:36:14 2024 -0500 +++ b/mercurial/interfaces/repository.py Wed Oct 23 12:21:52 2024 -0400 @@ -15,6 +15,8 @@ Any, Callable, Collection, + Iterable, + Iterator, Mapping, Protocol, ) @@ -608,10 +610,10 @@ nullid: bytes """node for the null revision for use as delta base.""" - def __len__(self): + def __len__(self) -> int: """Obtain the number of revisions stored for this file.""" - def __iter__(self): + def __iter__(self) -> Iterator[int]: """Iterate over revision numbers for this file.""" def hasnode(self, node): @@ -967,7 +969,7 @@ callers are expected to handle this special value. """ - def verifyintegrity(self, state): + def verifyintegrity(self, state) -> Iterable[iverifyproblem]: """Verifies the integrity of file storage. ``state`` is a dict holding state of the verifier process. It can be
--- a/tests/simplestorerepo.py Tue Dec 10 23:36:14 2024 -0500 +++ b/tests/simplestorerepo.py Wed Oct 23 12:21:52 2024 -0400 @@ -14,6 +14,8 @@ import stat from typing import ( + Iterable, + Iterator, Optional, ) @@ -164,10 +166,10 @@ self._index.append((0, 0, 0, -1, -1, -1, -1, self._repo.nullid)) - def __len__(self): + def __len__(self) -> int: return len(self._indexdata) - def __iter__(self): + def __iter__(self) -> Iterator[int]: return iter(range(len(self))) def revs(self, start=0, stop=None): @@ -431,7 +433,7 @@ 'storedsize': None, } - def verifyintegrity(self, state): + def verifyintegrity(self, state) -> Iterable[repository.iverifyproblem]: state['skipread'] = set() for rev in self: node = self.node(rev)