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/hgext/remotefilelog/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/hgext/remotefilelog/__pycache__/historypack.cpython-310.pyc
o

�]LbK�@s�ddlmZddlZddlmZmZddlmZmZddl	m
Z
ddlmZm
Z
mZdZe�e�Zd	Zd
Ze�e�ZdZdZd
ZdZdZdZdZdZdZd
ZGdd�dej�Z Gdd�dej�Z!Gdd�dej"�Z#dS)�)�absolute_importN)�hex�sha1nodeconstants)�pycompat�util)�hashutil�)�basepack�	constants�shallowutils!20sQQII�s!20sQs!20s20s20s20sH�R�s.histidxs	.histpack��c@s6eZdZeZeZdd�Zd
dd�Zdd�Zdd	�ZdS)�historypackstorecCst|�S�N)�historypack��self�path�r�A/usr/lib/python3/dist-packages/hgext/remotefilelog/historypack.py�getpack0szhistorypackstore.getpackNc	Csv|jD]}z|j|||d�WStyYqw|��D]}z|j|||d�WSty4Yqwt||f��)N��known)�packs�getancestors�KeyError�refresh)r�name�noder�packrrrr3s
��zhistorypackstore.getancestorsc	Csn|jD]}z	|�||�WStyYqw|��D]}z	|�||�WSty0Yqwt||f��r)r�getnodeinforr)rr r!r"rrrr#Bs
��zhistorypackstore.getnodeinfocC�td|t|�f��)Ns&cannot add to historypackstore (%s:%s)��RuntimeErrorr�r�filenamer!�p1�p2�linknode�copyfromrrr�addQ��zhistorypackstore.addr)	�__name__�
__module__�__qualname__�INDEXSUFFIX�
PACKSUFFIXrrr#r-rrrrr,s
rcs�eZdZeZeZdgZ�fdd�Zdd�Zddd�Zd	d
�Z	ddd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zddd�Zdd�Zdd�Zdd�Z�ZS) rrcs tt|��|�t|_t|_dSr)�superr�__init__�INDEXFORMAT2�INDEXFORMAT�INDEXENTRYLENGTH2�INDEXENTRYLENGTHr��	__class__rrr5]s
zhistorypack.__init__c	CsFg}|D]\}}z|�||�Wqty |�||f�Yqw|Sr)�	_findnoder�append)r�keys�missingr r!rrr�
getmissingbs�zhistorypack.getmissingNcCs\|r||vrgS|j|||d�}i}|D]\}}}}	}
|||	|
f||<q|s,t||f��|S)z�Returns as many ancestors as we're aware of.

        return value: {
           node: (p1, p2, linknode, copyfrom),
           ...
        }
        r)�
_getancestorsr)rr r!r�	ancestors�results�ancnoder)r*r+r,rrrrlszhistorypack.getancestorscCs|�||�dd�S)Nr)r<)rr r!rrrr#�szhistorypack.getnodeinfoccs��|durt�}|�|�}|\}}}}}	|h}
d}||krw|
s!dS|�||�\}}
|t7}|
r6|t|
�7}|t}||
vrq|
�|�|t}|t}|t	j
krY||vrY|
�|�|t	j
krg||vrg|
�|�||||t|
fV||ksdSdS�Nr)
�set�_findsection�
_readentry�PACKENTRYLENGTH�len�ANC_NODE�remove�
ANC_P1NODE�
ANC_P2NODEr�nullidr-�ANC_LINKNODE)rr r!r�sectionr(�offset�size�nodeindexoffset�
nodeindexsize�pending�o�entryr,rD�p1node�p2noderrrrA�s2�



�zhistorypack._getancestorscCsR|j}t�t|||t��}d}|t}|dkr%|t7}||||�}||fSrE)�_data�struct�unpack�
PACKFORMATrI�ANC_COPYFROM)rrR�datarXr,�copyfromlenrrrrH�s�zhistorypack._readentrycCr$)Ns!cannot add to historypack (%s:%s)r%r'rrrr-�r.zhistorypack.addcCs�|jdkr#|�||�}|D]\}}}}}||kr!|||||fSq
n3|�|�}	|	dd�\}
}|�||
|
|t�}|durVt�t|�\}}
|�|
�\}}|dd�|fSt	d|t
|�f��)Nrrrs unable to find history for %s:%s)�VERSIONrArG�_bisect�NODEINDEXENTRYLENGTHr\r]�NODEINDEXFORMATrHrr)rr r!rBrDrYrZr+r,rQrTrUrXrRrrrr<�s(
��
�zhistorypack._findnodecCs�|j}t�|���}t�|j|d|j��d}|j}|||j	}|j
}t�|d|j
�D]}|||j	}	|	|kr=nq.|}	|�|||	|j�}
|
sOt|��t�|j|
�}|\}}
}}}|j||tj�}t�d|�d}|tj7}|j|||�}||kr�td||f��||7}t�d|j|
|
tj��d}|
tj7}
|j|
|
|�}|
|7}
||kr�td||f��|
t7}
|
}|tj|t}|||||fS)Nrr�!Hs&found file name %s when looking for %s)�paramsr�sha1�digestr\r]�fanoutstruct�fanoutprefix�_fanouttable�
indexstart�	_indexendr�xrange�fanoutcountrcr9rr7�_indexr
�FILENAMESIZEr[�ENTRYCOUNTSIZE)rr rg�namehash�	fanoutkey�fanout�start�indexend�i�endrX�rawentry�xrRrSrTrU�
rawnamelen�
actualnamelen�
actualname�filenamelength�nodelistoffset�nodelistsizerrrrG�sp����

�
���

���zhistorypack._findsectionc
Cs�|}|j||t�}|j||t�}||kr!|j|||�S||kr.|j|||�S|||krm|||d}||||}|j||t�}	|	|krZ|j|||�S||	kra|}n||	krg|}|||ks4dS)Nr)rq�
NODELENGTH)
rr!rwrz�entrylen�	origstart�	startnode�endnode�mid�midnoderrrrcs&�
zhistorypack._bisectcCs |D]\}}|�|||�qdSr)�markhistoryentry)r�ledger�optionsr(r!rrr�
markledger"s�zhistorypack.markledgercCsl|j�|g�}t|�}dd�|D�}t||�dkr2|j|jvr4tj|jdd�tj|j	dd�dSdSdS)NcSsh|]}|jr|j|jf�qSr)�historyrepackedr(r!��.0�errr�	<setcomp>)s
�
�z&historypack.cleanup.<locals>.<setcomp>rT)�
ignoremissing)
�sources�getrFrJr�createdr�
unlinkpath�	indexpath�packpath)rr��entries�allkeys�repackedkeysrrr�cleanup&s��zhistorypack.cleanupccs*�|��D]
\}}}}}}||fVqdSr)�iterentries)r�f�nr|rrr�__iter__2s��zhistorypack.__iter__c	cs�d}||jkr�|j}t�d|||tj��d}|tj7}||||�}||7}t�d|||t��d}|t7}t�|�D]:}t�t	|||t
��}|t
7}||||t�}||t7}||t|t
|t|t|fV|jt
7_qB|��||jksdSdS)Nrrfr�!I)�datasizer[r\r]r
rrrsrror^rIr_rKrMrNrP�_pagedin�
freememory)	rrRr`�filenamelenr(�revcountryrXr,rrrr�6sF�
��
����	�zhistorypack.iterentriesr)r/r0r1r2r3�SUPPORTED_VERSIONSr5r@rr#rArHr-r<rGrcr�r�r�r��
__classcell__rrr:rrWs$


B
rcsVeZdZdZeZeZdgZd�fdd�	Zdd�Zdd�Z	d�fd
d�	Z
dd
�Z�ZS)�mutablehistorypacka�
A class for constructing and serializing a histpack file and index.

    A history pack is a pair of files that contain the revision history for
    various file revisions in Mercurial. It contains only revision history (like
    parent pointers and linknodes), not any revision content information.

    It consists of two files, with the following format:

    .histpack
        The pack itself is a series of file revisions with some basic header
        information on each.

        datapack = <version: 1 byte>
                   [<filesection>,...]
        filesection = <filename len: 2 byte unsigned int>
                      <filename>
                      <revision count: 4 byte unsigned int>
                      [<revision>,...]
        revision = <node: 20 byte>
                   <p1node: 20 byte>
                   <p2node: 20 byte>
                   <linknode: 20 byte>
                   <copyfromlen: 2 byte>
                   <copyfrom>

        The revisions within each filesection are stored in topological order
        (newest first). If a given entry has a parent from another file (a copy)
        then p1node is the node from the other file, and copyfrom is the
        filepath of the other file.

    .histidx
        The index file provides a mapping from filename to the file section in
        the histpack. In V1 it also contains sub-indexes for specific nodes
        within each file. It consists of three parts, the fanout, the file index
        and the node indexes.

        The file index is a list of index entries, sorted by filename hash (one
        per file section in the pack). Each entry has:

        - node (The 20 byte hash of the filename)
        - pack entry offset (The location of this file section in the histpack)
        - pack content size (The on-disk length of this file section's pack
                             data)
        - node index offset (The location of the file's node index in the index
                             file) [1]
        - node index size (the on-disk length of this file's node index) [1]

        The fanout is a quick lookup table to reduce the number of steps for
        bisecting the index. It is a series of 4 byte pointers to positions
        within the index. It has 2^16 entries, which corresponds to hash
        prefixes [00, 01, 02,..., FD, FE, FF]. Example: the pointer in slot 4F
        points to the index position of the first revision whose node starts
        with 4F. This saves log(2^16) bisect steps.

        dataidx = <fanouttable>
                  <file count: 8 byte unsigned> [1]
                  <fileindex>
                  <node count: 8 byte unsigned> [1]
                  [<nodeindex>,...] [1]
        fanouttable = [<index offset: 4 byte unsigned int>,...] (2^16 entries)

        fileindex = [<file index entry>,...]
        fileindexentry = <node: 20 byte>
                         <pack file section offset: 8 byte unsigned int>
                         <pack file section size: 8 byte unsigned int>
                         <node index offset: 4 byte unsigned int> [1]
                         <node index size: 4 byte unsigned int>   [1]
        nodeindex = <filename>[<node index entry>,...] [1]
        filename = <filename len : 2 byte unsigned int><filename value> [1]
        nodeindexentry = <node: 20 byte> [1]
                         <pack file node offset: 8 byte unsigned int> [1]

    [1]: new in version 1.
    rcsDtt|�j|||d�i|_i|_i|_t|_t|_	t
|_
t|_dS)N)�version)r4r�r5�files�entrylocations�fileentriesr6r7r8r9rerd)r�uir�r�r:rrr5�s
zmutablehistorypack.__init__cCs<|pd}t�dt|��}|j�|g��||||||f�dS)N�rf)r\r"rJr��
setdefaultr=)rr(r!r)r*r+r,rarrrr-�s
�zmutablehistorypack.addc
s2t|j�D]�}|j|}|j��}dd�|D���fdd�}ttt�dd�|D�|���}|�dt	�
dt|��|t	�
d	t|��f�tj
t|�d
}g}|j�|i�}||}	|D]}
|	||
<d�|
}|�|�|	t|�7}	q[d�|�}|t|�7}|�|�||f|j|<t�|���}
|
|j|
<qdS)
NcSsi|]}|d|�qS)rrr�rrr�
<dictcomp>�sz-mutablehistorypack._write.<locals>.<dictcomp>csD�|\}}}}}}g}|tjkr|�|�|tjkr |�|�|Sr)rrOr=)r!r|r)r*�parents��entrymaprr�
parentfunc�s



z-mutablehistorypack._write.<locals>.parentfunccss�|]}|dVqdS)rNrr�rrr�	<genexpr>�s�z,mutablehistorypack._write.<locals>.<genexpr>s%s%s%srfr�rs%s%s%s%s%s%sr�)�sortedr��packfp�tell�list�reversedr�	sortnodes�writerawr\r"rJr
rrr�r�r=�joinr�rrhrir�)
rr(r��sectionstartr��sortednodes�
sectionlen�
rawstrings�	locationsrRr!�raw�rawdatarr�r�_write�sD

	�����	


�zmutablehistorypack._writeNcs$|jrdS|��tt|�j|d�S)N)r�)�_closedr�r4r��close)rr�r:rrr��szmutablehistorypack.closec	Cs@|j}|j}|j}|j}dd�t�|j�D�}t|�}t�	d�}||t
|�||}	g}
g}d}|D]Y\}
}}}|j|}t
|�|}t�||
|||	|�}|�
t�tjt
|��|�|	tjt
|�7}	tt�|��D]\}}|�
t�|||��|d7}qm|	t
|�|7}	|
�
|�q4t�d|�}d�|
�|d�|�S)Ncss.�|]\}\}}t�|���|||fVqdSr)rrhri)r�r(rRrSrrrr�
s
�
�
�z1mutablehistorypack.createindex.<locals>.<genexpr>s!Qrrr�)r7r9rerdr�	iteritemsr�r�r\�calcsizerJr�r"r=r
�FILENAMESTRUCTrrr�)r�
nodelocations�indexoffset�fileindexformat�fileindexlength�nodeindexformat�nodeindexlengthr��indexlensizerT�fileindexentries�nodeindexentries�	nodecountrtr(rRrSrUr{r!�location�nodecountrawrrr�createindexsb
�
�
���
�	��
���zmutablehistorypack.createindex)rr)
r/r0r1�__doc__r2r3r�r5r-r�r�r�r�rrr:rr�`sK8r�)$�
__future__rr\�mercurial.noderr�	mercurialrr�mercurial.utilsr�r	r
rr6r�r8r�rerdr^rIrsr2r3rKrMrNrPr_�
basepackstorerr�mutablebasepackr�rrrr�<module>s4

+

https://t.me/RX1948 - 2025