diff --git a/hgext/git/manifest.py b/hgext/git/manifest.py --- a/hgext/git/manifest.py +++ b/hgext/git/manifest.py @@ -268,7 +268,7 @@ class gittreemanifestctx: def read(self): return gittreemanifest(self._repo, self._tree, None) - def readfast(self, shallow=False): + def readfast(self, shallow: bool = False): return self.read() def copy(self): @@ -276,7 +276,7 @@ class gittreemanifestctx: # because the caller expects a mutable manifest. return memgittreemanifestctx(self._repo, self._tree) - def find(self, path): + def find(self, path: bytes) -> tuple[bytes, bytes]: return self.read()[path] diff --git a/mercurial/interfaces/repository.py b/mercurial/interfaces/repository.py --- a/mercurial/interfaces/repository.py +++ b/mercurial/interfaces/repository.py @@ -12,6 +12,7 @@ import typing from typing import ( Any, + Collection, Protocol, ) @@ -1173,13 +1174,13 @@ class imanifestrevisionbase(Protocol): class imanifestrevisionstored(imanifestrevisionbase): """Interface representing a manifest revision committed to storage.""" - def node(self): + def node(self) -> bytes: """The binary node for this manifest.""" parents: list[bytes] """List of binary nodes that are parents for this manifest revision.""" - def readdelta(self, shallow=False): + def readdelta(self, shallow: bool = False): """Obtain the manifest data structure representing changes from parent. This manifest is compared to its 1st parent. A new manifest @@ -1194,7 +1195,12 @@ class imanifestrevisionstored(imanifestr The returned object conforms to the ``imanifestdict`` interface. """ - def read_any_fast_delta(self, valid_bases=None, *, shallow=False): + def read_any_fast_delta( + self, + valid_bases: Collection[int] | None = None, + *, + shallow: bool = False, + ): """read some manifest information as fast if possible This might return a "delta", a manifest object containing only file @@ -1217,7 +1223,7 @@ class imanifestrevisionstored(imanifestr The returned object conforms to the ``imanifestdict`` interface. """ - def read_delta_parents(self, *, shallow=False, exact=True): + def read_delta_parents(self, *, shallow: bool = False, exact: bool = True): """return a diff from this revision against both parents. If `exact` is False, this might return a superset of the diff, containing @@ -1231,7 +1237,7 @@ class imanifestrevisionstored(imanifestr The returned object conforms to the ``imanifestdict`` interface.""" - def read_delta_new_entries(self, *, shallow=False): + def read_delta_new_entries(self, *, shallow: bool = False): """Return a manifest containing just the entries that might be new to the repository. @@ -1246,13 +1252,13 @@ class imanifestrevisionstored(imanifestr The returned object conforms to the ``imanifestdict`` interface.""" - def readfast(self, shallow=False): + def readfast(self, shallow: bool = False): """Calls either ``read()`` or ``readdelta()``. The faster of the two options is called. """ - def find(self, key): + def find(self, key: bytes) -> tuple[bytes, bytes]: """Calls self.read().find(key)``. Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``. diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -2332,7 +2332,7 @@ class manifestctx: # (repository.imanif md.set(f, new_node, new_flag) return md - def read_delta_new_entries(self, *, shallow=False) -> manifestdict: + def read_delta_new_entries(self, *, shallow: bool = False) -> manifestdict: """see `interface.imanifestrevisionbase` documentations""" # If we are using narrow, returning a delta against an arbitrary # changeset might return file outside the narrowspec. This can create @@ -2621,7 +2621,7 @@ class treemanifestctx: # (repository.im bases = (store.deltaparent(r),) return self.read_any_fast_delta(bases, shallow=shallow)[1] - def readfast(self, shallow=False) -> AnyManifestDict: + def readfast(self, shallow: bool = False) -> AnyManifestDict: """Calls either readdelta or read, based on which would be less work. readdelta is called if the delta is against the p1, and therefore can be read quickly. @@ -2694,7 +2694,7 @@ class excludeddirmanifestctx(treemanifes def read(self): return excludeddir(self.nodeconstants, self._dir, self._node) - def readfast(self, shallow=False): + def readfast(self, shallow: bool = False): # special version of readfast since we don't have underlying storage return self.read()