mercurial/manifest.py
changeset 51819 5eb98ea78fd7
parent 51797 62b25293b620
child 51822 0338fb200a30
equal deleted inserted replaced
51818:e78b75f3cea9 51819:5eb98ea78fd7
     7 
     7 
     8 
     8 
     9 import heapq
     9 import heapq
    10 import itertools
    10 import itertools
    11 import struct
    11 import struct
       
    12 import typing
    12 import weakref
    13 import weakref
    13 
    14 
    14 from typing import (
    15 from typing import (
    15     ByteString,
    16     ByteString,
    16     Callable,
    17     Callable,
   751         return arraytext, deltatext
   752         return arraytext, deltatext
   752 
   753 
   753 
   754 
   754 manifestdict = interfaceutil.implementer(repository.imanifestdict)(ManifestDict)
   755 manifestdict = interfaceutil.implementer(repository.imanifestdict)(ManifestDict)
   755 
   756 
       
   757 if typing.TYPE_CHECKING:
       
   758     manifestdict = ManifestDict
       
   759 
   756 
   760 
   757 def _msearch(
   761 def _msearch(
   758     m: ByteString, s: bytes, lo: int = 0, hi: Optional[int] = None
   762     m: ByteString, s: bytes, lo: int = 0, hi: Optional[int] = None
   759 ) -> Tuple[int, int]:
   763 ) -> Tuple[int, int]:
   760     """return a tuple (start, end) that says where to find s within m.
   764     """return a tuple (start, end) that says where to find s within m.
  1532             for subtree in subm.walksubtrees(matcher=matcher):
  1536             for subtree in subm.walksubtrees(matcher=matcher):
  1533                 yield subtree
  1537                 yield subtree
  1534 
  1538 
  1535 
  1539 
  1536 treemanifest = interfaceutil.implementer(repository.imanifestdict)(TreeManifest)
  1540 treemanifest = interfaceutil.implementer(repository.imanifestdict)(TreeManifest)
       
  1541 
       
  1542 if typing.TYPE_CHECKING:
       
  1543     treemanifest = TreeManifest
  1537 
  1544 
  1538 
  1545 
  1539 class manifestfulltextcache(util.lrucachedict):
  1546 class manifestfulltextcache(util.lrucachedict):
  1540     """File-backed LRU cache for the manifest cache
  1547     """File-backed LRU cache for the manifest cache
  1541 
  1548 
  2045 
  2052 
  2046 manifestrevlog = interfaceutil.implementer(repository.imanifeststorage)(
  2053 manifestrevlog = interfaceutil.implementer(repository.imanifeststorage)(
  2047     ManifestRevlog
  2054     ManifestRevlog
  2048 )
  2055 )
  2049 
  2056 
       
  2057 if typing.TYPE_CHECKING:
       
  2058     manifestrevlog = ManifestRevlog
  2050 
  2059 
  2051 AnyManifestCtx = Union['ManifestCtx', 'TreeManifestCtx']
  2060 AnyManifestCtx = Union['ManifestCtx', 'TreeManifestCtx']
  2052 AnyManifestDict = Union[ManifestDict, TreeManifest]
  2061 AnyManifestDict = Union[ManifestDict, TreeManifest]
  2053 
  2062 
  2054 
  2063 
  2055 @interfaceutil.implementer(repository.imanifestlog)
  2064 class ManifestLog:
  2056 class manifestlog:
       
  2057     """A collection class representing the collection of manifest snapshots
  2065     """A collection class representing the collection of manifest snapshots
  2058     referenced by commits in the repository.
  2066     referenced by commits in the repository.
  2059 
  2067 
  2060     In this situation, 'manifest' refers to the abstract concept of a snapshot
  2068     In this situation, 'manifest' refers to the abstract concept of a snapshot
  2061     of the list of files in the given commit. Consumers of the output of this
  2069     of the list of files in the given commit. Consumers of the output of this
  2155 
  2163 
  2156     def update_caches(self, transaction) -> None:
  2164     def update_caches(self, transaction) -> None:
  2157         return self._rootstore._revlog.update_caches(transaction=transaction)
  2165         return self._rootstore._revlog.update_caches(transaction=transaction)
  2158 
  2166 
  2159 
  2167 
       
  2168 manifestlog = interfaceutil.implementer(repository.imanifestlog)(ManifestLog)
       
  2169 
       
  2170 if typing.TYPE_CHECKING:
       
  2171     manifestlog = ManifestLog
       
  2172 
       
  2173 
  2160 class MemManifestCtx:
  2174 class MemManifestCtx:
  2161     def __init__(self, manifestlog):
  2175     def __init__(self, manifestlog):
  2162         self._manifestlog = manifestlog
  2176         self._manifestlog = manifestlog
  2163         self._manifestdict = manifestdict(manifestlog.nodeconstants.nodelen)
  2177         self._manifestdict = manifestdict(manifestlog.nodeconstants.nodelen)
  2164 
  2178 
  2187 
  2201 
  2188 
  2202 
  2189 memmanifestctx = interfaceutil.implementer(
  2203 memmanifestctx = interfaceutil.implementer(
  2190     repository.imanifestrevisionwritable
  2204     repository.imanifestrevisionwritable
  2191 )(MemManifestCtx)
  2205 )(MemManifestCtx)
       
  2206 
       
  2207 if typing.TYPE_CHECKING:
       
  2208     memmanifestctx = MemManifestCtx
  2192 
  2209 
  2193 
  2210 
  2194 class ManifestCtx:
  2211 class ManifestCtx:
  2195     """A class representing a single revision of a manifest, including its
  2212     """A class representing a single revision of a manifest, including its
  2196     contents, its parent revs, and its linkrev.
  2213     contents, its parent revs, and its linkrev.
  2351 
  2368 
  2352 manifestctx = interfaceutil.implementer(repository.imanifestrevisionstored)(
  2369 manifestctx = interfaceutil.implementer(repository.imanifestrevisionstored)(
  2353     ManifestCtx
  2370     ManifestCtx
  2354 )
  2371 )
  2355 
  2372 
       
  2373 if typing.TYPE_CHECKING:
       
  2374     manifestctx = ManifestCtx
       
  2375 
  2356 
  2376 
  2357 class MemTreeManifestCtx:
  2377 class MemTreeManifestCtx:
  2358     def __init__(self, manifestlog, dir=b''):
  2378     def __init__(self, manifestlog, dir=b''):
  2359         self._manifestlog = manifestlog
  2379         self._manifestlog = manifestlog
  2360         self._dir = dir
  2380         self._dir = dir
  2389 
  2409 
  2390 
  2410 
  2391 memtreemanifestctx = interfaceutil.implementer(
  2411 memtreemanifestctx = interfaceutil.implementer(
  2392     repository.imanifestrevisionwritable
  2412     repository.imanifestrevisionwritable
  2393 )(MemTreeManifestCtx)
  2413 )(MemTreeManifestCtx)
       
  2414 
       
  2415 if typing.TYPE_CHECKING:
       
  2416     memtreemanifestctx = MemTreeManifestCtx
  2394 
  2417 
  2395 
  2418 
  2396 class TreeManifestCtx:
  2419 class TreeManifestCtx:
  2397     def __init__(self, manifestlog, dir, node):
  2420     def __init__(self, manifestlog, dir, node):
  2398         self._manifestlog = manifestlog
  2421         self._manifestlog = manifestlog
  2658 
  2681 
  2659 treemanifestctx = interfaceutil.implementer(repository.imanifestrevisionstored)(
  2682 treemanifestctx = interfaceutil.implementer(repository.imanifestrevisionstored)(
  2660     TreeManifestCtx
  2683     TreeManifestCtx
  2661 )
  2684 )
  2662 
  2685 
       
  2686 if typing.TYPE_CHECKING:
       
  2687     treemanifestctx = TreeManifestCtx
       
  2688 
  2663 
  2689 
  2664 class excludeddir(treemanifest):
  2690 class excludeddir(treemanifest):
  2665     """Stand-in for a directory that is excluded from the repository.
  2691     """Stand-in for a directory that is excluded from the repository.
  2666 
  2692 
  2667     With narrowing active on a repository that uses treemanifests,
  2693     With narrowing active on a repository that uses treemanifests,