diff hgext/git/gitlog.py @ 52518: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
line wrap: on
line diff
--- a/hgext/git/gitlog.py	Wed Dec 11 00:33:49 2024 -0500
+++ b/hgext/git/gitlog.py	Tue Oct 22 23:36:48 2024 -0400
@@ -21,6 +21,9 @@
     manifest,
     pycompat,
 )
+from mercurial.interfaces import (
+    repository,
+)
 from mercurial.utils import stringutil
 from . import (
     gitutil,
@@ -471,8 +474,7 @@
         return gitmanifest.gittreemanifestctx(self.gitrepo, t)
 
 
-# @interfaceutil.implementer(repository.ifilestorage)
-class filelog(baselog):
+class filelog(baselog, repository.ifilestorage):
     def __init__(self, gr, db, path):
         super(filelog, self).__init__(gr, db)
         assert isinstance(path, bytes)