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__/branchmap.cpython-310.pyc
o

�]LbR~�@sVddlmZddlZddlmZmZmZddlmZm	Z	m
Z
mZmZm
Z
ddlmZmZejr[ddlmZmZmZmZmZmZmZmZmZddlmZeeeeeeeeeeef
�s[J�ejZejZej Z ej!Z!Gd	d
�d
e"�Z#dd�Z$d
d�Z%Gdd�de"�Z&Gdd�de&�Z'dZ(de(Z)de(Z*dZ+ee+�Z,de,Z-dZ.dZ/dZ0Gdd�de"�Z1dS)�)�absolute_importN�)�bin�hex�nullrev)�encoding�error�obsolete�pycompat�scmutil�util)�repoviewutil�
stringutil)	�Any�Callable�Dict�Iterable�List�Optional�Set�Tuple�Union)�	localrepoc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�BranchMapCachez8mapping of filtered views of repo with their branchcachecCs
i|_dS�N)�_per_filter��self�r�5/usr/lib/python3/dist-packages/mercurial/branchmap.py�__init__E�
zBranchMapCache.__init__cCs|�|�|j|jSr)�updatecacher�
filtername�r�reporrr�__getitem__Hs
zBranchMapCache.__getitem__cs�|j}|j}|j�|���dus��|�st�|��g}�durLt�|�}|durH|�|�}||�	��|jj
|j
}|��fdd�|D��nt|��|�|j�j
dd��|r`��||���|�siJ|���|j|j<dS)z<Update the cache for the given filtered view on a repositoryNc3s�|]
}|�jkr|VqdSr)�tiprev)�.0�r��bcacherr�	<genexpr>c��z-BranchMapCache.updatecache.<locals>.<genexpr>r)�start)�	changelogr#r�get�validfor�branchcache�fromfile�subsettable�filtered�copy�filteredrevs�extend�revsr'�update)rr%�clr#r9�
subsetname�subset�	extrarevsrr*rr"Ls&


zBranchMapCache.updatecachecs�|j}|j�|j}g}t�}t�|�D]}||7}|D]}�|�}	||	�\}
}|r.|�|�qq|rft�fdd�|D��}t||||�	�||d�}
dD]}|�
|�}|
�|�re|
|j|<|
�
|�dSqLdSdS)z�Replace the branchmap cache for a repo with a branch mapping.

        This is likely only called during clone with a branch map from a
        remote.

        c3s�|]	}t�|��VqdSr)�int�r(�node��clrevrrr,�s�z)BranchMapCache.replace.<locals>.<genexpr>)�closednodes)sbases	immutablesservedN)r/�rev�
branchinfo�setr
�
itervalues�add�maxr2rAr5r1r�write)rr%�remotebranchmapr;�clbranchinfo�rbheads�closed�bheads�hr)�b�c�rtiprev�cache�	candidate�rviewrrBr�replaceos@
��
�




��zBranchMapCache.replacecCs|j��dSr)r�clearrrrrrY��zBranchMapCache.clearcCs:|��}|j��D]\}}|jr|�|�}|�|�q	dSr)�
unfilteredr�items�_delayedr5rK)rr%�unfir#rUrrr�
write_delayed�s

��zBranchMapCache.write_delayedN)
�__name__�
__module__�__qualname__�__doc__r r&r"rXrYr_rrrrrBs#'rcCstdt�t|����)zEraises ValueError when branchcache found a node which does not existsznode %s does not exist)�
ValueErrorr
�sysstrr�rArrr�_unknownnode�srgcCs|jdur
d|jSdS)Nsbranch cache (%s)sbranch cache�r#)r%rrr�_branchcachedesc�s

ric@s�eZdZdZddedddfdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
e
Zdd�Zedd��Zdd�Zedd��Zdd�Zd d!�Zd"d#�Zd$d%�Zd3d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�ZdS)4r2a<A dict like object that hold branches heads cache.

    This cache is used to avoid costly computations to determine all the
    branch heads of a repo.

    The cache is serialized on disk in the following format:

    <tip hex node> <tip rev number> [optional filtered repo hex hash]
    <branch head hex node> <open/closed state> <branch name>
    <branch head hex node> <open/closed state> <branch name>
    ...

    The first line is used to check if the cache is still valid. If the
    branch cache is for a filtered repo view, an optional third hash is
    included that hashes the hashes of all filtered and obsolete revisions.

    The open/closed state is represented by a single letter 'o' or 'c'.
    This field can be used to avoid changelog reads when determining if a
    branch head closes a branch or not.
    rNcCs�||_d|_|dur|j|_n||_||_||_|dur!t�|_n||_t|�|_	d|_
t�|_||_|jdur?dd�|_dSdS)z�hasnode is a function which can be used to verify whether changelog
        has a given node or not. If it's not provided, we assume that every node
        we have exists in changelogFNcSsdS)NTr)�xrrr�<lambda>�sz&branchcache.__init__.<locals>.<lambda>)
�_repor]�nullid�tipnoder'�filteredhashrG�_closednodes�dict�_entries�_closedverified�_verifiedbranches�_hasnode)rr%�entriesrnr'rorD�hasnoderrrr �s"



�zbranchcache.__init__cCs2|jrdS|jD]}|�|�st|�qd|_dS)zverify the closed nodes we haveNT)rsrprurg)rrArrr�
_verifyclosed�s

�
zbranchcache._verifyclosedcCsJ||jvs
||jvrdS|j|D]}|�|�st|�q|j�|�dS)z'verify head nodes for the given branch.N)rrrtrurgrI)r�branch�nrrr�
_verifybranch�s
�zbranchcache._verifybranchcCs,t|j���|j}|D]}|�|�qdS)z"verifies nodes of all the branchesN)rGrr�keysrtr{)r�needverificationrRrrr�
_verifyall�s�zbranchcache._verifyallcCs
t|j�Sr)�iterrrrrrr�__iter__r!zbranchcache.__iter__cCs||j|<dSr)rr)r�key�valuerrr�__setitem__rZzbranchcache.__setitem__cCs|�|�|j|Sr�r{rr�rr�rrrr&	�

zbranchcache.__getitem__cC�|�|�||jvSrr�r�rrr�__contains__
r�zbranchcache.__contains__ccs0�t�|j�D]\}}|�|�||fVqdSr)r
�	iteritemsrrr{)r�k�vrrrr�s
�
�zbranchcache.iteritemscCr�)z2checks whether a branch of this name exists or notr�)r�labelrrr�	hasbranchs

zbranchcache.hasbranchc
CsLd}z�zT|�|�|��}t|�}t|��d��dd�}|dd�\}}t|�t|�}}d}|jj	}t
|�dkr>t|d�}||||||d�}	|	�|�sPtd��|	�
||�Wn=ttfylYW|rj|��dSdSty�}
z|jjr�d}|j�|t|�t�|
�f�d}	WYd}
~
nd}
~
wwW|r�|��|	S|r�|��ww)N�
� �)rnr'rorwztip differssinvalid %s: %s
)�cachevfs�	_filenamer�next�rstrip�splitrr?r/rw�lenr1rd�load�IOError�OSError�close�	Exception�ui�	debugflag�debugrir�forcebytestr)�clsr%�f�lineiter�cachekey�last�lrevrorwr+�inst�msgrrrr3s\�
��������
�
�zbranchcache.fromfilecCs~|D]:}|�d�}|sq|�dd�\}}}|dvrtd��t�|���}t|�}|j�|g��	|�|dkr<|j
�|�qdS)z[fully loads the branchcache by reading from the file using the line
        iterator passedr�r�r�soczinvalid branch state�cN)r�r�rdr�tolocal�striprrr�
setdefault�appendrprI)rr%r��linerA�stater�rrrr�Js
��zbranchcache.loadcCsd}|jrd||jf}|S)z7name of a branchcache file for a given repo or repoviewsbranch2s%s-%srh)r%�filenamerrrr�Zszbranchcache._filenamecCsRz	|j�|j�}Wn
tyYdSw|j|krdStj||jdd�}|j|kS)z�check that cache contents are valid for (a subset of) this repo

        - False when the order of changesets changed or if we detect a strip.
        - True when cache is up-to-date for the current repo or its subset.FT��needobsolete)r/rAr'�
IndexErrorrnrro)rr%rA�tiphashrrrr1bs�

zbranchcache.validforcCs>|d}d}t|�D]}||jvr|}d}||fSq
||fS)zhReturn tuple with last open head in heads and false,
        otherwise return last closed head and true.���TF)�reversedrp)r�heads�tiprOrQrrr�
_branchtipws
�zbranchcache._branchtipcCs|�||�dS)z�Return the tipmost open head on branch head, otherwise return the
        tipmost closed head on branch.
        Raise KeyError for unknown branch.r)r�)rryrrr�	branchtip�szbranchcache.branchtipcs�fdd�|D�S)Nc3s�|]
}|�jvr|VqdSr)rp)r(rzrrrr,�r-z'branchcache.iteropen.<locals>.<genexpr>r)r�nodesrrr�iteropen�szbranchcache.iteropenFcCs*|�|�|j|}|st|�|��}|Sr)r{rr�listr�)rryrOr�rrr�branchheads�s


zbranchcache.branchheadsccs.�t�|�D]\}}||f|�|�VqdSr)r
r�r�)r�bnr�rrr�iterbranches�s��zbranchcache.iterbranchescCs|��t�|j�S)zreturns all the heads)r~r
rHrrrrrr�	iterheads�szbranchcache.iterheadscCs"t|�|j|j|j|j|j|j�S)z-return an deep copy of the branchcache object)�typerlrrrnr'rorprrrrr6�s�zbranchcache.copyc
CsT|��}t|dd�sd|_dSzx|j|�|�ddd�}t|j�d|jg}|jdur2|�	t|j��|�
d�|�d�d}tt
�|j��D](\}}t�|�}|D]}|d	7}||jvr_d
}	nd}	|�
dt|�|	|f�qQqF|��|j�d
dt|�t|j�|�d|_WdStttjfy�}
z|j�dt�|
��WYd}
~
dSd}
~
ww)N�	finalizedT�w)�
atomictemps%dr�r�rrr��os	%s %s %s
�branchcaches%wrote %s with %d labels and %d nodes
Fs couldn't write branch cache: %s
)�currenttransaction�getattrr]r�r�rrnr'ror�rK�join�sortedr
r�rrr�	fromlocalrpr�r��logrir�r�r�r�Abortr�rr�)rr%�trr�r��	nodecountr�r�rAr�r�rrrrK�sJ


������zbranchcache.writecs�t��}|j�i}|��j}|D]}||�\}}|�|g��|�|r,|j���	|��q|j
}	d}
|��jj}t
�|d�}t�|�D]�\}}
|j�|g�}�fdd�|D�}t�}t|
�D]j}||vreq^|sm|�|�q^dd�||�D�}t�}t�}t�}|D]#}||vr�|�|�q�||vs�||�d|kr�|�|�q�|�|�q�t|�t|�kr�dks�n|�|�|�|�|�|�|�|�q^|r�|
dur�t����}
||
r�t|�}|t|�kr�t��||��}||8}|r��fd	d�t|�D�||<t|
�}||	k�r	|}	qC|	|j
k�r|	|_
��	|	�|_|�|��sM|j|_t|_
|� �D]"}|�s1�q*t�fd
d�|D��}||j
k�rK��	|�|_||_
�q*t!j"||j
dd
�|_"t��|}|j#�$ddt%|�|�|�&|�dS)z�Given a branchhead cache, self, that may have extra nodes or be
        missing heads, and a generator of nodes that are strictly a superset of
        heads missing, this function updates self to be correct.
        Nsobsoletecsh|]}��|��qSr�rEr@�r;rr�	<setcomp>�z%branchcache.update.<locals>.<setcomp>cSsg|]}|tkr|�qSr)r)r(�prrr�
<listcomp>sz&branchcache.update.<locals>.<listcomp>rrcsg|]}��|��qSrrf)r(rEr�rrr�>r�c3s�|]}��|�VqdSrr�r@r�rrr,Ss�z%branchcache.update.<locals>.<genexpr>Tr�r�supdated %s in %.4f seconds
)'r�timerr/�revbranchcacherFr�r�rprIrAr'r[�
parentrevsr	�getrevsr
r�rrr0rGr�r�r:�difference_update�headrevs�minrJ�	ancestorsrnr1rmrr�rror�r�rirK)rr%�revgen�	starttime�newbranches�
getbranchinfor)ry�closesbranch�ntiprev�	topoheadsr��obsrevs�newheadrevsrP�bheadset�	uncertain�newrev�parents�
samebranch�otherbranch�
obsparentsr��floorrevr�r'r��durationrr�rr:�s�
�$




����zbranchcache.update)F)r`rarbrcrr rxr{r~r�r�r&r�r�r\r��classmethodr3r��staticmethodr�r1r�r�r�r�r�r�r6rKr:rrrrr2�sD
�&


,

(r2c@seZdZdZdd�ZdS)�remotebranchcachez@Branchmap info for a remote connection, should not write locallycCsdSrrr$rrrrKiszremotebranchcache.writeN)r`rarbrcrKrrrrr�fsr�s-v1s	rbc-namessrbc-revss>4sI�@�i���lc@sjeZdZdZddd�Zdd�Zejdd��Zd	d
�Z	dd�Z
d
d�Zdd�Zddd�Z
dd�Zdd�ZdS)r�a�Persistent cache, mapping from revision number to branch name and close.
    This is a low level cache, independent of filtering.

    Branch names are stored in rbc-names in internal encoding separated by 0.
    rbc-names is append-only, and each branch name is only stored once and will
    thus have a unique index.

    The branch info for each revision is stored in rbc-revs as constant size
    records. The whole file is read into memory, but it is only 'parsed' on
    demand. The file is usually append-only but will be truncated if repo
    modification is detected.
    The record for each revision contains the first 4 bytes of the
    corresponding node hash, and the record is only used if it still matches.
    Even a completely trashed rbc-revs fill thus still give the right result
    while converging towards full recovery ... assuming no incorrectly matching
    node hashes.
    The record also contains 4 bytes where 31 bits contains the index of the
    branch and the last bit indicate that it is a branch close commit.
    The usage pattern for rbc-revs is thus somewhat similar to 00changelog.i
    and will grow with it but be 1/8th of its size.
    Tc
Cs |jdusJ�||_g|_t�|_d|_z|j�t�}t	|�|_|r-dd�|�
d�D�|_Wnttfy?|r=|j
|_Ynw|jrrz|j�t�}||jdd�<Wnttfyq}z|j�dt�|��WYd}~nd}~wwtt	|j�tt	|j��|_|jdkr�g|_t	|j�|_dS)NrcSsg|]}t�|��qSr)rr�)r(r�rrrr��s
�z+revbranchcache.__init__.<locals>.<listcomp>�s(couldn't read revision branch cache: %s
)r#rl�_names�	bytearray�_rbcrevs�
_rbcsnameslenr��read�	_rbcnamesr�r�r�r��_branchinforFr�r�rr�r��_rbcrecsizer/�_rbcrevslen�_rbcnamescount)rr%�readonly�bndata�datar�rrrr �sH
���������
zrevbranchcache.__init__cCsFd|_|jdd�=d|_t|jj�|_t|jt�|_	t
�|d�dS)Nrs
_namesreverse)r�r�r�r�rlr/r�r�r�r�r�clearcachedpropertyrrrr�_clear�szrevbranchcache._clearcCsdd�t|j�D�S)NcSsi|]\}}||�qSrr)r(r)rRrrr�
<dictcomp>�r�z0revbranchcache._namesreverse.<locals>.<dictcomp>)�	enumerater�rrrr�
_namesreverse�szrevbranchcache._namesreversec	Cs
|jj}|t}|tkr|�|�St|j�|tkr|�|�S|�|�dt	�}t
tt�
|j�|�\}}t|t@�}|r@|tM}|dkrEn;||krfz|j||fWStye|jj�d�|��Ynw|jj�d|�|t}|j|d�=t|j|�|_|�|�S)zWReturn branch name and close flag for rev, using and updating
        persistent cache.NssRreferenced branch names not found - rebuilding revision branch cache from scratch
sPhistory modification detected - truncating revision branch cache to revision %d
)rlr/r�rrFr�r�r�rA�_rbcnodelen�unpack_from�
_rbcrecfmtr�buffer�bool�
_rbccloseflag�_rbcbranchidxmaskr�r�r�r�rr�r�)	rrEr/�	rbcrevidx�reponode�	cachenode�	branchidxr��truncaterrrrF�sB

���	��
zrevbranchcache.branchinfocCsx|jj}|�|�\}}||jvr|j|}nt|j�}|j�|�||j|<|�|�}|r1|tO}|�	|||�||fS)z7Retrieve branch info from changelog and update _rbcrevs)
rlr/rFrr�r�r�rAr
�
_setcachedata)rrEr/rRr�rrrrrr��s



zrevbranchcache._branchinfocCs||j\}}||jvr|j|}nt|j�}|j�|�||j|<|r&|tO}|�||jj�	|�|�dt
|�vr<|`dSdS)z%add new data information to the cacherFN)rFrr�r�r�r
rrlr/rA�vars)rrE�changelogrevisionryr�rrrr�setdatas



�zrevbranchcache.setdatacCs�|tkrdS|t}|t}t|j�}||kr"|j�dtt|��tt|j|||�t	|j
|�|_
|j��}|rB|�
d|j�dSdS)z:Writes the node's branch data to the in-memory cache data.Nr�swrite-revbranchcache)rr�r�r�r8rJ�
_rbcmininc�	pack_intor
r�r�rlr��addfinalizerK)rrErArr�requiredsize�rbccurr�rrrrs

�zrevbranchcache._setcachedataNcCs�|j}d}d}zhz5|jt|j�kr|jdd�}d}|�|�|jt}|t|j�kr<d}|dur6|jdd�}|�	||�Wn%t
ttj
tjfyb}z|j�d|t�|�f�WYd}~nd}~wwW|durn|��dSdS|dury|��ww)z!Save branch cache if it is dirty.N�F)�waits namess+couldn't write revision branch cache%s: %s
)rlr�r�r��wlock�_writenamesr�r�r��
_writerevsr�r�rr��	LockErrorr�r�rr��release)rr�r%r�stepr.r�rrrrK,s:

�������
�zrevbranchcache.writecCs�|jdkr+|j�td�}|��|jkr|�d�n|��|j�	dt�d|_d|_
|jdkr?|jjtdd�|j�td�}|�d�
dd	�|j|jd
�D���|��|_|��t|j�|_d
S)z,write the new branch names to revbranchcacher�abr�s%s changed - rewriting it
T)�
ignoremissingswbcss�|]}t�|�VqdSr)rr�)r(rRrrrr,Ys
��
�z-revbranchcache._writenames.<locals>.<genexpr>N)r�r��openr��tellr�rKr�r�r�r��
unlinkpathr�r�r�r�)rr%r�rrrr Is&


��
zrevbranchcache._writenamescCs�tt|j�t|j�t�}|j�td��<}|��|kr;|j�	dt|f�|�
|�|��|kr7d}|�
|�|��|t}|�|j||��Wd�n1sSwY||_
dS)z$write the new revs to revbranchcacher%struncating cache/%s to %d
rN)r�r�r/r�r�r�r'r(r�r��seekrrKr�)rr%r.r9r��endrrrr!bs
�

�
zrevbranchcache._writerevs)Tr)r`rarbrcr rr�
propertycacherrFr�rrrKr r!rrrrr�{s
$
/
r�)2�
__future__r�structrArrr�rrr	r
rr�utilsr
r�
TYPE_CHECKING�typingrrrrrrrrrr�anyr4�calcsizerr	�objectrrgrir2r��_rbcversionr�r�r
r�rrrr
r�rrrr�<module>sV ,��_<	

https://t.me/RX1948 - 2025