o ]Lb@sddlmZddlmZddlmZddlmZdZdZ d Z d Z d Z d Z d ZdZdZdZeeBeBeBZdZdZdZdZdZdZdZdZdZdZdZdZdZehZ eeeeeeeehZ!e!"Z#e#$eGdddej%Z&Gd d!d!ej%Z'Gd"d#d#ej%Z(Gd$d%d%ej%Z)Gd&d'd'ej%Z*Gd(d)d)ej%Z+Gd*d+d+e&e'e+Z,Gd,d-d-e&e'e+Z-e.e,Gd.d/d/e/Z0Gd0d1d1ej%Z1Gd2d3d3ej%Z2Gd4d5d5ej%Z3Gd6d7d7ej%Z4Gd8d9d9ej%Z5Gd:d;d;ej%Z6Gdd?d?ej%Z8Gd@dAdAej%Z9GdBdCdCej%Z:GdDdEdEe:Z;GdFdGdGe:ZGdLdMdMej%Z?GdNdOdOej%Z@GdPdQdQe@e?ZAGdRdSdSej%ZBdTS)U)absolute_import)_)error)utilsrevlogfilestorages sharedstoreslfss streamclones side-datasshallowfilestorageii@i isdefaultsprevioussfulltextsp1s branchmap-allsbranchmap-servedschangelog-caches full-manifestsfile-node-tagssmanifestlog-cachesrev-branch-caches tags-defaults tags-servedc@sBeZdZdZedZddZddZddZ d d Z d d Z d S)ipeerconnectiona*Represents a "connection" to a repository. This is the base interface for representing a connection to a repository. It holds basic properties and methods applicable to all peer types. This is not a complete interface definition and should not be used outside of this module. zui.ui instancecCdS)aReturns a URL string representing this peer. Currently, implementations expose the raw URL used to construct the instance. It may contain credentials as part of the URL. The expectations of the value aren't well-defined and this could lead to data leakage. TODO audit/clean consumers and more clearly define the contents of this value. Nr r r A/usr/lib/python3/dist-packages/mercurial/interfaces/repository.pyurllzipeerconnection.urlcCr )zReturns a local repository instance. If the peer represents a local repository, returns an object that can be used to interface with it. Otherwise returns ``None``. Nr r r r r localxr zipeerconnection.localcCr )zlReturns an object conforming to this interface. Most implementations will ``return self``. Nr r r r r peerr zipeerconnection.peercCr )z;Returns a boolean indicating if this peer can be pushed to.Nr r r r r canpushr zipeerconnection.canpushcCr )zClose the connection to this peer. This is called when the peer will no longer be used. Resources associated with the peer should be cleaned up. Nr r r r r closer zipeerconnection.closeN) __name__ __module__ __qualname____doc__ interfaceutil Attributeuir rrrrr r r r r`s   rc@ eZdZdZddZddZdS)ipeercapabilitiesz+Peer sub-interface related to capabilities.cCr )a5Determine support for a named capability. Returns ``False`` if capability not supported. Returns ``True`` if boolean capability is supported. Returns a string if capability support is non-boolean. Capability strings may or may not map to wire protocol capabilities. Nr )namer r r capabler zipeercapabilities.capablecCr )zsRequire a capability to be present. Raises a ``CapabilityError`` if the capability isn't present. Nr )rpurposer r r requirecapr zipeercapabilities.requirecapN)rrrrrrr r r r rs rc@sreZdZdZddZddZddZdd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS) ipeercommandszClient-side interface for communicating over the wire protocol. This interface is used as a gateway to the Mercurial wire protocol. methods commonly call wire protocol commands of the same name. cCr )zObtain heads in named branches. Returns a dict mapping branch name to an iterable of nodes that are heads on that branch. Nr r r r r branchmapr zipeercommands.branchmapcCr )zXObtain capabilities of the peer. Returns a set of string capabilities. Nr r r r r capabilitiesr zipeercommands.capabilitiescCr )zjObtains the clone bundles manifest for the repo. Returns the manifest as unparsed bytes. Nr r r r r clonebundlesr zipeercommands.clonebundlesNcCr )z?Used to facilitate debugging of arguments passed over the wire.Nr onetwothreefourfiver r r debugwireargsr zipeercommands.debugwireargscKr )zObtain remote repository data as a bundle. This command is how the bulk of repository data is transferred from the peer to the local repository Returns a generator of bundle data. Nr )sourcekwargsr r r getbundler zipeercommands.getbundlecCr )zfDetermine all known head revisions in the peer. Returns an iterable of binary nodes. Nr r r r r headsr zipeercommands.headscCr )zDetermine whether multiple nodes are known. Accepts an iterable of nodes whose presence to check for. Returns an iterable of booleans indicating of the corresponding node at that index is known to the peer. Nr nodesr r r knownr zipeercommands.knowncCr )z[Obtain all keys in a pushkey namespace. Returns an iterable of key names. Nr  namespacer r r listkeysr zipeercommands.listkeyscCr )zqResolve a value to a known revision. Returns a binary node of the resolved revision on success. Nr keyr r r lookupr zipeercommands.lookupcCr )aSet a value using the ``pushkey`` protocol. Arguments correspond to the pushkey namespace and key to operate on and the old and new values for that key. Returns a string with the peer result. The value inside varies by the namespace. Nr r2r5oldnewr r r pushkeyr zipeercommands.pushkeycCr )zfObtain streaming clone data. Successful result should be a generator of data chunks. Nr r r r r stream_outr zipeercommands.stream_outcCr )zTransfer repository data to the peer. This is how the bulk of data during a push is transferred. Returns the integer number of heads added to the peer. Nr )bundler-r r r r unbundler zipeercommands.unbundleNNN)rrrrr r!r"r)r,r-r0r3r6r:r;r=r r r r rs    rc@0eZdZdZddZddZddZdd Zd S) ipeerlegacycommandsa Interface for implementing support for legacy wire protocol commands. Wire protocol commands transition to legacy status when they are no longer used by modern clients. To facilitate identifying which commands are legacy, the interfaces are split. cCr )zObtain nodes between pairs of nodes. ``pairs`` is an iterable of node pairs. Returns an iterable of iterables of nodes corresponding to each requested pair. Nr pairsr r r betweenr zipeerlegacycommands.betweencCr )aObtain ancestor changesets of specific nodes back to a branch point. For each requested node, the peer finds the first ancestor node that is a DAG root or is a merge. Returns an iterable of iterables with the resolved values for each node. Nr r.r r r branchesr zipeerlegacycommands.branchescCr )zBObtain a changegroup with data for descendants of specified nodes.Nr )r/r*r r r changegroupr zipeerlegacycommands.changegroupcCdSNr )basesr-r*r r r changegroupsubsetz%ipeerlegacycommands.changegroupsubsetN)rrrrrCrDrErIr r r r r@s   r@c@s(eZdZdZddZddZddZdS) ipeercommandexecutoraDRepresents a mechanism to execute remote commands. This is the primary interface for requesting that wire protocol commands be executed. Instances of this interface are active in a context manager and have a well-defined lifetime. When the context manager exits, all outstanding requests are waited on. cCr )aRequest that a named command be executed. Receives the command name and a dictionary of command arguments. Returns a ``concurrent.futures.Future`` that will resolve to the result of that command request. That exact value is left up to the implementation and possibly varies by command. Not all commands can coexist with other commands in an executor instance: it depends on the underlying wire protocol transport being used and the command itself. Implementations MAY call ``sendcommands()`` automatically if the requested command can not coexist with other commands in this executor. Implementations MAY call ``sendcommands()`` automatically when the future's ``result()`` is called. So, consumers using multiple commands with an executor MUST ensure that ``result()`` is not called until all command requests have been issued. Nr )rargsr r r callcommand)r z ipeercommandexecutor.callcommandcCr )abTrigger submission of queued command requests. Not all transports submit commands as soon as they are requested to run. When called, this method forces queued command requests to be issued. It will no-op if all commands have already been sent. When called, no more new commands may be issued with this executor. Nr r r r r sendcommands?r z!ipeercommandexecutor.sendcommandscCr )aySignal that this command request is finished. When called, no more new commands may be issued. All outstanding commands that have previously been issued are waited on before returning. This not only includes waiting for the futures to resolve, but also waiting for all response data to arrive. In other words, calling this waits for all on-wire state for issued command requests to finish. When used as a context manager, this method is called when exiting the context manager. This method may call ``sendcommands()`` if there are buffered commands. Nr r r r r rIr zipeercommandexecutor.closeN)rrrrrMrNrr r r r rK s  rKc@s"eZdZdZedZddZdS) ipeerrequestsz+Interface for executing commands on a peer.zBTrue if the peer cannot receive large argument value for commands.cCr )aA context manager that resolves to an ipeercommandexecutor. The object this resolves to can be used to issue command requests to the peer. Callers should call its ``callcommand`` method to issue command requests. A new executor should be obtained for each distinct set of commands (possibly just a single command) that the consumer wants to execute as part of a single operation or round trip. This is because some peers are half-duplex and/or don't support persistent connections. e.g. in the case of HTTP peers, commands sent to an executor represent a single HTTP request. While some peers may support multiple command sends over the wire per executor, consumers need to code to the least capable peer. So it should be assumed that command executors buffer called commands until they are told to send them and that each command executor could result in a new connection or wire-level request being issued. Nr r r r r commandexecutorar zipeerrequests.commandexecutorN)rrrrrrlimitedargumentsrPr r r r rOZs  rOc@eZdZdZdS) ipeerbasezeUnified interface for peer repositories. All peer instances must conform to this interface. Nrrrrr r r r rSxsrSc@seZdZdZedZdS)ipeerv2z9Unified peer interface for wire protocol version 2 peers.z1Data structure holding description of server API.N)rrrrrr apidescriptorr r r r rUs rUc@s$eZdZdZdZddZddZdS)rz!Base class for peer repositories.FcCsH|}||vr dSd|}|D]}||r!|t|dSqdS)NTs%s=F)r! startswithlen)selfrcapscapr r r rs z peer.capablecCs$||rdSttd||f)NsAcannot %s; remote repository does not support the '%s' capability)rrCapabilityErrorr)rYrrr r r rs zpeer.requirecapN)rrrrrQrrr r r r rs  rc@s.eZdZdZedZedZedZdS)iverifyproblemaRepresents a problem with the integrity of the repository. Instances of this interface are emitted to describe an integrity issue with a repository (e.g. corrupt storage, missing data, etc). Instances are essentially messages associated with severity. z'Message indicating a non-fatal problem.z#Message indicating a fatal problem.zsRevision encountering the problem. ``None`` means the problem doesn't apply to a single revision. N) rrrrrrwarningrnoder r r r r]s r]c@s~eZdZdZedZedZedZedZ edZ edZ edZ ed Z ed Zed Zed Zd S)irevisiondeltaaRepresents a delta between one revision and another. Instances convey enough information to allow a revision to be exchanged with another repository. Instances represent the fulltext revision data or a delta against another revision. Therefore the ``revision`` and ``delta`` attributes are mutually exclusive. Typically used for changegroup generation. z20 byte node of this revision.z,20 byte node of 1st parent of this revision.z,20 byte node of 2nd parent of this revision.z>20 byte node of the changelog revision this node is linked to.z2 bytes of integer flags that apply to this revision. This is a bitwise composition of the ``REVISION_FLAG_*`` constants. z20 byte node of the revision this data is a delta against. ``nullid`` indicates that the revision is a full revision and not a delta. zmSize of base revision this delta is against. May be ``None`` if ``basenode`` is ``nullid``. z,Raw fulltext of revision data for this node.z\Delta between ``basenode`` and ``node``. Stored in the bdiff delta format. z*Raw sidedata bytes for the given revision.zSingle byte of integer flags that can influence the protocol. This is a bitwise composition of the ``storageutil.CG_FLAG*`` constants. N)rrrrrrr_p1nodep2nodelinknodeflagsbasenodebaserevisionsizerevisiondeltasidedataprotocol_flagsr r r r r`sB r`c@r?) ifilerevisionssequencea,Contains index data for all revisions of a file. Types implementing this behave like lists of tuples. The index in the list corresponds to the revision number. The values contain index metadata. The *null* revision (revision number -1) is always the last item in the index. cCr )zThe total number of revisions.Nr r r r r __len__r zifilerevisionssequence.__len__cCr )aReturns the object having a specific revision number. Returns an 8-tuple with the following fields: offset+flags Contains the offset and flags for the revision. 64-bit unsigned integer where first 6 bytes are the offset and the next 2 bytes are flags. The offset can be 0 if it is not used by the store. compressed size Size of the revision data in the store. It can be 0 if it isn't needed by the store. uncompressed size Fulltext size. It can be 0 if it isn't needed by the store. base revision Revision number of revision the delta for storage is encoded against. -1 indicates not encoded against a base revision. link revision Revision number of changelog revision this entry is related to. p1 revision Revision number of 1st parent. -1 if no 1st parent. p2 revision Revision number of 2nd parent. -1 if no 1st parent. node Binary node value for this revision number. Negative values should index off the end of the sequence. ``-1`` should return the null revision. ``-2`` should return the most recent revision. Nr revr r r __getitem__r z"ifilerevisionssequence.__getitem__cCr )z!Whether a revision number exists.Nr rmr r r __contains__2r z#ifilerevisionssequence.__contains__cCr )z.Add an item to the index at specific revision.Nr )rYientryr r r insert5r zifilerevisionssequence.insertN)rrrrrlrorprsr r r r rks   rkc@seZdZdZedZddZddZddZ d#d d Z d dZ ddZ ddZ ddZddZddZddZddZddZd$dd Zd!d"Zd S)% ifileindexaStorage interface for index data of a single file. File storage data is divided into index metadata and data storage. This interface defines the index portion of the interface. The index logically consists of: * A mapping between revision numbers and nodes. * DAG data (storing and querying the relationship between nodes). * Metadata to facilitate storage. z1node for the null revision for use as delta base.cCr )z4Obtain the number of revisions stored for this file.Nr r r r r rlJr zifileindex.__len__cCr )z,Iterate over revision numbers for this file.Nr r r r r __iter__Mr zifileindex.__iter__cCr )aReturns a bool indicating if a node is known to this store. Implementations must only return True for full, binary node values: hex nodes, revision numbers, and partial node matches must be rejected. The null node is never present. Nr r_r r r hasnodePr zifileindex.hasnoderNcCr )z:Iterate over revision numbers for this file, with control.Nr startstopr r r revsZr zifileindex.revscCr )zuReturns a 2-tuple of parent nodes for a revision. Values will be ``nullid`` if the parent is empty. Nr rvr r r parents]r zifileindex.parentscCr z0Like parents() but operates on revision numbers.Nr rmr r r parentrevscr zifileindex.parentrevscCr )zqObtain the revision number given a node. Raises ``error.LookupError`` if the node is not known. Nr rvr r r rnfr zifileindex.revcCr )zpObtain the node value given a revision number. Raises ``IndexError`` if the node is not known. Nr rmr r r r_lr zifileindex.nodecCr )zAttempt to resolve a value to a node. Value can be a binary node, hex node, revision number, or a string that can be converted to an integer. Raises ``error.LookupError`` if a node could not be resolved. Nr rvr r r r6rr zifileindex.lookupcCr z=Obtain the changeset revision number a revision is linked to.Nr rmr r r linkrev{r zifileindex.linkrevcCr )z6Return whether a revision's content has been censored.Nr rmr r r iscensored~r zifileindex.iscensoredcCr )z|Obtain an iterable of nodes containing heads of common ancestors. See ``ancestor.commonancestorsheads()``. Nr )node1node2r r r commonancestorsheadsr zifileindex.commonancestorsheadscCr )zObtain descendant revision numbers for a set of revision numbers. If ``nullrev`` is in the set, this is equivalent to ``revs()``. Nr )r{r r r descendantsr zifileindex.descendantscCr )agObtain a list of nodes that are DAG heads, with control. The set of revisions examined can be limited by specifying ``start`` and ``stop``. ``start`` is a node. ``stop`` is an iterable of nodes. DAG traversal starts at earlier revision ``start`` and iterates forward until any node in ``stop`` is encountered. Nr rxr r r r-r zifileindex.headscCr )zTObtain nodes that are children of a node. Returns a list of nodes. Nr rvr r r childrenr zifileindex.children)rNNN)rrrrrrnullidrlrurwr{r|r~rnr_r6rrrrr-rr r r r rt9s(     rtc@sTeZdZdZddZdddZddZd d Zd d Zd dZ ddde fddZ dS) ifiledatazStorage interface for data storage of a specific file. This complements ``ifileindex`` and provides an interface for accessing data for a tracked file. cCr )ziObtain the fulltext size of file data. Any metadata is excluded from size measurements. Nr rmr r r sizer zifiledata.sizeFcCr )ajObtain fulltext data for a node. By default, any storage transformations are applied before the data is returned. If ``raw`` is True, non-raw storage transformations are not applied. The fulltext data may contain a header containing metadata. Most consumers should use ``read()`` to obtain the actual file data. Nr )r_rawr r r rgr zifiledata.revisioncCr zObtain raw data for a node.Nr rvr r r rawdatar zifiledata.rawdatacCr )zResolve file fulltext data. This is similar to ``revision()`` except any metadata in the data headers is stripped. Nr rvr r r readr zifiledata.readcCr )zObtain copy metadata for a node. Returns ``False`` if no copy metadata is stored or a 2-tuple of (path, node) from which this revision was copied. Nr rvr r r renamedr zifiledata.renamedcCr )zCompare fulltext to another revision. Returns True if the fulltext is different from what is stored. This takes copy metadata into account. TODO better document the copy metadata and censoring logic. Nr r_fulltextr r r cmpr z ifiledata.cmpNcCr )a- Produce ``irevisiondelta`` for revisions. Given an iterable of nodes, emits objects conforming to the ``irevisiondelta`` interface that describe revisions in storage. This method is a generator. The input nodes may be unordered. Implementations must ensure that a node's parents are emitted before the node itself. Transitively, this means that a node may only be emitted once all its ancestors in ``nodes`` have also been emitted. By default, emits "index" data (the ``node``, ``p1node``, and ``p2node`` attributes). If ``revisiondata`` is set, revision data will also be present on the emitted objects. With default argument values, implementations can choose to emit either fulltext revision data or a delta. When emitting deltas, implementations must consider whether the delta's base revision fulltext is available to the receiver. The base revision fulltext is guaranteed to be available if any of the following are met: * Its fulltext revision was emitted by this method call. * A delta for that revision was emitted by this method call. * ``assumehaveparentrevisions`` is True and the base revision is a parent of the node. ``nodesorder`` can be used to control the order that revisions are emitted. By default, revisions can be reordered as long as they are in DAG topological order (see above). If the value is ``nodes``, the iteration order from ``nodes`` should be used. If the value is ``storage``, then the native order from the backing storage layer is used. (Not all storage layers will have strong ordering and behavior of this mode is storage-dependent.) ``nodes`` ordering can force revisions to be emitted before their ancestors, so consumers should use it with care. The ``linknode`` attribute on the returned ``irevisiondelta`` may not be set and it is the caller's responsibility to resolve it, if needed. If ``deltamode`` is CG_DELTAMODE_PREV and revision data is requested, all revision data should be emitted as deltas against the revision emitted just prior. The initial revision should be a delta against its 1st parent. Nr )r/ nodesorder revisiondataassumehaveparentrevisions deltamoder r r emitrevisionsr zifiledata.emitrevisionsF) rrrrrrgrrrrCG_DELTAMODE_STDrr r r r rs   rc@sReZdZdZddZ   dddZ   dd d Zdd d ZddZddZ dS) ifilemutationz8Storage interface for mutation events of a tracked file.cCr )aAdd a new revision to the store. Takes file data, dictionary of metadata, a transaction, linkrev, and parent nodes. Returns the node that was added. May no-op if a revision matching the supplied data is already stored. Nr )filedatameta transactionrp1p2r r r add r zifilemutation.addNrcCr )aAdd a new revision to the store and return its number. This is similar to ``add()`` except it operates at a lower level. The data passed in already contains a metadata header, if any. ``node`` and ``flags`` can be used to define the expected node and the flags to use with storage. ``flags`` is a bitwise value composed of the various ``REVISION_FLAG_*`` constants. ``add()`` is usually called when adding files from e.g. the working directory. ``addrevision()`` is often called by ``add()`` and for scenarios where revision data has already been computed, such as when applying raw data from a peer repo. Nr )rrrrrr_rd cachedeltar r r addrevisionr zifilemutation.addrevisionFcCr )aProcess a series of deltas for storage. ``deltas`` is an iterable of 7-tuples of (node, p1, p2, linknode, deltabase, delta, flags) defining revisions to add. The ``delta`` field contains ``mpatch`` data to apply to a base revision, identified by ``deltabase``. The base node can be ``nullid``, in which case the header from the delta can be ignored and the delta used as the fulltext. ``alwayscache`` instructs the lower layers to cache the content of the newly added revision, even if it needs to be explicitly computed. This used to be the default when ``addrevisioncb`` was provided up to Mercurial 5.8. ``addrevisioncb`` should be called for each new rev as it is committed. ``duplicaterevisioncb`` should be called for all revs with a pre-existing node. ``maybemissingparents`` is a bool indicating whether the incoming data may reference parents/ancestor revisions that aren't present. This flag is set when receiving data into a "shallow" store that doesn't hold all history. Returns a list of nodes that were processed. A node will be in the list even if it existed in the store previously. Nr )deltas linkmapperr addrevisioncbduplicaterevisioncbmaybemissingparentsr r r addgroup1r zifilemutation.addgroupcCr )aRemove the content of a single revision. The specified ``node`` will have its content purged from storage. Future attempts to access the revision data for this node will result in failure. A ``tombstone`` message can optionally be stored. This message may be displayed to users when they attempt to access the missing revision data. Storage backends may have stored deltas against the previous content in this revision. As part of censoring a revision, these storage backends are expected to rewrite any internally stored deltas such that they no longer reference the deleted content. Nr )trr_ tombstoner r r censorrevisionVr zifilemutation.censorrevisioncCr )aoFind the minimum revision that must be stripped to strip a linkrev. Returns a 2-tuple containing the minimum revision number and a set of all revisions numbers that would be broken by this strip. TODO this is highly revlog centric and should be abstracted into a higher-level deletion API. ``repair.strip()`` relies on this. Nr minlinkr r r getstrippointgr zifilemutation.getstrippointcCr )a@Remove storage of items starting at a linkrev. This uses ``getstrippoint()`` to determine the first node to remove. Then it effectively truncates storage for all revisions after that. TODO this is highly revlog centric and should be abstracted into a higher-level deletion API. Nr rrr r r stripqr zifilemutation.strip)NrNNNF)r) rrrrrrrrrrr r r r r s  % rc@s4eZdZdZddZ     d ddZddZd S) ifilestoragez5Complete storage interface for a single tracked file.cCr )zObtain paths that are backing storage for this file. TODO this is used heavily by verify code and there should probably be a better API for that. Nr r r r r filesr zifilestorage.filesFcCr )aObtain information about storage for this file's data. Returns a dict describing storage for this tracked path. The keys in the dict map to arguments of the same. The arguments are bools indicating whether to calculate and obtain that data. exclusivefiles Iterable of (vfs, path) describing files that are exclusively used to back storage for this tracked path. sharedfiles Iterable of (vfs, path) describing files that are used to back storage for this tracked path. Those files may also provide storage for other stored entities. revisionscount Number of revisions available for retrieval. trackedsize Total size in bytes of all tracked revisions. This is a sum of the length of the fulltext of all revisions. storedsize Total size in bytes used to store data for all tracked revisions. This is commonly less than ``trackedsize`` due to internal usage of deltas rather than fulltext revisions. Not all storage backends may support all queries are have a reasonable value to use. In that case, the value should be set to ``None`` and callers are expected to handle this special value. Nr exclusivefiles sharedfilesrevisionscount trackedsize storedsizer r r storageinfor zifilestorage.storageinfocCr )aVerifies the integrity of file storage. ``state`` is a dict holding state of the verifier process. It can be used to communicate data between invocations of multiple storage primitives. If individual revisions cannot have their revision content resolved, the method is expected to set the ``skipread`` key to a set of nodes that encountered problems. If set, the method can also add the node(s) to ``safe_renamed`` in order to indicate nodes that may perform the rename checks with currently accessible data. The method yields objects conforming to the ``iverifyproblem`` interface. Nr stater r r verifyintegrityr zifilestorage.verifyintegrityNFFFFF)rrrrrrrr r r r r|s 'rc@r?) idirszInterface representing a collection of directories from paths. This interface is essentially a derived data structure representing directories from a collection of paths. cCr )zlAdd a path to the collection. All directories in the path will be added to the collection. Nr pathr r r addpathr z idirs.addpathcCr )zRemove a path from the collection. If the removal was the last path in a particular directory, the directory is removed from the collection. Nr rr r r delpathr z idirs.delpathcCr )z9Iterate over the directories in this collection of paths.Nr r r r r rur zidirs.__iter__cCr )z3Whether a specific directory is in this collection.Nr rr r r rpr zidirs.__contains__N)rrrrrrrurpr r r r rs  rc@seZdZdZddZddZddZdd ZeZd d Z d d Z ddZ ddZ ddZ ddZd4ddZddZddZddZd5d d!Zd"d#Zd4d$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3ZdS)6 imanifestdictzInterface representing a manifest data structure. A manifest is effectively a dict mapping paths to entries. Each entry consists of a binary node and extra flags affecting that entry. cCr )zReturns the binary node value for a path in the manifest. Raises ``KeyError`` if the path does not exist in the manifest. Equivalent to ``self.find(path)[0]``. Nr rr r r ror zimanifestdict.__getitem__cCr )zReturns the entry for a path in the manifest. Returns a 2-tuple of (node, flags). Raises ``KeyError`` if the path does not exist in the manifest. Nr rr r r findr zimanifestdict.findcCr )z-Return the number of entries in the manifest.Nr r r r r rlr zimanifestdict.__len__cCr )z:Returns True if the manifest has entries, False otherwise.Nr r r r r __nonzero__r zimanifestdict.__nonzero__cCr )zDefine the node value for a path in the manifest. If the path is already in the manifest, its flags will be copied to the new entry. Nr )rr_r r r __setitem__r zimanifestdict.__setitem__cCr )z&Whether a path exists in the manifest.Nr rr r r rpr zimanifestdict.__contains__cCr )zjRemove a path from the manifest. Raises ``KeyError`` if the path is not in the manifest. Nr rr r r __delitem__r zimanifestdict.__delitem__cCr z#Iterate over paths in the manifest.Nr r r r r ru r zimanifestdict.__iter__cCr rr r r r r iterkeys r zimanifestdict.iterkeyscCr )z'Obtain a list of paths in the manifest.Nr r r r r keysr zimanifestdict.keysNcCr )zObtain the set of paths in this manifest but not in another. ``match`` is an optional matcher function to be applied to both manifests. Returns a set of paths. Nr )othermatchr r r filesnotinr zimanifestdict.filesnotincCr )z7Returns an object implementing the ``idirs`` interface.Nr r r r r dirsr zimanifestdict.dirscCr )z=Returns a bool indicating if a directory is in this manifest.Nr )dirr r r hasdirr zimanifestdict.hasdircCr )zGenerator of paths in manifest satisfying a matcher. If the matcher has explicit files listed and they don't exist in the manifest, ``match.bad()`` is called for each missing file. Nr )rr r r walk!r zimanifestdict.walkFcCr )azFind differences between this manifest and another. This manifest is compared to ``other``. If ``match`` is provided, the two manifests are filtered against this matcher and only entries satisfying the matcher are compared. If ``clean`` is True, unchanged files are included in the returned object. Returns a dict with paths as keys and values of 2-tuples of 2-tuples of the form ``((node1, flag1), (node2, flag2))`` where ``(node1, flag1)`` represents the node and flags for this manifest and ``(node2, flag2)`` are the same for the other manifest. Nr )rrcleanr r r diff(r zimanifestdict.diffcCr )zvSet the flag value for a given path. Raises ``KeyError`` if the path is not already in the manifest. Nr )rflagr r r setflag9r zimanifestdict.setflagcCr )z?Obtain the node value for a path or a default value if missing.Nr )rdefaultr r r get?r zimanifestdict.getcCr )z>Return the flags value for a path (default: empty bytestring).Nr rr r r rdBr zimanifestdict.flagscCr )zReturn a copy of this manifest.Nr r r r r copyEr zimanifestdict.copycCr )z?Returns an iterable of (path, node) for items in this manifest.Nr r r r r itemsHr zimanifestdict.itemscCr )zIdentical to items().Nr r r r r iteritemsKr zimanifestdict.iteritemscCr )zReturns an iterable of (path, node, flags) for this manifest. Similar to ``iteritems()`` except items are a 3-tuple and include flags. Nr r r r r iterentriesNr zimanifestdict.iterentriescCr )zuObtain the raw data representation for this manifest. Result is used to create a manifest revision. Nr r r r r textUr zimanifestdict.textcCr )aObtain a delta between this manifest and another given changes. ``base`` in the raw data representation for another manifest. ``changes`` is an iterable of ``(path, to_delete)``. Returns a 2-tuple containing ``bytearray(self.text())`` and the delta between ``base`` and this manifest. If this manifest implementation can't support ``fastdelta()``, raise ``mercurial.manifest.FastdeltaUnavailable``. Nr )basechangesr r r fastdelta[r zimanifestdict.fastdeltarGNF)rrrrrorrlr__bool__rrprrurrrrrrrrrrdrrrrrrr r r r rs6     rc@r)imanifestrevisionbasezBase interface representing a single revision of a manifest. Should not be used as a primary interface: should always be inherited as part of a larger interface. cCr )zObtain a copy of this manifest instance. Returns an object conforming to the ``imanifestrevisionwritable`` interface. The instance will be associated with the same ``imanifestlog`` collection as this instance. Nr r r r r rqr zimanifestrevisionbase.copycCr )z}Obtain the parsed manifest data structure. The returned object conforms to the ``imanifestdict`` interface. Nr r r r r ryr zimanifestrevisionbase.readN)rrrrrrr r r r rjs rc@s>eZdZdZddZedZd ddZd dd Z d d Z d S)imanifestrevisionstoredz@Interface representing a manifest revision committed to storage.cCr )z"The binary node for this manifest.Nr r r r r r_r zimanifestrevisionstored.nodezAList of binary nodes that are parents for this manifest revision.FcCr )aObtain the manifest data structure representing changes from parent. This manifest is compared to its 1st parent. A new manifest representing those differences is constructed. The returned object conforms to the ``imanifestdict`` interface. Nr shallowr r r readdeltar z!imanifestrevisionstored.readdeltacCr )zfCalls either ``read()`` or ``readdelta()``. The faster of the two options is called. Nr rr r r readfastr z imanifestrevisionstored.readfastcCr )zoCalls self.read().find(key)``. Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``. Nr r4r r r rr zimanifestrevisionstored.findNr) rrrrr_rrr|rrrr r r r rs  rc@seZdZdZdddZdS)imanifestrevisionwritablezAInterface representing a manifest revision that can be committed.NcCr )a&Add this revision to storage. Takes a transaction object, the changeset revision number it will be associated with, its parent nodes, and lists of added and removed paths. If match is provided, storage can choose not to inspect or write out items that do not match. Storage is still required to be able to provide the full manifest in the future for any directories written (these manifests should not be "narrowed on disk"). Returns the binary node of the created revision. Nr )rrrarbaddedremovedrr r r writer zimanifestrevisionwritable.writerG)rrrrrr r r r rsrc@s8eZdZdZedZedZedZedZ edZ edZ dd Z d d Z d d ZddZddZddZddZddZdd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Z d?d4d5Z!d6d7Z" d>d8d9Z# ! ! ! ! !d@d:d;Z$dS)Aimanifeststoragez$Storage interface for manifest data.-nodeconstants used by the current repository.ztThe path to the directory this manifest tracks. The empty bytestring represents the root manifest. z'An ``ifilerevisionssequence`` instance.zVFS opener to use to access underlying files used for storage. TODO this is revlog specific and should not be exposed. zuWhether generaldelta storage is being used. TODO this is revlog specific and should not be exposed. zmDict with cache of fulltexts. TODO this doesn't feel appropriate for the storage interface. cCr )z8Obtain the number of revisions stored for this manifest.Nr r r r r rlr zimanifeststorage.__len__cCr )z0Iterate over revision numbers for this manifest.Nr r r r r rur zimanifeststorage.__iter__cCr )zxObtain the revision number given a binary node. Raises ``error.LookupError`` if the node is not known. Nr rvr r r rnr zimanifeststorage.revcCr )z{Obtain the node value given a revision number. Raises ``error.LookupError`` if the revision is not known. Nr rmr r r r_r zimanifeststorage.nodecCr )zAttempt to resolve a value to a node. Value can be a binary node, hex node, revision number, or a bytes that can be converted to an integer. Raises ``error.LookupError`` if a ndoe could not be resolved. Nr )valuer r r r6r zimanifeststorage.lookupcCr )zqReturns a 2-tuple of parent nodes for a node. Values will be ``nullid`` if the parent is empty. Nr rvr r r r|r zimanifeststorage.parentscCr r}r rmr r r r~r zimanifeststorage.parentrevscCr rr rmr r r rr zimanifeststorage.linkrevNcCr )z Obtain fulltext data for a node.Nr r__dfr r r rgr zimanifeststorage.revisioncCr rr rr r r rr zimanifeststorage.rawdatacCr )zObtain a delta between two revision numbers. The returned data is the result of ``bdiff.bdiff()`` on the raw revision data. Nr )rev1rev2r r r revdiffr zimanifeststorage.revdiffcCr )zvCompare fulltext to another revision. Returns True if the fulltext is different from what is stored. Nr rr r r rr zimanifeststorage.cmpFcCr )ztProduce ``irevisiondelta`` describing revisions. See the documentation for ``ifiledata`` for more. Nr )r/rrrr r r rr zimanifeststorage.emitrevisionscCr )znProcess a series of deltas for storage. See the documentation in ``ifilemutation`` for more. Nr )rrrrrr r r rr zimanifeststorage.addgroupcCr )zObtain the size of tracked data. Is equivalent to ``len(m.rawdata(node))``. TODO this method is only used by upgrade code and may be removed. Nr rmr r r rawsize+r zimanifeststorage.rawsizecCr )zFind minimum revision that must be stripped to strip a linkrev. See the documentation in ``ifilemutation`` for more. Nr rr r r r3r zimanifeststorage.getstrippointcCr )zuRemove storage of items starting at a linkrev. See the documentation in ``ifilemutation`` for more. Nr rr r r r9r zimanifeststorage.stripcCr )zObtain the expected sizes of backing files. TODO this is used by verify and it should not be part of the interface. Nr r r r r checksize?r zimanifeststorage.checksizecCr )zObtain paths that are backing storage for this manifest. TODO this is used by verify and there should probably be a better API for this functionality. Nr r r r r rEr zimanifeststorage.filescCr )zObtain the revision that a revision is delta'd against. TODO delta encoding is an implementation detail of storage and should not be exposed to the storage interface. Nr rmr r r deltaparentLr zimanifeststorage.deltaparentcKr )zClone this instance to another.Nr )rdestr+r r r cloneSr zimanifeststorage.clonecCr )z/Clear any caches associated with this instance.Nr )clear_persisted_datar r r clearcachesVr zimanifeststorage.clearcachescCr )z.Obtain a manifest storage instance for a tree.Nr )dr r r dirlogYr zimanifeststorage.dirlogc Cr )aAdd a revision to storage. ``m`` is an object conforming to ``imanifestdict``. ``link`` is the linkrev revision number. ``p1`` and ``p2`` are the parent revision numbers. ``added`` and ``removed`` are iterables of added and removed paths, respectively. ``readtree`` is a function that can be used to read the child tree(s) when recursively writing the full tree structure when using treemanifets. ``match`` is a matcher that can be used to hint to storage that not all paths must be inspected; this is an optimization and can be safely ignored. Note that the storage must still be able to reproduce a full manifest including files that did not match. Nr ) mrlinkrrrrreadtreerr r r r\r zimanifeststorage.addcCr )zObtain information about storage for this manifest's data. See ``ifilestorage.storageinfo()`` for a description of this method. This one behaves the same way, except for manifest data. Nr rr r r rtr zimanifeststorage.storageinforG)NFFrrr)%rrrrrr nodeconstantstreeindexopener _generaldelta fulltextcacherlrurnr_r6r|r~rrgrrrrrrrrrrrrrrrrr r r r rsp        rc@sLeZdZdZedZddZdddZdd Z d d Z d d Z ddZ dS) imanifestlogzInterface representing a collection of manifest snapshots. Represents the root manifest in a repository. Also serves as a means to access nested tree manifests and to cache tree manifests. rcCr )zObtain a manifest instance for a given binary node. Equivalent to calling ``self.get('', node)``. The returned object conforms to the ``imanifestrevisionstored`` interface. Nr rvr r r ror zimanifestlog.__getitem__TcCr )aKRetrieve the manifest instance for a given directory and binary node. ``node`` always refers to the node of the root manifest (which will be the only manifest if flat manifests are being used). If ``tree`` is the empty string, the root manifest is returned. Otherwise the manifest for the specified directory will be returned (requires tree manifests). If ``verify`` is True, ``LookupError`` is raised if the node is not known. The returned object conforms to the ``imanifestrevisionstored`` interface. Nr )rr_verifyr r r rr zimanifestlog.getcCr )aRetrieve an interface to storage for a particular tree. If ``tree`` is the empty bytestring, storage for the root manifest will be returned. Otherwise storage for a tree manifest is returned. TODO formalize interface for returned object. Nr )rr r r getstorager zimanifestlog.getstoragecCr )z-Clear caches associated with this collection.Nr r r r r rr zimanifestlog.clearcachescCr )zvObtain the revision number for a binary node. Raises ``error.LookupError`` if the node is not known. Nr rvr r r rnr zimanifestlog.revcCr )z8update whatever cache are relevant for the used storage.Nr )rr r r update_cachesr zimanifestlog.update_cachesNT) rrrrrrrrorr rrnr r r r r rs   rc@seZdZdZddZdS)ilocalrepositoryfilestoragezLocal repository sub-interface providing access to tracked file storage. This interface defines how a repository accesses storage for a single tracked file path. cCr )ztObtain a filelog for a tracked path. The returned type conforms to the ``ifilestorage`` interface. Nr )fr r r filer z ilocalrepositoryfilestorage.fileN)rrrrrr r r r r s r c@seZdZdZedZedZedZedZ edZ edZ edZ ed Z ed Zed Zed Zed ZedZedZedZedZedZedZedZedZedZedZedZedZedZddZddZ dd Z!dd"d#Z"ed$Z#ed%Z$ed&Z%ed'Z&ed(Z'dd*d+Z(d,d-Z)d.d/Z*d0d1Z+d2d3Z,e,Z-d4d5Z.d6d7Z/d8d9Z0d:d;Z1ddd?Z3dd@dAZ4dBdCZ5dDdEZ6dFdGZ7dHdIZ8dJdKZ9dLdMZ:dNdOZ;dPdQZdVdWZ?dXdYZ@dZd[ZAd\d]ZBd^d_ZCd`daZDdbdcZEdddeZFddfdgZGdhdiZHddjdkZIdldmZJdndoZKddpdqZLdrdsZMdtduZNddvdwZOdxdyZPdzd{ZQdd|d}ZRdd~dZSddZTddZUddZVdddZWddZXdddZYdddZZddZ[ddZ\ ! ! ! ) ) !dddZ]dddZ^ddZ_ddZ` ! ! ) ) ) )dddZaddZbddZcddZddddZedddZfddZgddZhddZiedZjddZkddZldddZmddZn )dddZoddZpd!S)ilocalrepositorymainzzMain interface for local repositories. This currently captures the reality of things - not how things should be. zAConstant nodes matching the hash function used by the repository.z;null revision for the hash function used by the repository.z9Set of requirements that this repo is capable of opening.z#Set of requirements this repo uses.atSet of "features" this repository supports. A "feature" is a loosely-defined term. It can refer to a feature in the classical sense or can describe an implementation detail of the repository. For example, a ``readonly`` feature may denote the repository as read-only. Or a ``revlogfilestore`` feature may denote that the repository is using revlogs for file storage. The intent of features is to provide a machine-queryable mechanism for repo consumers to test for various repository characteristics. Features are similar to ``requirements``. The main difference is that requirements are stored on-disk and represent requirements to open the repository. Features are more run-time capabilities of the repository and more granular capabilities (which may be derived from requirements). z1Name of the repoview that is active on this repo.z)VFS used to access the working directory.zcVFS rooted at the .hg directory. Used to access repository data not in the store. zVFS rooted at the store. Used to access repository data in the store. Typically .hg/store. But can point elsewhere if the store is shared. z*Path to the root of the working directory.zPath to the .hg directory.z8The filesystem path that was used to construct the repo.zA pathauditor for the working directory. This checks if a path refers to a nested repository. Operates on the filesystem. z{A pathauditor for the working directory. This is like ``auditor`` except it doesn't do filesystem checks. z-Original ui instance passed into constructor.z#Main ui instance for this instance.z@Path to the .hg directory of the repo this repo was shared from.zA store instance.zPath to the store.zAlias to self.store.join.zPA VFS used to access the cache directory. Typically .hg/cache. zjA VFS used to access the cache directory dedicated to working copy Typically .hg/wcache. z'Holds sets of revisions to be filtered.zA ``namespaces`` instance.z7The way files copies should be dealt with in this repo.cCr )z$Close the handle on this repository.Nr r r r r rNr zilocalrepositorymain.closecCr )z6Obtain an object conforming to the ``peer`` interface.Nr r r r r rQr zilocalrepositorymain.peercCr )z+Obtain an unfiltered/raw view of this repo.Nr r r r r unfilteredTr zilocalrepositorymain.unfilteredNcCr )z'Obtain a named view of this repository.Nr )rvisibilityexceptionsr r r filteredWr zilocalrepositorymain.filteredzA store of obsolescence data.z!A handle on the changelog revlog.z|An instance conforming to the ``imanifestlog`` interface. Provides access to manifests for the repository. zWorking directory state.z2Matcher patterns for this repository's narrowspec.FcCr )z$Obtain a matcher for the narrowspec.Nr )r includeexactr r r narrowmatchkr z ilocalrepositorymain.narrowmatchcCr )z*Define the narrowspec for this repository.Nr ) newincludes newexcludesr r r setnarrowpatsnr z"ilocalrepositorymain.setnarrowpatscCr )zTry to resolve a changectx.Nr changeidr r r roqr z ilocalrepositorymain.__getitem__cCr )zWhether a changeset exists.Nr rr r r rptr z!ilocalrepositorymain.__contains__cCr )zAlways returns True.Tr r r r r rwz ilocalrepositorymain.__nonzero__cCr )z-Returns the number of changesets in the repo.Nr r r r r rl}r zilocalrepositorymain.__len__cCr )z(Iterate over revisions in the changelog.Nr r r r r rur zilocalrepositorymain.__iter__cGr )z5Evaluate a revset. Emits revisions. Nr exprrLr r r r{r zilocalrepositorymain.revscGr )z?Evaluate a revset. Emits changectx instances. Nr rr r r setr zilocalrepositorymain.setcCr )z1Find revisions matching one of the given revsets.Nr )specsuser localaliasr r r anyrevsr zilocalrepositorymain.anyrevscCr )z8Returns a string representing the location of this repo.Nr r r r r r r zilocalrepositorymain.urlcKr )z Call a hook.Nr )rthrowrLr r r hookr zilocalrepositorymain.hookcCr )z Return a mapping of tag to node.Nr r r r r tagsr zilocalrepositorymain.tagscCr )zReturn the type of a given tag.Nr )tagnamer r r tagtyper zilocalrepositorymain.tagtypecCr )z*Return a list of tags ordered by revision.Nr r r r r tagslistr zilocalrepositorymain.tagslistcCr )z'Return the tags associated with a node.Nr rvr r r nodetagsr zilocalrepositorymain.nodetagscCr )zdatardbackgroundcloser+r r r wwriter zilocalrepositorymain.wwritecCr )z9Resolve data for writing to the wvfs, using data filters.Nr )r>r@r r r wwritedatar zilocalrepositorymain.wwritedatacCr )z0Obtain the current transaction instance or None.Nr r r r r currenttransactionr z'ilocalrepositorymain.currenttransactioncCr )z2Open a new transaction to write to the repository.Nr )descreportr r r rr z ilocalrepositorymain.transactioncCr )z=Returns a list of (vfs, path) for files to undo transactions.Nr r r r r undofilesr zilocalrepositorymain.undofilescCr )z%Roll back an interrupted transaction.Nr r r r r recoverr zilocalrepositorymain.recovercCr )z7Undo the last transaction. DANGEROUS. Nr )dryrunforcer r r rollbackr zilocalrepositorymain.rollbackcCr )zWarm repo caches.Nr )rfullcachesr r r updatecachesr z!ilocalrepositorymain.updatecachescCr )z6Invalidate cached data due to the repository mutating.Nr r r r r invalidatecachesr z%ilocalrepositorymain.invalidatecachescCrFrGr r r r r invalidatevolatilesetsrJz+ilocalrepositorymain.invalidatevolatilesetscCr )zInvalidate the dirstate.Nr r r r r invalidatedirstater z'ilocalrepositorymain.invalidatedirstatecCrFrGr )clearfilecacher r r invalidate rJzilocalrepositorymain.invalidatecCrFrGr r r r r invalidateall rJz"ilocalrepositorymain.invalidateallTcCr )z5Lock the repository store and return a lock instance.Nr waitr r r lockr zilocalrepositorymain.lockcCr )z+Lock the non-store parts of the repository.Nr rUr r r wlockr zilocalrepositorymain.wlockcCr )z&Return the wlock if it's held or None.Nr r r r r currentwlockr z!ilocalrepositorymain.currentwlockcCrFrGr )wctxrstatusfailr r r checkcommitpatternsrJz(ilocalrepositorymain.checkcommitpatternsrcCr )z%Add a new revision to the repository.Nr )rr daterrJeditorextrar r r commitr zilocalrepositorymain.commitcCr )z.Commit a commitctx instance to the repository.Nr )ctxrorigctxr r r commitctx'r zilocalrepositorymain.commitctxcCr )z;Inform the repository that nodes are about to be destroyed.Nr r r r r destroying*r zilocalrepositorymain.destroyingcCr )z5Inform the repository that nodes have been destroyed.Nr r r r r destroyed-r zilocalrepositorymain.destroyed.cCr )z,Convenience method to call repo[x].status().Nr )rrrignoredrunknown listsubreposr r r r[0r zilocalrepositorymain.statuscCrFrGr )psr r r addpostdsstatus;rJz$ilocalrepositorymain.addpostdsstatuscCrFrGr r r r r postdsstatus>rJz!ilocalrepositorymain.postdsstatuscCrFrGr r r r r clearpostdsstatusArJz&ilocalrepositorymain.clearpostdsstatuscCr )z(Obtain list of nodes that are DAG heads.Nr )ryr r r r-Dr zilocalrepositorymain.headscCrFrGr )branchryclosedr r r branchheadsGrJz ilocalrepositorymain.branchheadscCrFrGr r.r r r rDJrJzilocalrepositorymain.branchescCrFrGr rAr r r rCMrJzilocalrepositorymain.betweencCrFrGr )pushopr r r checkpushPrJzilocalrepositorymain.checkpushzutil.hooks instance.cCrFrGr r7r r r r:UrJzilocalrepositorymain.pushkeycCrFrGr r1r r r r3XrJzilocalrepositorymain.listkeyscCrFrGr r#r r r r)[rJz"ilocalrepositorymain.debugwireargscCrFrGr )rr r r savecommitmessage^rJz&ilocalrepositorymain.savecommitmessagecCrFrGr )kindcategoryrcomputerrdreplacer r r register_sidedata_computerasz/ilocalrepositorymain.register_sidedata_computercCrFrGr )rvr r r register_wanted_sidedatafrJz-ilocalrepositorymain.register_wanted_sidedatarGr)FNrr)FF)NFNr )rNNNFFN)rgNNFFFFrr>)qrrrrrrrr supported requirementsfeatures filternamewvfsvfssvfsrootrorigrootauditor nofsauditorbaseuir sharedpathstorespathsjoincachevfs wcachevfsfilteredrevcachenamesfilecopiesmoderrrrobsstore changelog manifestlogdirstate narrowpatsrrrorprrrlrur{rr"r r$r%r'r(r)r*r r+r-r.r6r0r0rr1r2r3r5r6r8r9r;r=r?rBrCrDrrGrHrKrNrOrPrQrSrTrWrXrYr]rardrerfr[rlrmrnr-rqrDrCrsprepushoutgoinghooksr:r3r)rtryrzr r r r rsL                                rc@rR)completelocalrepositoryz*Complete interface for a local repository.NrTr r r r rjsrc@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ dS)iwireprotocolcommandcacheraRepresents a caching backend for wire protocol commands. Wire protocol version 2 supports transparent caching of many commands. To leverage this caching, servers can activate objects that cache command responses. Objects handle both cache writing and reading. This interface defines how that response caching mechanism works. Wire protocol version 2 commands emit a series of objects that are serialized and sent to the client. The caching layer exists between the invocation of the command function and the sending of its output objects to an output layer. Instances of this interface represent a binding to a cache that can serve a response (in place of calling a command function) and/or write responses to a cache for subsequent use. When a command request arrives, the following happens with regards to this interface: 1. The server determines whether the command request is cacheable. 2. If it is, an instance of this interface is spawned. 3. The cacher is activated in a context manager (``__enter__`` is called). 4. A cache *key* for that request is derived. This will call the instance's ``adjustcachekeystate()`` method so the derivation can be influenced. 5. The cacher is informed of the derived cache key via a call to ``setcachekey()``. 6. The cacher's ``lookup()`` method is called to test for presence of the derived key in the cache. 7. If ``lookup()`` returns a hit, that cached result is used in place of invoking the command function. ``__exit__`` is called and the instance is discarded. 8. The command function is invoked. 9. ``onobject()`` is called for each object emitted by the command function. 10. After the final object is seen, ``onfinished()`` is called. 11. ``__exit__`` is called to signal the end of use of the instance. Cache *key* derivation can be influenced by the instance. Cache keys are initially derived by a deterministic representation of the command request. This includes the command name, arguments, protocol version, etc. This initial key derivation is performed by CBOR-encoding a data structure and feeding that output into a hasher. Instances of this interface can influence this initial key derivation via ``adjustcachekeystate()``. The instance is informed of the derived cache key via a call to ``setcachekey()``. The instance must store the key locally so it can be consulted on subsequent operations that may require it. When constructed, the instance has access to a callable that can be used for encoding response objects. This callable receives as its single argument an object emitted by a command function. It returns an iterable of bytes chunks representing the encoded object. Unless the cacher is caching native Python objects in memory or has a way of reconstructing the original Python objects, implementations typically call this function to produce bytes from the output objects and then store those bytes in the cache. When it comes time to re-emit those bytes, they are wrapped in a ``wireprototypes.encodedresponse`` instance to tell the output layer that they are pre-encoded. When receiving the objects emitted by the command function, instances can choose what to do with those objects. The simplest thing to do is re-emit the original objects. They will be forwarded to the output layer and will be processed as if the cacher did not exist. Implementations could also choose to not emit objects - instead locally buffering objects or their encoded representation. They could then emit a single "coalesced" object when ``onfinished()`` is called. In this way, the implementation would function as a filtering layer of sorts. When caching objects, typically the encoded form of the object will be stored. Keep in mind that if the original object is forwarded to the output layer, it will need to be encoded there as well. For large output, this redundant encoding could add overhead. Implementations could wrap the encoded object data in ``wireprototypes.encodedresponse`` instances to avoid this overhead. cCr )zCMarks the instance as active. Should return self. Nr r r r r __enter__r z$iwireprotocolcommandcacher.__enter__cCr )zCalled when cacher is no longer used. This can be used by implementations to perform cleanup actions (e.g. disconnecting network sockets, aborting a partially cached response. Nr )exctypeexcvalueexctbr r r __exit__r z#iwireprotocolcommandcacher.__exit__cCr )arInfluences cache key derivation by adjusting state to derive key. A dict defining the state used to derive the cache key is passed. Implementations can modify this dict to record additional state that is wanted to influence key derivation. Implementations are *highly* encouraged to not modify or delete existing keys. Nr rr r r adjustcachekeystater z.iwireprotocolcommandcacher.adjustcachekeystatecCr )a~Record the derived cache key for this request. Instances may mutate the key for internal usage, as desired. e.g. instances may wish to prepend the repo name, introduce path components for filesystem or URL addressing, etc. Behavior is up to the cache. Returns a bool indicating if the request is cacheable by this instance. Nr r4r r r setcachekeyr z&iwireprotocolcommandcacher.setcachekeycCr )aAttempt to resolve an entry in the cache. The instance is instructed to look for the cache key that it was informed about via the call to ``setcachekey()``. If there's no cache hit or the cacher doesn't wish to use the cached entry, ``None`` should be returned. Else, a dict defining the cached result should be returned. The dict may have the following keys: objs An iterable of objects that should be sent to the client. That iterable of objects is expected to be what the command function would return if invoked or an equivalent representation thereof. Nr r r r r r6r z!iwireprotocolcommandcacher.lookupcCr )aOCalled when a new object is emitted from the command function. Receives as its argument the object that was emitted from the command function. This method returns an iterator of objects to forward to the output layer. The easiest implementation is a generator that just ``yield obj``. Nr )objr r r onobjectr z#iwireprotocolcommandcacher.onobjectcCr )zCalled after all objects have been emitted from the command function. Implementations should return an iterator of objects to forward to the output layer. This method can be a generator. Nr r r r r onfinishedr z%iwireprotocolcommandcacher.onfinishedN) rrrrrrrrr6rrr r r r rpsR   rN)C __future__ri18nrrrr REPO_FEATURE_REVLOG_FILE_STORAGEREPO_FEATURE_SHARED_STORAGEREPO_FEATURE_LFSREPO_FEATURE_STREAM_CLONEREPO_FEATURE_SIDE_DATA!REPO_FEATURE_SHALLOW_FILE_STORAGEREVISION_FLAG_CENSOREDREVISION_FLAG_ELLIPSISREVISION_FLAG_EXTSTOREDREVISION_FLAG_HASCOPIESINFOREVISION_FLAGS_KNOWNrCG_DELTAMODE_PREVCG_DELTAMODE_FULLCG_DELTAMODE_P1CACHE_BRANCHMAP_ALLCACHE_BRANCHMAP_SERVEDCACHE_CHANGELOG_CACHECACHE_FULL_MANIFESTCACHE_FILE_NODE_TAGSCACHE_MANIFESTLOG_CACHECACHE_REV_BRANCHCACHE_TAGS_DEFAULTCACHE_TAGS_SERVEDCACHES_DEFAULT CACHES_ALLrCACHES_POST_CLONEdiscard Interfacerrrr@rKrOrSrU implementerobjectrr]r`rkrtrrrrrrrrrrr rrrr r r r s     0Z!:H4eksC P=