changeset 51961:3a90a6fd710d

dirstate: subclass the new dirstate Protocol class Behold the chaos that ensues. We'll use the generated *.pyi files to apply type annotations to the interface, and see how much agrees with the documentation. Since the CamelCase name was used to try to work around pytype issues with zope interfaces and is a new innovation this cycle (see c1d7ac70980b), drop the CamelCase name. I think the Protocol classes *should* be CamelCase, but that can be done later in one pass. For now, the CamelCase alias is extra noise in the *.pyi files.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 26 Sep 2024 18:52:46 -0400
parents 51be8bf8c986
children 70fe33bdab54
files hgext/git/dirstate.py mercurial/dirstate.py
diffstat 2 files changed, 2 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/git/dirstate.py	Thu Sep 26 18:51:03 2024 -0400
+++ b/hgext/git/dirstate.py	Thu Sep 26 18:52:46 2024 -0400
@@ -18,7 +18,6 @@
 )
 from mercurial.interfaces import (
     dirstate as intdirstate,
-    util as interfaceutil,
 )
 
 from . import gitutil
@@ -73,8 +72,7 @@
     }
 
 
-@interfaceutil.implementer(intdirstate.idirstate)
-class gitdirstate:
+class gitdirstate(intdirstate.idirstate):
     def __init__(self, ui, vfs, gitrepo, use_dirstate_v2):
         self._ui = ui
         self._root = os.path.dirname(vfs.base)
--- a/mercurial/dirstate.py	Thu Sep 26 18:51:03 2024 -0400
+++ b/mercurial/dirstate.py	Thu Sep 26 18:52:46 2024 -0400
@@ -11,7 +11,6 @@
 import contextlib
 import os
 import stat
-import typing
 import uuid
 
 from .i18n import _
@@ -38,7 +37,6 @@
 
 from .interfaces import (
     dirstate as intdirstate,
-    util as interfaceutil,
 )
 
 parsers = policy.importmod('parsers')
@@ -136,7 +134,7 @@
 CHANGE_TYPE_FILES = "files"
 
 
-class DirState:
+class dirstate(intdirstate.idirstate):
     # used by largefile to avoid overwritting transaction callback
     _tr_key_suffix = b''
 
@@ -1808,9 +1806,3 @@
             entry = self.get_entry(f)
             if not entry.p1_tracked:
                 yield missing_from_ds % (f, node.short(p1))
-
-
-dirstate = interfaceutil.implementer(intdirstate.idirstate)(DirState)
-
-if typing.TYPE_CHECKING:
-    dirstate = DirState