diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -81,6 +81,9 @@ from .revlogutils import ( ) if TYPE_CHECKING: + from .interfaces import ( + status as istatus, + ) from . import ( ui as uimod, ) @@ -796,7 +799,7 @@ class dirnode: yield st, fpath -def tersedir(statuslist, terseargs): +def tersedir(statuslist: istatus.Status, terseargs) -> istatus.Status: """ Terse the status if all the files in a directory shares the same status. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -37,6 +37,9 @@ from . import ( testing, util, ) +from .interfaces import ( + status as istatus, +) from .utils import ( dateutil, stringutil, @@ -99,7 +102,7 @@ class basectx: def _buildstatus( self, other, s, match, listignored, listclean, listunknown - ): + ) -> istatus.Status: """build a status with respect to another context""" # Load earliest manifest first for caching reasons. More specifically, # if you have revisions 1000 and 1001, 1001 is probably stored as a @@ -388,7 +391,7 @@ class basectx: listclean=False, listunknown=False, listsubrepos=False, - ): + ) -> istatus.Status: """return status of files between two nodes or node and working directory. @@ -1905,7 +1908,9 @@ class workingctx(committablectx): # Even if the wlock couldn't be grabbed, clear out the list. self._repo.clearpostdsstatus() - def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False): + def _dirstatestatus( + self, match, ignored=False, clean=False, unknown=False + ) -> istatus.Status: '''Gets the status from the dirstate -- internal use only.''' subrepos = [] if b'.hgsub' in self: @@ -2729,7 +2734,9 @@ class workingcommitctx(workingctx): repo, text, user, date, extra, changes ) - def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False): + def _dirstatestatus( + self, match, ignored=False, clean=False, unknown=False + ) -> istatus.Status: """Return matched files only in ``self._status`` Uncommitted files appear "clean" via this context, even if @@ -2924,7 +2931,7 @@ class memctx(committablectx): return man @propertycache - def _status(self): + def _status(self) -> istatus.Status: """Calculate exact status from ``files`` specified at construction""" man1 = self.p1().manifest() p2 = self._parents[1] @@ -3089,7 +3096,7 @@ class metadataonlyctx(committablectx): return self._originalctx.manifest() @propertycache - def _status(self): + def _status(self) -> istatus.Status: """Calculate exact status from ``files`` specified in the ``origctx`` and parents manifests. """ diff --git a/mercurial/interfaces/dirstate.py b/mercurial/interfaces/dirstate.py --- a/mercurial/interfaces/dirstate.py +++ b/mercurial/interfaces/dirstate.py @@ -22,10 +22,11 @@ if typing.TYPE_CHECKING: # to avoid circular imports from .. import ( match as matchmod, - scmutil, transaction as txnmod, ) + from . import status as istatus + # TODO: finish adding type hints AddParentChangeCallbackT = Callable[ ["idirstate", Tuple[Any, Any], Tuple[Any, Any]], Any @@ -49,7 +50,7 @@ if typing.TYPE_CHECKING: """The return type of dirstate.flagfunc().""" # TODO: verify and complete this- it came from a pytype *.pyi file - StatusReturnT = Tuple[Any, scmutil.status, Any] + StatusReturnT = Tuple[Any, istatus.Status, Any] """The return type of dirstate.status().""" # TODO: probably doesn't belong here. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -39,6 +39,9 @@ from . import ( util, vfs as vfsmod, ) +from .interfaces import ( + status as istatus, +) from .utils import ( dateutil, hashutil, @@ -332,7 +335,7 @@ class abstractsubrepo: def cat(self, match, fm, fntemplate, prefix, **opts): return 1 - def status(self, rev2, **opts): + def status(self, rev2, **opts) -> istatus.Status: return scmutil.status([], [], [], [], [], [], []) def diff(self, ui, diffopts, node2, match, prefix, **opts): @@ -614,7 +617,7 @@ class hgsubrepo(abstractsubrepo): ) @annotatesubrepoerror - def status(self, rev2, **opts): + def status(self, rev2, **opts) -> istatus.Status: try: rev1 = self._state[1] ctx1 = self._repo[rev1] @@ -1971,7 +1974,7 @@ class gitsubrepo(abstractsubrepo): return 0 @annotatesubrepoerror - def status(self, rev2, **opts): + def status(self, rev2, **opts) -> istatus.Status: rev1 = self._state[1] if self._gitmissing() or not rev1: # if the repo is missing, return no results diff --git a/mercurial/subrepoutil.py b/mercurial/subrepoutil.py --- a/mercurial/subrepoutil.py +++ b/mercurial/subrepoutil.py @@ -52,17 +52,17 @@ if typing.TYPE_CHECKING: context, localrepo, match as matchmod, - scmutil, subrepo, ui as uimod, ) + from .interfaces import status as istatus + # keeps pyflakes happy assert [ context, localrepo, matchmod, - scmutil, subrepo, uimod, ] @@ -334,7 +334,7 @@ def submerge( def precommit( ui: "uimod.ui", wctx: "context.workingcommitctx", - status: "scmutil.status", + status: "istatus.Status", match: "matchmod.basematcher", force: bool = False, ) -> Tuple[List[bytes], Set[bytes], Substate]: