comparison hgext/git/gitlog.py @ 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 cdb45eb77efb
children ba8f03ad8906
comparison
equal deleted inserted replaced
52515:c0d9fda9f5f5 52516:3daaa5195a30
1 from __future__ import annotations 1 from __future__ import annotations
2
3 from typing import (
4 Iterator,
5 )
2 6
3 from mercurial.i18n import _ 7 from mercurial.i18n import _
4 8
5 from mercurial.node import ( 9 from mercurial.node import (
6 bin, 10 bin,
32 36
33 def __init__(self, gr, db): 37 def __init__(self, gr, db):
34 self.gitrepo = gr 38 self.gitrepo = gr
35 self._db = db 39 self._db = db
36 40
37 def __len__(self): 41 def __len__(self) -> int:
38 return int( 42 return int(
39 self._db.execute('SELECT COUNT(*) FROM changelog').fetchone()[0] 43 self._db.execute('SELECT COUNT(*) FROM changelog').fetchone()[0]
40 ) 44 )
41 45
42 def rev(self, n): 46 def rev(self, n):
498 502
499 def add(self, text, meta, transaction, link, p1=None, p2=None): 503 def add(self, text, meta, transaction, link, p1=None, p2=None):
500 assert not meta # Should we even try to handle this? 504 assert not meta # Should we even try to handle this?
501 return self.gitrepo.create_blob(text).raw 505 return self.gitrepo.create_blob(text).raw
502 506
503 def __iter__(self): 507 def __iter__(self) -> Iterator[int]:
504 for clrev in self._db.execute( 508 for clrev in self._db.execute(
505 ''' 509 '''
506 SELECT rev FROM changelog 510 SELECT rev FROM changelog
507 INNER JOIN changedfiles ON changelog.node = changedfiles.node 511 INNER JOIN changedfiles ON changelog.node = changedfiles.node
508 WHERE changedfiles.filename = ? AND changedfiles.filenode != ? 512 WHERE changedfiles.filename = ? AND changedfiles.filenode != ?