# HG changeset patch # User Matt Harbison # Date 2024-09-26 22:52:46 # Node ID 3a90a6fd710d77669751b479f2b5d4549dfd8c69 # Parent 51be8bf8c98650709691f36aeafd644badcd9e50 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. diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py --- a/hgext/git/dirstate.py +++ b/hgext/git/dirstate.py @@ -18,7 +18,6 @@ from mercurial.dirstateutils import ( ) from mercurial.interfaces import ( dirstate as intdirstate, - util as interfaceutil, ) from . import gitutil @@ -73,8 +72,7 @@ if pygit2: } -@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) diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -11,7 +11,6 @@ import collections import contextlib import os import stat -import typing import uuid from .i18n import _ @@ -38,7 +37,6 @@ from .dirstateutils import ( from .interfaces import ( dirstate as intdirstate, - util as interfaceutil, ) parsers = policy.importmod('parsers') @@ -136,7 +134,7 @@ CHANGE_TYPE_PARENTS = "parents" 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 @@ class DirState: 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