https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/manifest.cpython-310.pyc
o

�]Lb�-�@s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
ddlmZmZmZmZmZmZmZmZmZddlmZmZdd	lmZe�d
�Zej Z dZ!dd
�Z"dd�Z#Gdd�de$�Z%Gdd�de$�Z&dd�Z'dd�Z(hd�Z)Gdd�de$�Z*zej+Z*Wn	e,y�Ynwe�-ej.�Gdd�de$��Z/d@dd�Z0dd �Z1d!d"�Z2d#d$�Z3d%d&�Z4e�-ej.�Gd'd(�d(e$��Z5Gd)d*�d*ej6�Z7d+Z8Gd,d-�d-e9�Z:e�-ej;�Gd.d/�d/e$��Z<e�-ej=�Gd0d1�d1e$��Z>e�-ej?�Gd2d3�d3e$��Z@e�-ejA�Gd4d5�d5e$��ZBe�-ej?�Gd6d7�d7e$��ZCe�-ejA�Gd8d9�d9e$��ZDGd:d;�d;e5�ZEGd<d=�d=eD�ZFGd>d?�d?e<�ZGdS)A�)�absolute_importN�)�_)�bin�hex�nullrev)�getattr)	�encoding�error�match�mdiff�pathutil�policy�pycompat�revlog�util)�
repositoryr)�	constants�parsersi�ccs��|r|dd�dkrtd��d}|��D]D}|dur#||kr#td��|}|�d�\}}t|�}|dd�}|tvrE|dd�}|d8}nd}|d|krQtd	��|t|�|fVqdS)
N����
�"Manifest did not end in a newline.�#Manifest lines not in sorted order.�r���Invalid manifest line)�
ValueError�
splitlines�split�len�_manifestflagsr)�nodelen�data�prev�l�f�n�nl�flags�r*�4/usr/lib/python3/dist-packages/mercurial/manifest.py�_parse0s&�
�r,cCsLg}g}|D]\}}}|�|�|�d|t|�|f�qt|�d�|�S)N�%s%s%s
r)�appendr�_checkforbidden�join)�it�files�linesr&r'�flr*r*r+�_textKs

r5c@�(eZdZdd�Zdd�Zdd�ZeZdS)�lazymanifestitercCsd|_||_dS�Nr)�pos�lm��selfr:r*r*r+�__init__Y�
zlazymanifestiter.__init__cC�|S�Nr*�r<r*r*r+�__iter__]�zlazymanifestiter.__iter__cCsnz|j�|j�\}}Wn	tyt�w|dkr$|jd7_|dS|jd7_|�d|�}|||�S)Nrrrr)r:�_getr9�
IndexError�
StopIteration�find)r<r#r9�zeroposr*r*r+�next`s�zlazymanifestiter.nextN��__name__�
__module__�__qualname__r=rBrI�__next__r*r*r*r+r7Xs
r7c@r6)�lazymanifestiterentriescC�||_d|_dSr8)r:r9r;r*r*r+r=pr>z lazymanifestiterentries.__init__cCr?r@r*rAr*r*r+rBtrCz lazymanifestiterentries.__iter__cCs
z|j�|j�\}}Wn	tyt�w|dkr"|jd7_|S|�d|�}|�d|�}|dks:|dks:||kr?t�d��||d|�}|tvrR||d}n||d}d}|d|jj	krgt�d��t
||jj|j|d|�}|jd7_|||�||fS)Nrrrrrrr)r:rDr9rErFrGr
�StorageErrorr!�_nodelen�	unhexlify�	extrainfo)r<r#r9rH�nlposr)�hlen�hashvalr*r*r+rIws0�

�zlazymanifestiterentries.nextNrJr*r*r*r+rOos
rOcCs,t||||��}|r|t|d@�7}|S)N�)r�chr)r#�extrar9�length�sr*r*r+rS�srScCs||k||kSr@r*)�a�br*r*r+�_cmp��r_>r�l�t�xc@s�eZdZdZ				d,dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd-d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�ZdS).�
_lazymanifesta�A pure python manifest backed by a byte string.  It is supplimented with
    internal lists as it is modified, until it is compacted back to a pure byte
    string.

    ``data`` is the initial manifest data.

    ``positions`` is a list of offsets, one per manifest entry.  Positive
    values are offsets into ``data``, negative values are offsets into the
    ``extradata`` list.  When an entry is removed, its entry is dropped from
    ``positions``.  The values are encoded such that when walking the list and
    indexing into ``data`` or ``extradata`` as appropriate, the entries are
    sorted by filename.

    ``extradata`` is a list of (key, hash, flags) for entries that were added or
    modified since the manifest was created or compacted.
    NFcCs|||_|dur!|�|�|_dgt|j�|_||_g|_d|_dS|dd�|_|dd�|_|dd�|_||_||_dS)NrF)rR�	findlines�	positionsr rTr#�	extradata�hasremovals)r<r"r#rfrTrgrhr*r*r+r=�s	

z_lazymanifest.__init__cCs�|sgS|�d�}|dks|dd�dkrtd��dg}|d|�d��}|t|�dkrd|dkrd|�|d�||d|�d|d��}||krNtd��|}|�d|d�}|t|�dkrd|dks1|S)Nrrrrrrr)rGrr r.)r<r#r9rfr$�nextsr*r*r+re�s 
�z_lazymanifest.findlinescCs0|j|}|dkr|j|fS|j|ddfS)Nrrr)rfr#rg)r<�indexr9r*r*r+rD�s

z_lazymanifest._getcCs8|dkr|j||j�d|d��S|j|ddS)Nrrr)r#rGrg)r<r9r*r*r+�_getkey�sz_lazymanifest._getkeycCsvd}t|j�d}||kr9||d}|j|}|�|�}t||�}|dkr(|S|dkr1|d}n|d}||ks
dS)Nrrrr�r rfrkr_�r<�key�first�last�midpoint�nextpos�	candidate�rr*r*r+�bsearch�s



�z_lazymanifest.bsearchcCs~d}t|j�d}||kr;||d}|j|}|�|�}t||�}|dkr*|dfS|dkr3|d}n|d}||ks
|dfS)NrrrTFrlrmr*r*r+�bsearch2�s



�z_lazymanifest.bsearch2cCs|�|�dkS�Nr)ru�r<rnr*r*r+�__contains__�z_lazymanifest.__contains__c
Cs,t|t�s	td��|�|�}|dkrt�|�|�\}}|dkr'|d|dfS|�d|�}|�d|�}d|krAt|j�ksDJ�J�t|j	�t|j�ksPJ�|dks\|dks\||krat
�d��||d}||d|�}|tvrx|d8}nd	}|d|j
kr�t
�d��t||j	||d|�}	|	|fS)
Ns'getitem: manifest keys must be a bytes.rrrrrrrr)�
isinstance�bytes�	TypeErrorru�KeyErrorrDrGr rfrTr
rQr!rRrS)
r<rn�needler#r9rHrUrVr)rWr*r*r+�__getitem__s.

"


z_lazymanifest.__getitem__cCs�|�|�\}}|st�|j|}|jd|�|j|dd�|_|jd|�|j|dd�|_|dkrN|jd|�d|j|dd�|_d|_dSdS)NrrrT)rvr~rfrTr#rh)r<rnr�found�curr*r*r+�__delitem__-s
""&
�z_lazymanifest.__delitem__cCsVt|t�s	td��t|t�rt|�dkrtd��|d}t|t�r't|�dvr+td��|d}t|t�r:t|�dkr?td|��|�|�\}}|rv|j|}|dkr`|||df|j|d<dS|j�|||df�t|j�|j|<dS|j�|||df�|jd|�t|j�g|j|d�|_|j	d|�dg|j	|d�|_	dS)	Ns-setitem: manifest keys must be a byte string.rs1Manifest values must be a tuple of (node, flags).r��� s-node must be a 20-byte or 32-byte byte stringrs'flags must a 0 or 1 byte string, got %r)
r{r|r}�tupler rvrfrgr.rT)r<rn�valuerWr)rr�r9r*r*r+�__setitem__:s8
�

��� �z_lazymanifest.__setitem__cCst|j|j|j|j|j|j�Sr@)rdrRr#rfrTrgrhrAr*r*r+�copy]s�z_lazymanifest.copyc	Cst|j�dkr|jsdSg}d}d}dgt|j�|_|t|j�kr�|j|dkr�|j|}|}	||j|<|d7}|t|j�ksH|j|dkrIn |jrZ|j�d||j|�dkrZn||j||7}|j|}q1|j�d|�}|dkrx|d7}|||7}|�|j||��nc|t|j�kr�|j|dkr�|j|}|j|d}|�|�|��||j|<d}t|d�dkr�d	}t|d�|kr�t	|d|d�|j|<|t|d�7}|d7}|t|j�kr�|j|dks�|t|j�ks"d
�
|�|_d|_g|_dS)NrTrs
rrr��r�rF)r rgrhrfrTr#rGr.�_pack�ordr0)	r<r%�i�offsetr��last_cut�end_cut�trVr*r*r+�_compacths\

��
�

��/
z_lazymanifest._compactcCs8|d}t|�dvsJ�|ddt|�|ddS)Nrr�rrrr)r r)r<�dr'r*r*r+r��s z_lazymanifest._packcCs|��|jSr@)r�r#rAr*r*r+�text�sz_lazymanifest.textcCs�i}|��D]+\}}}||vr||fdf||<q||}||f|kr+||f|f||<q|r1d||<q|��D]\}}}||vrGd||ff||<q6|S)z2Finds changes between the current manifest and m2.�NrN)�iterentries)r<�m2�clean�diff�fn�e1r)�e2r*r*r+r��s��z_lazymanifest.diffcC�t|�Sr@)rOrAr*r*r+r���z_lazymanifest.iterentriescCr�r@�r7rAr*r*r+�iterkeys�r�z_lazymanifest.iterkeyscCr�r@r�rAr*r*r+rB�r�z_lazymanifest.__iter__cC�
t|j�Sr@)r rfrAr*r*r+�__len__��
z_lazymanifest.__len__cCs8t|jd�}|��D]\}}}||�r||f||<q
|Sr�)rdrRr�)r<�filterfn�cr&r'r4r*r*r+�
filtercopy�s�z_lazymanifest.filtercopy)NNNF�F)rKrLrM�__doc__r=rerDrkrurvryr�r�r�r�r�r�r�r�r�r�rBr�r�r*r*r*r+rd�s4
�	
#;
rdc@s�eZdZd<dd�Zdd�Zdd�Zdd	�Zd
d�ZeZdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd=dd�Zedd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd>d(d)�Zd*d+�Zd=d,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z dS)?�manifestdictrcCs||_t||�|_dSr@)rRrd�_lm)r<r"r#r*r*r+r=�szmanifestdict.__init__cCs|j|dSr8�r�rxr*r*r+r��rzzmanifestdict.__getitem__cCs
|j|Sr@r�rxr*r*r+rG�r�zmanifestdict.findcCr�r@�r r�rAr*r*r+r��r�zmanifestdict.__len__cCst|j�dkSr8r�rAr*r*r+�__nonzero__�szmanifestdict.__nonzero__cCs||�|�f|j|<dSr@)r)r�)r<rn�noder*r*r+r��szmanifestdict.__setitem__cCs|durdS||jvS�NFr�rxr*r*r+ry�s
zmanifestdict.__contains__cCs|j|=dSr@r�rxr*r*r+r���zmanifestdict.__delitem__cC�
|j��Sr@)r�rBrAr*r*r+rB�r�zmanifestdict.__iter__cCr�r@)r�r�rAr*r*r+r�r�zmanifestdict.iterkeyscC�t|���Sr@��listr�rAr*r*r+�keysr�zmanifestdict.keysNcsP|durt�|dd��}t��|����fdd�|�|�D�S�fdd�|D�S)�7Set of files in this manifest that are not in the otherNcS�dSr@r*)�path�msgr*r*r+�<lambda>	�z)manifestdict.filesnotin.<locals>.<lambda>c�h|]}|�vr|�qSr*r*��.0r&)�sm2r*r+�	<setcomp>�z*manifestdict.filesnotin.<locals>.<setcomp>cr�r*r*r�)r�r*r+r�r�)�matchmod�badmatch�set�walk)r<r�rr*)r�r�r+�
filesnotins
zmanifestdict.filesnotincC�
t�|�Sr@�r
�dirsrAr*r*r+�_dirs�
zmanifestdict._dirscC�|jSr@�r�rAr*r*r+r��zmanifestdict.dirscCs
||jvSr@r�)r<�dirr*r*r+�hasdirr�zmanifestdict.hasdircs:|��}t|�dko|��p|��ot�fdd�|D��S)znChecks whether we can correctly and quickly iterate over matcher
        files instead of over manifest files.�dc3s�|]}|�vVqdSr@r*)r�r�rAr*r+�	<genexpr>��z.manifestdict._filesfastpath.<locals>.<genexpr>)r2r �isexact�prefix�all)r<rr2r*rAr+�_filesfastpaths
�zmanifestdict._filesfastpathccs��|��rt|�D]}|Vq	dSt|���}|�|�r,t|�D]	}||vr)|Vq dS|D]}||vr9|�|�||�r@|Vq.|�d�t|�D]
}|�|�sW|�	|d�qJdS)z�Generates matching file names.

        Equivalent to manifest.matches(match).iterkeys(), but without creating
        an entirely new manifest.

        It also reports nonexistent files by marking them bad with match.bad().
        Nr)
�always�iterr�r2r��sorted�remove�discardr��bad�r<rr&�fsetr�r*r*r+r�!s0�
�
�

��zmanifestdict.walkcCsn|��r|��S|�|�r)t|j�}|j}|��D]
}||vr&|||j|<q|St|j�}|j�|�|_|S)z6generate a new manifest filtered by the match argument)r�r�r�r�rRr�r2r�)r<r�mr:r�r*r*r+�_matchesFs

�
zmanifestdict._matchesFcCs6|r|�|�}|�|�}|j||d�S|j�|j|�S)�zFinds changes between the current manifest and m2.

        Args:
          m2: the manifest to which this manifest should be compared.
          clean: if true, include files unchanged between these manifests
                 with a None value in the returned dictionary.

        The result is returned as a dict with filename as key and
        values of the form ((n1,fl1),(n2,fl2)), where n1/n2 is the
        nodeid in the current/other manifest and fl1/fl2 is the flag
        in the current/other manifest. Where the file does not exist,
        the nodeid will be None and the flags will be the empty
        string.
        �r�)r�r�r�)r<r�rr��m1r*r*r+r�Ws


zmanifestdict.diffcCs&|tvrtd��|||f|j|<dS)N�Invalid manifest flag set.)r!r}r�)r<rn�flagr*r*r+�setflaglszmanifestdict.setflagcCs(z|j|dWSty|YSwr8�r�r~)r<rn�defaultr*r*r+�getqs
�zmanifestdict.getcCs&z|j|dWStyYdSw)Nrrr�rxr*r*r+r)ws
�zmanifestdict.flagscCst|j�}|j��|_|Sr@)r�rRr�r�)r<r�r*r*r+r�}s
zmanifestdict.copycC�dd�|j��D�S)Ncs��|]	}|dd�VqdS�Nrr*�r��xr*r*r+r����z%manifestdict.items.<locals>.<genexpr>�r�r�rAr*r*r+�items��zmanifestdict.itemscCr�)Ncsr�r�r*r�r*r*r+r��r�z)manifestdict.iteritems.<locals>.<genexpr>r�rAr*r*r+�	iteritems�r�zmanifestdict.iteritemscCr�r@r�rAr*r*r+r��r�zmanifestdict.iterentriescCr�r@)r�r�rAr*r*r+r��r�zmanifestdict.textcCsTg}d}d}dg}d}t�|�}t|�}t|�tkr�|D]]\}	}
t||	|�\}}|
s;|j|	\}}
d|	t|�|
f}n||krGtt	d�|	��d}|durc||krc||krc||kr[|}|rb|�
|�q|durr|�
||d�|�g�|}|}|g}q|dur�|�
||d�|�g�t||�\}}||fSt
|���}t�t�|�t�|��}||fS)z�Given a base manifest text as a bytearray and a list of changes
        relative to that text, compute a delta that can be used by revlog.
        Nrrr-s!failed to remove %s from manifest)r�bufferr�r �FASTDELTA_TEXTDIFF_THRESHOLD�_msearchr�r�AssertionErrorrr.r0�
_addlistdelta�	bytearrayr�r�textdiff)r<�base�changes�delta�dstart�dend�dline�start�addbufr&�todelete�end�hr4r%�	deltatext�	arraytextr*r*r+�	fastdelta�sL

�
�	��zmanifestdict.fastdelta�rr@r�)!rKrLrMr=r�rGr�r��__bool__r�ryr�rBr�r�r��
propertycacher�r�r�r�r�r�r�r�r�r)r�r�r�r�r�r
r*r*r*r+r��s>


	%

r�c	s��fdd�}|s
||fSt���|s�}||kr`||d}|}|dkrA�|d|�dkrA|d8}|dkrA�|d|�dks/||d�}t�||��|krZ||dd�d}n|}||ks||d�}�||�}||kr|||dd�}||dfS||fS)	aEreturn a tuple (start, end) that says where to find s within m.

    If the string is found m[start:end] are the line containing
    that string.  If start == end the string was not found and
    they indicate the proper sorted insertion point.

    m should be a buffer, a memoryview or a byte string.
    s is a byte stringcsD|�kr �||d�|kr |d7}|�kr �||d�|ks|S)Nrr*)r�r���lenmr�r*r+�advance�s�z_msearch.<locals>.advancerrrrr�()r r|)	r�r\�lo�hir�midrrr�r*rr+r��s.
�
�

r�cCs6|D]}d|vsd|vrt�td�t�|���qdS)z'Check filenames for illegal characters.r�
s)'\n' and '\r' disallowed in filenames: %rN)r
rQrr�bytestr)r%r&r*r*r+r/�s����r/cCsjd}t�}|D]\}}}||||�7}|r|t|�7}|}q|||d�7}d�dd�|D��}||fS)Nrrcss.�|]\}}}t�d||t|��|VqdS)s>lllN)�struct�packr )r�rr�contentr*r*r+r�
s
��
�z _addlistdelta.<locals>.<genexpr>)r�r0)�addlistr��currentposition�
newaddlistrrrrr*r*r+r��s
�r�cCs,d|vr|�dd�\}}|d|fSd|fS)N�/rr)r)r&r��subpathr*r*r+�_splittopdirsrcCr�r@r*�r\r*r*r+r�r�r�c@s�eZdZd^dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
e
Zdd�Ze
jdd��Zdd�Zdd�Zdd�Zdd�Zdd�ZeZd d!�Zd"d#�Zd$d%�Zd&d'�Zd_d)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z d7d8�Z!d9d:�Z"d_d;d<�Z#e$d=d>��Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)dGdH�Z*dIdJ�Z+dKdL�Z,d`dNdO�Z-dPdQ�Z.dRdS�Z/dTdU�Z0dVdW�Z1dXdY�Z2dZd[�Z3d_d\d]�Z4d(S)a�treemanifestrcCsp||_||_|jj|_|jj|_t|_t|_d|_	i|_
i|_i|_i|_
|r6dd�}|�||�d|_	dSdS)NFcSstd��)Ns4treemanifest constructor only accepts flat manifests)r�)�subdir�submr*r*r+�readsubtree0s�z*treemanifest.__init__.<locals>.readsubtreeT)�_dir�
nodeconstants�nullid�_noder"rR�_noop�	_loadfunc�	_copyfunc�_dirtyr��	_lazydirs�_files�_flags�parse)r<r&r�r�r$r*r*r+r=!s 


�ztreemanifest.__init__cCs
|j|Sr@�r%)r<r�r*r*r+�_subpath8r�ztreemanifest._subpathcCs`|j}|j}t�|j�D]\}\}}}|r!|||�|���||<q|||�|�||<qi|_dSr@)r�r2rr�r-r�)r<�selfdirsrr�r�r$�docopyr*r*r+�_loadalllazy;s�
ztreemanifest._loadalllazycCs`|j�|�}|r.|\}}}|r||�|�|���|j|<n||�|�|�|j|<|j|=dSdSr@)r-r�r2r�r�)r<r��vr�r$r4r*r*r+�	_loadlazyGs
�ztreemanifest._loadlazycCsD|sdS|dks|dkr|��dS|j}|D]}||d�q|S)N�all�thisr)r5r7)r<�visit�loadlazy�kr*r*r+�_loadchildrensetlazyQsz!treemanifest._loadchildrensetlazycCs�g}t�|j�D]\}}|j�|�}|r|d|dkr!|�|�qt�|j�D]\}}||jvr6|�|�q(|D]}|�|�|�|�q9dS)amload items in t1 and t2 if they're needed for diffing.

        The criteria currently is:
        - if it's not present in _lazydirs in either t1 or t2, load it in the
          other (it may already be loaded or it may not exist, doesn't matter)
        - if it's present in _lazydirs in both, compare the nodeid; if it
          differs, load it in both
        rN)rr�r-r�r.r7)r<�t1�t2�
toloadlazyr��v1�v2r*r*r+�
_loaddifflazy]s	
�

�
�ztreemanifest._loaddifflazycCs:|��t|j�}|��|j��D]}||��7}q|Sr@)�_loadr r.r5r��valuesr�)r<�sizer�r*r*r+r�ss
ztreemanifest.__len__cCs
|��Sr@��_isemptyrAr*r*r+r�{r�ztreemanifest.__nonzero__cCsX|��|js|jrtdd�|j��D��rdS|��|jp+tdd�|j��D��S)Ncss�|]}|��VqdSr@rG�r�r�r*r*r+r��s�z(treemanifest._isempty.<locals>.<genexpr>Fcss�|]}|��VqdSr@rGrIr*r*r+r��r�)rDr.r��anyrEr5r�rAr*r*r+rH�s�� ztreemanifest._isemptycCs*d|jt|j�t|jtu�|jt|�fS)Ns;<treemanifest dir=%s, node=%s, loaded=%r, dirty=%r at 0x%x>)r%rr(�boolr*r)r,�idrAr*r*r+�__repr__�s���ztreemanifest.__repr__cCr�)z}The directory that this tree manifest represents, including a
        trailing '/'. Empty string for the repo root directory.r1rAr*r*r+r��sztreemanifest.dircCs|jrJ�|jS)z�This node of this instance. nullid for unsaved instances. Should
        be updated when the instance is read or written from a revlog.
        �r,r(rAr*r*r+r��s
ztreemanifest.nodecCrPr�)r(r,�r<r�r*r*r+�setnode�r>ztreemanifest.setnodeccsx�|��|��tt�|j��|j����D]"\}}||jvr/|�|�||j	�
|d�fVq|��D]}|Vq3qdSr�)rDr5r��	itertools�chainr�r�r.r2r/r�r�)r<�pr'r�r*r*r+r��s��
��ztreemanifest.iterentriesccsv�|��|��tt�|j��|j����D]!\}}||jvr)|�|�|fVqt	�
|�D]	\}}||fVq.qdSr@)rDr5r�rQrRr�r�r.r2rr�)r<rSr'r&�snr*r*r+r��s��
��ztreemanifest.itemsccs^�|��|��tt�|j|j��D]}||jvr!|�|�Vq|j|D]}|Vq&qdSr@)rDr5r�rQrRr�r.r2)r<rSr&r*r*r+r��s�
��ztreemanifest.iterkeyscCr�r@r�rAr*r*r+r��r�ztreemanifest.keyscC�|��Sr@)r�rAr*r*r+rB�r�ztreemanifest.__iter__cCsV|durdS|��t|�\}}|r&|�|�||jvrdS|j|�|�S||jvSr�)rDrr7r�ryr.�r<r&r�rr*r*r+ry�s


ztreemanifest.__contains__NcCsP|��t|�\}}|r!|�|�||jvr|S|j|�||�S|j�||�Sr@)rDrr7r�r�r.)r<r&r�r�rr*r*r+r��s

ztreemanifest.getcCs<|��t|�\}}|r|�|�|j|�|�S|j|Sr@)rDrr7r�r�r.rVr*r*r+r��s

ztreemanifest.__getitem__cCsf|��t|�\}}|r |�|�||jvrdS|j|�|�S||jvs*||jvr,dS|j�|d�Sr�)rDrr7r�r)r-r/r�rVr*r*r+r)�s

ztreemanifest.flagscCsJ|��t|�\}}|r|�|�|j|�|�S|j||j�|d�fSr�)rDrr7r�rGr.r/r�rVr*r*r+rGs
ztreemanifest.findcCsn|��t|�\}}|r%|�|�|j|�|�|j|��r$|j|=n
|j|=||jvr2|j|=d|_dS�NT)	rDrr7r�r�rHr.r/r,rVr*r*r+r�s
�

ztreemanifest.__delitem__cCs�|dusJ�|��t|�\}}|r2|�|�||jvr(t|j|�|��|j|<|j|�||�n
t|�dvs:J�||j	|<d|_
dS)Nr�T)rDrr7r�r!r&r2r�r r.r,)r<r&r'r�rr*r*r+r�s


�

ztreemanifest.__setitem__cCsL|jtur|jt}|_||�dS|jtur$|jt}|_||�dSdSr@)r*r)r+)r<�lf�cfr*r*r+rD2s

�ztreemanifest._loadcCs||tvrtd��|��t|�\}}|r4|�|�||jvr*t|j|�|��|j|<|j|�	||�n||j
|<d|_dS)z/Set the flags (symlink, executable) for path f.r�TN)r!r}rDrr7r�r!r&r2r�r/r,)r<r&r)r�rr*r*r+r�:s


�

ztreemanifest.setflagcs`t�j�j�}�j|_�j|_�jtur*�fdd�}�jtur%||�|S||_|S�j|_|S)Ncsh���dd�t��j�D�|_|j}t��j�D]
\}}|��||<qt��j�|_t��j�|_dS)NcSs"i|]
\}\}}}|||df�qS�Tr*)r�r�r'rtr�r*r*r+�
<dictcomp>Ss
��z8treemanifest.copy.<locals>._copyfunc.<locals>.<dictcomp>)	rDrr�r-r�r��dictr.r/)r\�sdirsr�r6rAr*r+r+Qs
�z$treemanifest.copy.<locals>._copyfunc)r!r&r%r(r,r+r)r*)r<r�r+r*rAr+r�Ks

��ztreemanifest.copycsN|r|��s��|�}|�|�}|�|�St�����fdd����|��S)r�cs�|j|jkr|js|jsdS|��|����||�t�|j�D]\}}||jvr6|j|}�||�q"��|���q"|j	D]}||j	vrP��
|�|��qAdSr@)r(r,rDrCrr�r��updater�r.�addr2)r>r?r�r�r�r���_filesnotinr2r<r*r+rans



��z,treemanifest.filesnotin.<locals>._filesnotin)r�r�r�r�)r<r�rr�r*r`r+r�es



ztreemanifest.filesnotincCr�r@r�rAr*r*r+�_alldirs�r�ztreemanifest._alldirscCr�r@)rbrAr*r*r+r��r�ztreemanifest.dirscCs\|��t|�\}}|r |�|�||jvr|j|�|�SdS|d}||jvp-||jvS)NFr)rDrr7r�r�r-)r<r��topdirr"�dirslashr*r*r+r��s

ztreemanifest.hasdirccs��|��rt|�D]}|Vq	dSt|���}|�|�D]}||vr'|�|�|Vq|�d�t|�D]
}|�|�sA|�	|d�q4dS)zxGenerates matching file names.

        It also reports nonexistent files by marking them bad with match.bad().
        Nr)
r�r�r�r2�_walkr�r�r�r�r�r�r*r*r+r��s �


��ztreemanifest.walkccs��|�|jdd��}|sdS|��|�|�}tt|j�t|j��D],}||jvr8|�|�}||�r7|Vq$|rB|dd�|vrP|j|�	|�D]}|VqJq$dS)z5Recursively generates matching file names for walk().Nr)
�visitchildrensetr%rDr=r�r�r�r.r2re)r<rr:rS�fullpr&r*r*r+re�s"�


���ztreemanifest._walkcCs|��r|��S|�|�S)zCrecursively generate a new manifest filtered by the match argument.)r�r��_matches_inner)r<rr*r*r+r��s
ztreemanifest._matchesc	Cs|��r|��S|�|jdd��}|dkr|��St|j|j�}|s%|S|��|jD]*}|dkr7||vr7q,|�|�}||�sAq,|j||j|<||j	vrV|j	||j	|<q,|�
|�}t�|j
�D]\}}|rq|dd�|vrqqb|�|�}|��s||j
|<qb|��s�d|_|S)Nrr8r9T)r�r�rfr%r!r&rDr.r2r/r=rr�r�rhrHr,)	r<rr:�retr�rgr�r#r�r*r*r+rh�s<


�


�ztreemanifest._matches_innercCst��r@)�FastdeltaUnavailable)r<r�r�r*r*r+r
�r�ztreemanifest.fastdeltaFc	s�|r|��s��|�}|�|�}|j|�d�Si�t�j������fdd�}g}|�||�|r?|��\}}||||�|s1�S)r�r�cs^|j|jkr|js|jsdS|��|����||�t�|j�D]\}}|j�|��}|�||f�q"t�|j�D]\}}||jvrK|��|f�q;t�|j	�D]8\}}|j
�|d�}|j	�|d�}	|j
�|d�}
||	kss||
kr�||f|	|
ff�|�|�<qR�r�d�|�|�<qRt�|j	�D]\}}	||j	vr�|j
�|d�}
d|	|
ff�|�|�<q�dS)zicompares two tree manifests and append new tree-manifests which
            needs to be compared to stackNrr�)r(r,rDrCrr�r�r�r.r.r/r2)r>r?�stackr�r�r�r��n1�fl1�n2�fl2�r��	emptytree�resultr<r*r+�_iterativediff	s6
��
��z)treemanifest.diff.<locals>._iterativediff)r�r�r�r!r&�pop)	r<r�rr�r�rs�stacklsr>r?r*rpr+r��s


�ztreemanifest.diffcCs|jo
|jo
|j|jkSr@rN)r<r�r*r*r+�unmodifiedsince0sztreemanifest.unmodifiedsincecCs||j}t|j|�D]2\}}}|dkr|d}||df||<q	d|vr/|||<|r.|�||�q	||j|<|r;||j|<q	dS)NrbrF)r-r,rRr�r.r/)r<r�r$�selflazyr&r'r4r*r*r+r03s�

��ztreemanifest.parsecCs|��t|���S)z3Get the full data of this manifest as a bytestring.)rDr5r�rAr*r*r+r�Jsztreemanifest.textcsb����j�dd�t��j�D�}�fdd��jD�}��fdd��jD�}tt|||��S)z�Get the full data of this directory as a bytestring. Make sure that
        any submanifests have been written first, so their nodeids are correct.
        cSs&g|]\}}|dd�|ddf�qS)Nrrrbr*)r�r�r6r*r*r+�
<listcomp>Us�z(treemanifest.dirtext.<locals>.<listcomp>cs&g|]}|dd��j|jdf�qS)Nrrb)r�r()r�r�rAr*r+rxXs&cs g|]}|�j|�|�f�qSr*)r.r��r)r<r*r+rxYs )	rDr)rr�r-r�r.r5r�)r<�lazydirsr�r2r*ryr+�dirtextOs
�ztreemanifest.dirtextcs��fdd�}||_dS)Ncs|�����d|_dSr�)r0r,r ��gettextr$r*r+�_load_for_read]s
z)treemanifest.read.<locals>._load_for_read)r*)r<r}r$r~r*r|r+�read\s
ztreemanifest.readcs�|��|��|��t|j���fdd�}|�|jdd��}|�|�}|dks.|dkr0d}t�|j�D]+\}}|rE|dd�|vrEq6|||�}	|||�}
|	|jj	krZ|
|	}	}
|||	|
|�q6dS)Ncs(|j�|�}|r|dS|j�|��jSr8)r-r�r�r()r�r��ld�rqr*r+�getnodeisz+treemanifest.writesubtrees.<locals>.getnoderr9r8)
rDr!r&rfr%r=rr�r�r')r<r�r��writesubtreerr�r:r�r#�subp1�subp2r*r�r+�
writesubtreescs$




�ztreemanifest.writesubtreesccs|�|r|�|jdd��sdS|r||jdd��r|V|��|��t�|j�D]\}}|j|d�D]}|Vq5q+dS)z�Returns an iterator of the subtrees of this manifest, including this
        manifest itself.

        If `matcher` is provided, it only returns subtrees that match.
        Nr)�matcher)�visitdirr%rDr5rr�r��walksubtrees)r<r�r�r#�subtreer*r*r+r�}s���ztreemanifest.walksubtrees)rrr@r�)5rKrLrMr=r2r5r7r=rCr�r�rrHr	�	strmethodrMr�r�rPr�r�r�r�r�rBryr�r�r)rGr�r�rDr�r�r�r
rbr�r�r�rer�rhr
r�rvr0r�r{rr�r�r*r*r*r+r!sd









)
=
r!cs�eZdZdZdZ�fdd�Z�fdd�Zdd�Z�fd	d
�Z�fdd�Z	�fd
d�Z
�fdd�Z�fdd�Z�fdd�Z
d�fdd�	Zd�fdd�	Z�ZS)�manifestfulltextcachez�File-backed LRU cache for the manifest cache

    File consists of entries, up to EOF:

    - 20 bytes node, 4 bytes length, <length> manifest data

    These are written in reverse cache order (oldest to newest).

    smanifestfulltextcachecs&tt|��|�d|_d|_d|_dSr�)�superr�r=r,�_read�_opener)r<�max��	__class__r*r+r=�s
zmanifestfulltextcache.__init__c	s�|js|jdur
dSzW|�|j��G}tt|�j}	|�d�}t|�dkr%n,z
t�	d|�d��d}Wn
tj
y<Ynwt|�|��}t|�|krKn|||�qWd�n1s[wYWn	tyjYnwd|_d|_
dS)NTr��>L�rF)r�r��_filer�r�r�rr r�unpackr
r��IOErrorr,)r<�fpr�r�rFr�r�r*r+r�s6
�
�����
zmanifestfulltextcache.readcCs�|jr|jdur
dSzL|j|jdddd��7}|jj}	|j|jvr9|�|j�|�t�	dt
|j���|�|j�||jur?n|j}qWd�WdS1sOwYWdSty`YdSw)N�wT)�
atomictemp�
checkambigr�)
r,r�r��_headr$rn�_cache�writerrr r�r�)r<r�r�r*r*r+r��s,
�
�&�	�zmanifestfulltextcache.writec�|js|��tt|���Sr@)r�rr�r�r�rAr�r*r+r���zmanifestfulltextcache.__len__cs|js|��tt|��|�Sr@)r�rr�r�ry�r<r<r�r*r+ry�sz"manifestfulltextcache.__contains__cr�r@)r�rr�r�rBrAr�r*r+rB�r�zmanifestfulltextcache.__iter__cs>|js|��|j�|�|ju}tt|��|�}|rd|_|SrW)	r�rr�r�r�r�r�r�r,)r<r<�setdirtyr�r�r*r+r��sz!manifestfulltextcache.__getitem__cs*|js|��tt|��||�d|_dSrW)r�rr�r�r�r,)r<r<r6r�r*r+r��s
z!manifestfulltextcache.__setitem__cs(|js|��tt|��|�d|_dSrW)r�rr�r�r�r,r�r�r*r+r��s
z!manifestfulltextcache.__delitem__Ncs"|js|��tt|�j||d�S)N)r�)r�rr�r�r�)r<r<r�r�r*r+r�szmanifestfulltextcache.getFcs*tt|���|rd|_|��d|_dS)NTF)r�r��clearr,r�r��r<�clear_persisted_datar�r*r+r�s

zmanifestfulltextcache.clearr@r�)rKrLrMr�r�r=rr�r�ryrBr�r�r�r�r��
__classcell__r*r*r�r+r��s

r��c@seZdZdZdS)rjz;Exception raised when fastdelta isn't usable on a manifest.N)rKrLrMr�r*r*r*r+rjsrjc@sLeZdZdZ			dBdd�Zdd�Zed	d
��ZdCdd�Zd
d�Z			dDdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdEd%d&�ZdEd'd(�Zd)d*�Zd+d,�Zd-d.�Zdddejdfd/d0�Z			dFd1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!d;d<�Z"					dGd=d>�Z#ed?d@��Z$e$j%dAd@��Z$dS)H�manifestrevlogznA revlog that stores manifest texts. This is responsible for caching the
    full-text manifest contents.
    rNFc
Cs�||_d}d}t|dd�}|dur|�d|�}|�dd�}|p ||_t|�|_|r2|js2Jd|��d}	|r<d	||	}	||_|rE||_nd
|i|_tj|t	j
|jf|	t|�dt|j
�dd�d
�|_|jj|_|jj|_dS)a�Constructs a new manifest revlog

        `indexfile` - used by extensions to have two manifests at once, like
        when transitioning between flatmanifeset and treemanifests.

        `treemanifest` - used to indicate this is a tree manifest revlog. Opener
        options can also be used to make this a tree manifest revlog. The opener
        option takes precedence, so if it is set to True, we ignore whatever
        value is passed in to the constructor.
        r�F�optionsN�manifestcachesize�treemanifests
opts is %rs
00manifestsmeta/rTspersistent-nodemap)�target�radixr��mmaplargeindex�upperboundcomp�persistentnodemap)r&rr��_treeondiskr��_fulltextcache�tree�_dirlogcacher�revlog_constants�KIND_MANIFESTLOGrK�MAXCOMPRESSIONr��_revlogrj�
_generaldelta)
r<r&�openerr��dirlogcacher!�	cachesize�optiontreemanifest�optsr�r*r*r+r=s:



�
zmanifestrevlog.__init__cs^t�|d�sdS|j|j_|�|j�durdSt�|��t�|����fdd�}|�	|�dS)z1Persist the manifestfulltextcache on lock releases	_wlockrefNcsJ|sdS��}��}|dus|durdS|j�d�|urdS|j��dSr�)�manifestlog�
getstorager�r�)�success�repor<��manifestrevlogref�reporefr*r+�persistmanifestcachefszEmanifestrevlog._setupmanifestcachehooks.<locals>.persistmanifestcache)
r�safehasattr�	wcachevfsr�r��_currentlock�	_wlockref�weakref�ref�
_afterlock)r<r�r�r*r�r+�_setupmanifestcachehooksZs


z'manifestrevlog._setupmanifestcachehookscCr�r@)r�rAr*r*r+�
fulltextcachevszmanifestrevlog.fulltextcachecCs(|j��|jj|d�|j|i|_dS�N)r�)r��clearcachesr�r�r�r�r�r*r*r+r�zs
zmanifestrevlog.clearcachescCsF|r|jsJ�||jvrt|j|j||j|jd�}||j|<|j|S)N)r!)r�r�r�r&r�)r<r��mfrevlogr*r*r+�dirlogs

�

zmanifestrevlog.dirlogc
CsDzK||jvr	t��t|�t�dd�t|�D�dd�t|�D��}
|�|j||
�\}}|j�|�|f}
t	�
|�}|j�||||||
�}|j�|�}WnKty�|j
r||s[Jd��|	saJd��||j|�}||j|�}|j|||||||	d�}d}n|��}|j�|||||�}|j�|�}t|�}Ynw|dur�||j|<|S)aadd some manifest entry in to the manifest log

        input:

          m:           the manifest dict we want to store
          transaction: the open transaction
          p1:          manifest-node of p1
          p2:          manifest-node of p2
          added:       file added/changed compared to parent
          removed:     file removed compared to parent

        tree manifest input:

          readtree:    a function to read a subtree
          match:       a filematcher for the subpart of the tree manifest
        cS�g|]}|df�qSr�r*r�r*r*r+rx��z&manifestrevlog.add.<locals>.<listcomp>cSr�rZr*r�r*r*r+rx�r�s,readtree must be set for treemanifest writess/match must be specified for treemanifest writes�rN)r�rjr/�heapq�merger�r
r��revrr��addrevisionr�r�r��_addtreer�r�)r<r��transaction�link�p1�p2�added�removed�readtreer�workr	r�
cachedeltar�r�r'r�r�r*r*r+r_�sD
�
����
zmanifestrevlog.addcs��jdkr|�|�s|�|�r|��S����fdd�}|�||||�|��}	d}
�jdkrD|	|��kr:|��}
n
|	|��krD|��}
|
sZ�j�|	��|��|���}�j�|�}
|�|
�|
S)Nrcs.��|���}|j|��||dd�|d�	dS)N�r�r)r�r�r_)r#r�r�r�sublog�r�r�r<r�r*r+r��s
�z-manifestrevlog._addtree.<locals>.writesubtree)r�rvr�r�r{r�r�rP)r<r�r�r�r�r�r�rr�r�r'r�r*r�r+r��s,
��

�
zmanifestrevlog._addtreecCr�r@)r r�rAr*r*r+r�r�zmanifestrevlog.__len__cCr�r@)r�rBrAr*r*r+rBr�zmanifestrevlog.__iter__cC�|j�|�Sr@)r�r�rOr*r*r+r�	r�zmanifestrevlog.revcCr�r@)r�r��r<r�r*r*r+r�r�zmanifestrevlog.nodecCr�r@)r��lookup�r<r�r*r*r+r�r�zmanifestrevlog.lookupcCr�r@)r��
parentrevsr�r*r*r+r�r�zmanifestrevlog.parentrevscCr�r@)r��parentsrOr*r*r+r�r�zmanifestrevlog.parentscCr�r@)r��linkrevr�r*r*r+r�r�zmanifestrevlog.linkrevcCr�r@)r��	checksizerAr*r*r+r�r�zmanifestrevlog.checksizecC�|jj||d�S�N)�_df)r��revision�r<r�r�r*r*r+r�r`zmanifestrevlog.revisioncCr�r�)r��rawdatar�r*r*r+r�!r`zmanifestrevlog.rawdatacC�|j�||�Sr@)r��revdiff)r<�rev1�rev2r*r*r+r�$rzzmanifestrevlog.revdiffcCr�r@)r��cmp)r<r�r�r*r*r+r�'rzzmanifestrevlog.cmpcCr�r@)r��deltaparentr�r*r*r+r�*r�zmanifestrevlog.deltaparentcC�|jj||||||d�S)N)�
nodesorder�revisiondata�assumehaveparentrevisions�	deltamode�sidedata_helpers)r��
emitrevisions)r<�nodesr�r�r�rrr*r*r+r-�	�zmanifestrevlog.emitrevisionscCr�)N)�alwayscache�
addrevisioncb�duplicaterevisioncb)r��addgroup)r<�deltas�
linkmapperr�rrrr*r*r+r?rzmanifestrevlog.addgroupcCr�r@)r��rawsizer�r*r*r+rQr�zmanifestrevlog.rawsizecCr�r@)r��
getstrippoint)r<�minlinkr*r*r+rTr�zmanifestrevlog.getstrippointcCr�r@)r��strip)r<r
r�r*r*r+rWrzzmanifestrevlog.stripcCr�r@)r�r2rAr*r*r+r2Zr�zmanifestrevlog.filescKs,t|t�s
t�d��|jj||jfi|��S)Ns"expected manifestrevlog to clone())r{r�r
�ProgrammingErrorr��clone)r<�tr�
destrevlog�kwargsr*r*r+r]s

zmanifestrevlog.clonecCs|jj|||||d�S)N)�exclusivefiles�sharedfiles�revisionscount�trackedsize�
storedsize)r��storageinfo)r<rrrrrr*r*r+rcs�zmanifestrevlog.storageinfocCs|jjSr@�r�r�rAr*r*r+r�s�zmanifestrevlog.openercCs||j_dSr@rr�r*r*r+r�ws)rNFr�)NNr@)FNN)FFFFF)&rKrLrMr�r=r��propertyr�r�r�r_r�r�rBr�r�r�r�r�r�r�r�r�r�r�r�r�CG_DELTAMODE_STDrrrrrr2rrr��setterr*r*r*r+r�sl
�>


�L*


�
�
�
r�c@sLeZdZdZdd�Zdd�Zddd�Zd	d
�Zddd
�Zdd�Z	dd�Z
dS)r�a�A collection class representing the collection of manifest snapshots
    referenced by commits in the repository.

    In this situation, 'manifest' refers to the abstract concept of a snapshot
    of the list of files in the given commit. Consumers of the output of this
    class do not care about the implementation details of the actual manifests
    they receive (i.e. tree or flat or lazily loaded, etc).cCsz|j|_d}d}t|dd�}|dur|�d|�}|�d|�}||_||_|j�|�||_i|_t�	|�|jd<||_
dS)NFr�r�r�r�r)r&rr��_treemanifests�
_rootstorer��_narrowmatch�_dirmancacher�lrucachedict�
_cachesize)r<r�r��	rootstore�narrowmatch�usetreemanifestr�r�r*r*r+r=�s
zmanifestlog.__init__cCs|�d|�S)zgRetrieves the manifest instance for the given node. Throws a
        LookupError if not found.
        r)r�rOr*r*r+r��szmanifestlog.__getitem__TcCs�||j�|d�vr|j||S|j��s&|j�|dd��s&t|j||�S|rF|jjr=|r6|�	|��
|�t|||�}n t�
td�|��|rN|j�
|�|jrXt|d|�}nt||�}||jjkrz|j�|�}|svt�|j�}||j|<|||<|S)z�Retrieves the manifest instance for the given node. Throws a
        LookupError if not found.

        `verify` - if True an exception will be thrown if the node is not in
                   the revlog
        r*Nrs9cannot ask for manifest directory '%s' in a flat manifestr)r"r�r!r�r��excludeddirmanifestctxr&r r�r�r��treemanifestctxr
�Abortrr�manifestctxr'rr#r$)r<r�r��verifyr��mancacher*r*r+r��s:
���

zmanifestlog.getcCr�r@)r r�)r<r�r*r*r+r��r�zmanifestlog.getstorageFcCs|j��|jj|d�dSr�)r"r�r r�r�r*r*r+r��s
zmanifestlog.clearcachescCr�r@)r r�rOr*r*r+r��r�zmanifestlog.revcCs|jjj|d�S)N)r�)r r��
update_caches)r<r�r*r*r+r.�r`zmanifestlog.update_cachesNrZr�)rKrLrMr�r=r�r�r�r�r�r.r*r*r*r+r�|s
/
r�c@s6eZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zd	S)
�memmanifestctxcCs||_t|jj�|_dSr@)�_manifestlogr�r&r"�
_manifestdict)r<r�r*r*r+r=�szmemmanifestctx.__init__cC�|j�d�Sr��r0r�rAr*r*r+�_storage�r�zmemmanifestctx._storagecC�t|j�}|����|_|Sr@�r/r0rr�r1�r<�memmfr*r*r+r���
zmemmanifestctx.copycCr�r@)r1rAr*r*r+r�r�zmemmanifestctx.readNc
Cs |��j|j|||||||d�S)Nr�)r4r_r1)r<r�r�r�r�r�r�rr*r*r+r��s�zmemmanifestctx.writer@�rKrLrMr=r4r�rr�r*r*r*r+r/�sr/c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dd
�Z
ddd�Zddd�Zdd�Z
dS)r+zxA class representing a single revision of a manifest, including its
    contents, its parent revs, and its linkrev.
    cCs||_d|_||_dSr@)r0�_datar()r<r�r�r*r*r+r=s
zmanifestctx.__init__cCr2r�r3rAr*r*r+r4r�zmanifestctx._storagecCr�r@�r(rAr*r*r+r�r�zmanifestctx.nodecCr5r@r6r7r*r*r+r�r9zmanifestctx.copycC�|���|j�Sr@�r4r�r(rAr*r*r+r��zmanifestctx.parentscCs�|jdurC|jj}|j|jkrt|j�|_|jS|��}|j|jvr,t	�
|j|j�}n|�|j�}t|�}||j|j<t|j|�|_|jSr@)
r;r0r&r(r'r�r"r4r�rrr�r�)r<�nc�storer�r	r*r*r+rs

�zmanifestctx.readFcCsD|��}|�|j�}|�|�}|tkr||�|�vr|��S|��S)aCalls 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.

        If `shallow` is True, nothing changes since this is a flat manifest.
        )r4r�r(r�rr��	readdeltar�r<�shallowrArtr�r*r*r+�readfast/s
zmanifestctx.readfastcCs:|��}|�|j�}t�|�|�|�|��}t|jj	|�S)a
Returns a manifest containing just the entries that are present
        in this manifest, but not in its p1 manifest. This is efficient to read
        if the revlog delta is already p1.

        Changing the value of `shallow` has no effect on flat manifests.
        )
r4r�r(r�	patchtextr�r�r�r&r")r<rDrArtr�r*r*r+rB=szmanifestctx.readdeltacC�|���|�Sr@�rrGrxr*r*r+rGIrzzmanifestctx.findNr�)rKrLrMr�r=r4r�r�r
r�rrErBrGr*r*r*r+r+�s



r+c@s8eZdZd
dd�Zdd�Zdd�Zdd	�Zddd�Zd
S)�memtreemanifestctxrcCs||_||_t|j�|_dSr@)r0r%r!r&�
_treemanifest)r<r�r�r*r*r+r=Oszmemtreemanifestctx.__init__cCr2r�r3rAr*r*r+r4Tr�zmemtreemanifestctx._storagecCs t|j|jd�}|j��|_|S�N�r�)rIr0r%rJr�r7r*r*r+r�Wszmemtreemanifestctx.copycCr�r@)rJrAr*r*r+r\r�zmemtreemanifestctx.readNc	s.�fdd�}���j�j||||||||d�	S)Ncs�j�||���Sr@�r0r�r)r�r�rAr*r+r�`�z*memtreemanifestctx.write.<locals>.readtreer�)r4r_rJ)	r<r�r�r�r�r�r�rr�r*rAr+r�_s�zmemtreemanifestctx.writerr@r:r*r*r*r+rIMs
rIc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	ddd�Z
ddd�Zdd�ZdS)r)cCs||_||_d|_||_dSr@)r0r%r;r()r<r�r�r�r*r*r+r=rs
ztreemanifestctx.__init__cCsB|jj}|��s|�|jdd��st|jj|j�S|j�|j�Srw)r0r!r�r�r%�excludedmanifestrevlogr&r�)r<r&r*r*r+r4�s
�ztreemanifestctx._storagecs��jdurq�����j�jjjkrt�jj��_�jS�jrFt�jj�jd�}��fdd�}�fdd�}|�	||�|�
�j�|�_�jS�j�jvrVt�
�j�j�}n���j�}t|�}|�j�j<t�jj�j|d��_�jS)NrLcs���j�Sr@)r�r(r*�r<rAr*r+r}�r�z%treemanifestctx.read.<locals>.gettextcs�jj||dd���S)NF)r,rM)r�r#rAr*r+r$�sz)treemanifestctx.read.<locals>.readsubtree)r�r�)r;r4r(r0r&r'r!r�r%rrPr�rrr�r�)r<r�r}r$r�r	r*rPr+r�s,
���ztreemanifestctx.readcCr�r@r<rAr*r*r+r��r�ztreemanifestctx.nodecCs"t|j|jd�}|����|_|SrK)rIr0r%rr�rJr7r*r*r+r��sztreemanifestctx.copycCr=r@r>rAr*r*r+r��r?ztreemanifestctx.parentsFcCs�|��}|r|�|j�}t�|�|�|�|��}t|jj	|�S|�|�|j��}|j
�|j|�
|����}|��}t|j
j|jd�}t�|�|��D]\}	\\}
}\}}
|rb|||	<|
rb|�|	|
�qJ|S)aReturns a manifest containing just the entries that are present
        in this manifest, but not in its p1 manifest. This is efficient to read
        if the revlog delta is already p1.

        If `shallow` is True, this will read the delta for this directory,
        without recursively reading subdirectory manifests. Instead, any
        subdirectory entry will be reported as it appears in the manifest, i.e.
        the subdirectory will be reported among files and distinguished only by
        its 't' flag.
        rL)r4r�r(rrFr�r�r�r&r"r0r�r%r�rr!rr�r�r�)r<rDrArtr��r0�m0r��mdr&�n0�fl0rlrmr*r*r+rB�s $�ztreemanifestctx.readdeltacCsb|��}|�|j�}|�|�}|tkr ||�|�vr |j|d�S|r-t|jj	|�
|j��S|��S)a#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.

        If `shallow` is True, it only returns the entries from this manifest,
        and not any submanifests.
        )rD)r4r�r(r�rr�rBr�r&r"r�rrCr*r*r+rE�s
�ztreemanifestctx.readfastcCrGr@rHrxr*r*r+rG�rzztreemanifestctx.findNr�)
rKrLrMr=r4rr�r�r
r�rBrErGr*r*r*r+r)ps	!


r)cs(eZdZdZ�fdd�Zdd�Z�ZS)�excludeddira�Stand-in for a directory that is excluded from the repository.

    With narrowing active on a repository that uses treemanifests,
    some of the directory revlogs will be excluded from the resulting
    clone. This is a huge storage win for clients, but means we need
    some sort of pseudo-manifest to surface to internals so we can
    detect a merge conflict outside the narrowspec. That's what this
    class is: it stands in for a directory whose node is known, but
    whose contents are unknown.
    cs0tt|��||�||_||jd<d|jd<dS)Nrrb)r�rVr=r(r.r/�r<r&r�r�r�r*r+r=�s
zexcludeddir.__init__cCr?r@r*rAr*r*r+r�	rCzexcludeddir.copy)rKrLrMr�r=r�r�r*r*r�r+rV�s
rVc@s2eZdZdZdd�Zdd�Zddd�Zd	d
�ZdS)
r(zBcontext wrapper for excludeddir - see that docstring for rationalecCs||_||_||_dSr@)r&r%r(rWr*r*r+r=	s
zexcludeddirmanifestctx.__init__cCst|j|j|j�Sr@)rVr&r%r(rAr*r*r+r	rNzexcludeddirmanifestctx.readFcCrUr@)r)r<rDr*r*r+rE	rzexcludeddirmanifestctx.readfastcG�t�d|j��)Ns.attempt to write manifest from excluded dir %s�r
rr%)r<�argsr*r*r+r�	��zexcludeddirmanifestctx.writeNr�)rKrLrMr�r=rrEr�r*r*r*r+r(		s
r(c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rOa\Stand-in for excluded treemanifest revlogs.

    When narrowing is active on a treemanifest repository, we'll have
    references to directories we can't see due to the revlog being
    skipped. This class exists to conform to the manifestrevlog
    interface for those directories and proactively prevent writes to
    outside the narrowspec.
    cCs||_||_dSr@)r&r%)r<r&r�r*r*r+r=(	r>zexcludedmanifestrevlog.__init__cCrX)Ns(attempt to get length of excluded dir %srYrAr*r*r+r�,	r[zexcludedmanifestrevlog.__len__cCrX)Ns'attempt to get rev from excluded dir %srYrOr*r*r+r�1	r[zexcludedmanifestrevlog.revcCrX)Ns+attempt to get linkrev from excluded dir %srYrOr*r*r+r�6	r[zexcludedmanifestrevlog.linkrevcCrX)Ns(attempt to get node from excluded dir %srYr�r*r*r+r�;	r[zexcludedmanifestrevlog.nodecOr�r@r*)r<rZrr*r*r+r_@	szexcludedmanifestrevlog.addN)
rKrLrMr�r=r�r�r�r�r_r*r*r*r+rO	s	rO)rN)H�
__future__rr�rQrr��i18nrr�rrrrr�r	r
rr�rr
rrr�
interfacesr�
interfaceutil�revlogutilsrr��	importmodrr
r�r,r5�objectr7rOrSr_r!rd�lazymanifest�AttributeError�implementer�
imanifestdictr�r�r/r�rr)r!r#r�r��	Exceptionrj�imanifeststorager��imanifestlogr��imanifestrevisionwritabler/�imanifestrevisionstoredr+rIr)rVr(rOr*r*r*r+�<module>s~,

%6
�

k+
t

g
b

O
"{

https://t.me/RX1948 - 2025