mercurial/interfaces/repository.py
changeset 52475 cdd4bc69bfc1
parent 52474 048c11993d6a
child 52476 0c60be5e021a
equal deleted inserted replaced
52474:048c11993d6a 52475:cdd4bc69bfc1
     6 # This software may be used and distributed according to the terms of the
     6 # This software may be used and distributed according to the terms of the
     7 # GNU General Public License version 2 or any later version.
     7 # GNU General Public License version 2 or any later version.
     8 
     8 
     9 from __future__ import annotations
     9 from __future__ import annotations
    10 
    10 
       
    11 import abc
    11 import typing
    12 import typing
    12 
    13 
    13 from typing import (
    14 from typing import (
    14     Any,
    15     Any,
    15     Collection,
    16     Collection,
  1169 
  1170 
  1170         The returned object conforms to the ``imanifestdict`` interface.
  1171         The returned object conforms to the ``imanifestdict`` interface.
  1171         """
  1172         """
  1172 
  1173 
  1173 
  1174 
  1174 class imanifestrevisionstored(imanifestrevisionbase):
  1175 class imanifestrevisionstored(imanifestrevisionbase, Protocol):
  1175     """Interface representing a manifest revision committed to storage."""
  1176     """Interface representing a manifest revision committed to storage."""
  1176 
  1177 
       
  1178     @abc.abstractmethod
  1177     def node(self) -> bytes:
  1179     def node(self) -> bytes:
  1178         """The binary node for this manifest."""
  1180         """The binary node for this manifest."""
  1179 
  1181 
  1180     parents: list[bytes]
  1182     parents: list[bytes]
  1181     """List of binary nodes that are parents for this manifest revision."""
  1183     """List of binary nodes that are parents for this manifest revision."""
  1182 
  1184 
       
  1185     @abc.abstractmethod
  1183     def readdelta(self, shallow: bool = False):
  1186     def readdelta(self, shallow: bool = False):
  1184         """Obtain the manifest data structure representing changes from parent.
  1187         """Obtain the manifest data structure representing changes from parent.
  1185 
  1188 
  1186         This manifest is compared to its 1st parent. A new manifest
  1189         This manifest is compared to its 1st parent. A new manifest
  1187         representing those differences is constructed.
  1190         representing those differences is constructed.
  1193         its 't' flag. This only apply if the underlying manifest support it.
  1196         its 't' flag. This only apply if the underlying manifest support it.
  1194 
  1197 
  1195         The returned object conforms to the ``imanifestdict`` interface.
  1198         The returned object conforms to the ``imanifestdict`` interface.
  1196         """
  1199         """
  1197 
  1200 
       
  1201     @abc.abstractmethod
  1198     def read_any_fast_delta(
  1202     def read_any_fast_delta(
  1199         self,
  1203         self,
  1200         valid_bases: Collection[int] | None = None,
  1204         valid_bases: Collection[int] | None = None,
  1201         *,
  1205         *,
  1202         shallow: bool = False,
  1206         shallow: bool = False,
  1221         its 't' flag. This only apply if the underlying manifest support it.
  1225         its 't' flag. This only apply if the underlying manifest support it.
  1222 
  1226 
  1223         The returned object conforms to the ``imanifestdict`` interface.
  1227         The returned object conforms to the ``imanifestdict`` interface.
  1224         """
  1228         """
  1225 
  1229 
       
  1230     @abc.abstractmethod
  1226     def read_delta_parents(self, *, shallow: bool = False, exact: bool = True):
  1231     def read_delta_parents(self, *, shallow: bool = False, exact: bool = True):
  1227         """return a diff from this revision against both parents.
  1232         """return a diff from this revision against both parents.
  1228 
  1233 
  1229         If `exact` is False, this might return a superset of the diff, containing
  1234         If `exact` is False, this might return a superset of the diff, containing
  1230         files that are actually present as is in one of the parents.
  1235         files that are actually present as is in one of the parents.
  1235         the subdirectory will be reported among files and distinguished only by
  1240         the subdirectory will be reported among files and distinguished only by
  1236         its 't' flag. This only apply if the underlying manifest support it.
  1241         its 't' flag. This only apply if the underlying manifest support it.
  1237 
  1242 
  1238         The returned object conforms to the ``imanifestdict`` interface."""
  1243         The returned object conforms to the ``imanifestdict`` interface."""
  1239 
  1244 
       
  1245     @abc.abstractmethod
  1240     def read_delta_new_entries(self, *, shallow: bool = False):
  1246     def read_delta_new_entries(self, *, shallow: bool = False):
  1241         """Return a manifest containing just the entries that might be new to
  1247         """Return a manifest containing just the entries that might be new to
  1242         the repository.
  1248         the repository.
  1243 
  1249 
  1244         This is often equivalent to a diff against both parents, but without
  1250         This is often equivalent to a diff against both parents, but without
  1250         the subdirectory will be reported among files and distinguished only by
  1256         the subdirectory will be reported among files and distinguished only by
  1251         its 't' flag. This only apply if the underlying manifest support it.
  1257         its 't' flag. This only apply if the underlying manifest support it.
  1252 
  1258 
  1253         The returned object conforms to the ``imanifestdict`` interface."""
  1259         The returned object conforms to the ``imanifestdict`` interface."""
  1254 
  1260 
       
  1261     @abc.abstractmethod
  1255     def readfast(self, shallow: bool = False):
  1262     def readfast(self, shallow: bool = False):
  1256         """Calls either ``read()`` or ``readdelta()``.
  1263         """Calls either ``read()`` or ``readdelta()``.
  1257 
  1264 
  1258         The faster of the two options is called.
  1265         The faster of the two options is called.
  1259         """
  1266         """
  1260 
  1267 
       
  1268     @abc.abstractmethod
  1261     def find(self, key: bytes) -> tuple[bytes, bytes]:
  1269     def find(self, key: bytes) -> tuple[bytes, bytes]:
  1262         """Calls self.read().find(key)``.
  1270         """Calls self.read().find(key)``.
  1263 
  1271 
  1264         Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
  1272         Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
  1265         """
  1273         """