##// END OF EJS Templates
typing: use the `Status` protocol wherever `scmutil.status` was being used...
Matt Harbison -
r53349:9d79ffee default
parent child Browse files
Show More
@@ -81,6 +81,9 from .revlogutils import (
81 )
81 )
82
82
83 if TYPE_CHECKING:
83 if TYPE_CHECKING:
84 from .interfaces import (
85 status as istatus,
86 )
84 from . import (
87 from . import (
85 ui as uimod,
88 ui as uimod,
86 )
89 )
@@ -796,7 +799,7 class dirnode:
796 yield st, fpath
799 yield st, fpath
797
800
798
801
799 def tersedir(statuslist, terseargs):
802 def tersedir(statuslist: istatus.Status, terseargs) -> istatus.Status:
800 """
803 """
801 Terse the status if all the files in a directory shares the same status.
804 Terse the status if all the files in a directory shares the same status.
802
805
@@ -37,6 +37,9 from . import (
37 testing,
37 testing,
38 util,
38 util,
39 )
39 )
40 from .interfaces import (
41 status as istatus,
42 )
40 from .utils import (
43 from .utils import (
41 dateutil,
44 dateutil,
42 stringutil,
45 stringutil,
@@ -99,7 +102,7 class basectx:
99
102
100 def _buildstatus(
103 def _buildstatus(
101 self, other, s, match, listignored, listclean, listunknown
104 self, other, s, match, listignored, listclean, listunknown
102 ):
105 ) -> istatus.Status:
103 """build a status with respect to another context"""
106 """build a status with respect to another context"""
104 # Load earliest manifest first for caching reasons. More specifically,
107 # Load earliest manifest first for caching reasons. More specifically,
105 # if you have revisions 1000 and 1001, 1001 is probably stored as a
108 # if you have revisions 1000 and 1001, 1001 is probably stored as a
@@ -388,7 +391,7 class basectx:
388 listclean=False,
391 listclean=False,
389 listunknown=False,
392 listunknown=False,
390 listsubrepos=False,
393 listsubrepos=False,
391 ):
394 ) -> istatus.Status:
392 """return status of files between two nodes or node and working
395 """return status of files between two nodes or node and working
393 directory.
396 directory.
394
397
@@ -1905,7 +1908,9 class workingctx(committablectx):
1905 # Even if the wlock couldn't be grabbed, clear out the list.
1908 # Even if the wlock couldn't be grabbed, clear out the list.
1906 self._repo.clearpostdsstatus()
1909 self._repo.clearpostdsstatus()
1907
1910
1908 def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False):
1911 def _dirstatestatus(
1912 self, match, ignored=False, clean=False, unknown=False
1913 ) -> istatus.Status:
1909 '''Gets the status from the dirstate -- internal use only.'''
1914 '''Gets the status from the dirstate -- internal use only.'''
1910 subrepos = []
1915 subrepos = []
1911 if b'.hgsub' in self:
1916 if b'.hgsub' in self:
@@ -2729,7 +2734,9 class workingcommitctx(workingctx):
2729 repo, text, user, date, extra, changes
2734 repo, text, user, date, extra, changes
2730 )
2735 )
2731
2736
2732 def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False):
2737 def _dirstatestatus(
2738 self, match, ignored=False, clean=False, unknown=False
2739 ) -> istatus.Status:
2733 """Return matched files only in ``self._status``
2740 """Return matched files only in ``self._status``
2734
2741
2735 Uncommitted files appear "clean" via this context, even if
2742 Uncommitted files appear "clean" via this context, even if
@@ -2924,7 +2931,7 class memctx(committablectx):
2924 return man
2931 return man
2925
2932
2926 @propertycache
2933 @propertycache
2927 def _status(self):
2934 def _status(self) -> istatus.Status:
2928 """Calculate exact status from ``files`` specified at construction"""
2935 """Calculate exact status from ``files`` specified at construction"""
2929 man1 = self.p1().manifest()
2936 man1 = self.p1().manifest()
2930 p2 = self._parents[1]
2937 p2 = self._parents[1]
@@ -3089,7 +3096,7 class metadataonlyctx(committablectx):
3089 return self._originalctx.manifest()
3096 return self._originalctx.manifest()
3090
3097
3091 @propertycache
3098 @propertycache
3092 def _status(self):
3099 def _status(self) -> istatus.Status:
3093 """Calculate exact status from ``files`` specified in the ``origctx``
3100 """Calculate exact status from ``files`` specified in the ``origctx``
3094 and parents manifests.
3101 and parents manifests.
3095 """
3102 """
@@ -22,10 +22,11 if typing.TYPE_CHECKING:
22 # to avoid circular imports
22 # to avoid circular imports
23 from .. import (
23 from .. import (
24 match as matchmod,
24 match as matchmod,
25 scmutil,
26 transaction as txnmod,
25 transaction as txnmod,
27 )
26 )
28
27
28 from . import status as istatus
29
29 # TODO: finish adding type hints
30 # TODO: finish adding type hints
30 AddParentChangeCallbackT = Callable[
31 AddParentChangeCallbackT = Callable[
31 ["idirstate", Tuple[Any, Any], Tuple[Any, Any]], Any
32 ["idirstate", Tuple[Any, Any], Tuple[Any, Any]], Any
@@ -49,7 +50,7 if typing.TYPE_CHECKING:
49 """The return type of dirstate.flagfunc()."""
50 """The return type of dirstate.flagfunc()."""
50
51
51 # TODO: verify and complete this- it came from a pytype *.pyi file
52 # TODO: verify and complete this- it came from a pytype *.pyi file
52 StatusReturnT = Tuple[Any, scmutil.status, Any]
53 StatusReturnT = Tuple[Any, istatus.Status, Any]
53 """The return type of dirstate.status()."""
54 """The return type of dirstate.status()."""
54
55
55 # TODO: probably doesn't belong here.
56 # TODO: probably doesn't belong here.
@@ -39,6 +39,9 from . import (
39 util,
39 util,
40 vfs as vfsmod,
40 vfs as vfsmod,
41 )
41 )
42 from .interfaces import (
43 status as istatus,
44 )
42 from .utils import (
45 from .utils import (
43 dateutil,
46 dateutil,
44 hashutil,
47 hashutil,
@@ -332,7 +335,7 class abstractsubrepo:
332 def cat(self, match, fm, fntemplate, prefix, **opts):
335 def cat(self, match, fm, fntemplate, prefix, **opts):
333 return 1
336 return 1
334
337
335 def status(self, rev2, **opts):
338 def status(self, rev2, **opts) -> istatus.Status:
336 return scmutil.status([], [], [], [], [], [], [])
339 return scmutil.status([], [], [], [], [], [], [])
337
340
338 def diff(self, ui, diffopts, node2, match, prefix, **opts):
341 def diff(self, ui, diffopts, node2, match, prefix, **opts):
@@ -614,7 +617,7 class hgsubrepo(abstractsubrepo):
614 )
617 )
615
618
616 @annotatesubrepoerror
619 @annotatesubrepoerror
617 def status(self, rev2, **opts):
620 def status(self, rev2, **opts) -> istatus.Status:
618 try:
621 try:
619 rev1 = self._state[1]
622 rev1 = self._state[1]
620 ctx1 = self._repo[rev1]
623 ctx1 = self._repo[rev1]
@@ -1971,7 +1974,7 class gitsubrepo(abstractsubrepo):
1971 return 0
1974 return 0
1972
1975
1973 @annotatesubrepoerror
1976 @annotatesubrepoerror
1974 def status(self, rev2, **opts):
1977 def status(self, rev2, **opts) -> istatus.Status:
1975 rev1 = self._state[1]
1978 rev1 = self._state[1]
1976 if self._gitmissing() or not rev1:
1979 if self._gitmissing() or not rev1:
1977 # if the repo is missing, return no results
1980 # if the repo is missing, return no results
@@ -52,17 +52,17 if typing.TYPE_CHECKING:
52 context,
52 context,
53 localrepo,
53 localrepo,
54 match as matchmod,
54 match as matchmod,
55 scmutil,
56 subrepo,
55 subrepo,
57 ui as uimod,
56 ui as uimod,
58 )
57 )
59
58
59 from .interfaces import status as istatus
60
60 # keeps pyflakes happy
61 # keeps pyflakes happy
61 assert [
62 assert [
62 context,
63 context,
63 localrepo,
64 localrepo,
64 matchmod,
65 matchmod,
65 scmutil,
66 subrepo,
66 subrepo,
67 uimod,
67 uimod,
68 ]
68 ]
@@ -334,7 +334,7 def submerge(
334 def precommit(
334 def precommit(
335 ui: "uimod.ui",
335 ui: "uimod.ui",
336 wctx: "context.workingcommitctx",
336 wctx: "context.workingcommitctx",
337 status: "scmutil.status",
337 status: "istatus.Status",
338 match: "matchmod.basematcher",
338 match: "matchmod.basematcher",
339 force: bool = False,
339 force: bool = False,
340 ) -> Tuple[List[bytes], Set[bytes], Substate]:
340 ) -> Tuple[List[bytes], Set[bytes], Substate]:
General Comments 0
You need to be logged in to leave comments. Login now