Mercurial > public > mercurial-scm > hg
comparison hgext/git/gitlog.py @ 52489:ba8f03ad8906
filelog: subclass the new `repository.ifilestorage` Protocol class
This is the same transformation as 3a90a6fd710d did for dirstate, but the
CamelCase naming was already cleaned up here. See 4ef6dbc27a99 for the benefits
of explicit subclassing.
One thing to mention is that pytype gets confused if Protocol classes preceed a
regular class in the superclass list, so the interface goes last in the git
extension. (I didn't bother to verify that it would have been an issue here,
rather it was something I noticed when making `repository.ipeerbase` a Protocol
class locally before dropping it entirely earlier in this series.)
One other thing is that PyCharm starts flagging `__len__()` and `hasnode()` on
`hgext.git.gitlog.baselog` with:
"Type of 'hasnode' is incompatible with 'ifilestorage'"
No clue why; it's happy with the other 3 implementations (at least with these
methods- simplestorerepo.py looks badly broken otherwise).
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 22 Oct 2024 23:36:48 -0400 |
parents | 3daaa5195a30 |
children | a26c5da900ff |
comparison
equal
deleted
inserted
replaced
52488:8c89e978375c | 52489:ba8f03ad8906 |
---|---|
18 dagop, | 18 dagop, |
19 encoding, | 19 encoding, |
20 error, | 20 error, |
21 manifest, | 21 manifest, |
22 pycompat, | 22 pycompat, |
23 ) | |
24 from mercurial.interfaces import ( | |
25 repository, | |
23 ) | 26 ) |
24 from mercurial.utils import stringutil | 27 from mercurial.utils import stringutil |
25 from . import ( | 28 from . import ( |
26 gitutil, | 29 gitutil, |
27 index, | 30 index, |
469 te = t[p] | 472 te = t[p] |
470 t = self.gitrepo[te.id] | 473 t = self.gitrepo[te.id] |
471 return gitmanifest.gittreemanifestctx(self.gitrepo, t) | 474 return gitmanifest.gittreemanifestctx(self.gitrepo, t) |
472 | 475 |
473 | 476 |
474 # @interfaceutil.implementer(repository.ifilestorage) | 477 class filelog(baselog, repository.ifilestorage): |
475 class filelog(baselog): | |
476 def __init__(self, gr, db, path): | 478 def __init__(self, gr, db, path): |
477 super(filelog, self).__init__(gr, db) | 479 super(filelog, self).__init__(gr, db) |
478 assert isinstance(path, bytes) | 480 assert isinstance(path, bytes) |
479 self.path = path | 481 self.path = path |
480 self.nullid = sha1nodeconstants.nullid | 482 self.nullid = sha1nodeconstants.nullid |