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/fastannotate/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�]Lb�"�@s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZm
Z
ddlmZdZdZd	ZGd
d�de�Zdd
�ZdS)�)�absolute_importN)�hex)�open)�error�pycompat�)r��c@s�eZdZdZdZd!dd�Zdd�Zedd	��Zd"dd�Z	d
d�Z
dd�Zdd�Zdd�Z
d#dd�Zdd�Zdd�Zdd�Zedd��Zdd �ZdS)$�revmapz~trivial hg bin hash - linelog rev bidirectional map

    also stores a flag (uint8) for each revision, and track renames.
    sREVMAP1NcCs^||_dg|_dg|_i|_dg|_dg|_d|_|r-tj�|�r'|�	�dS|�
�dSdS)a=create or load the revmap, optionally associate to a file

        if path is None, the revmap is entirely in-memory. the caller is
        responsible for locking. concurrent writes to a same file is unsafe.
        the caller needs to make sure one file is associated to at most one
        revmap object at a time.Nr����)�path�_rev2hsh�	_rev2flag�_hsh2rev�_renamerevs�_renamepaths�_lastmaxrev�os�exists�_load�flush)�selfr
�r�;/usr/lib/python3/dist-packages/hgext/fastannotate/revmap.py�__init__<s�zrevmap.__init__cCsV|jdd�|_|jdd�|_|j��|_|jdd�|_|jdd�|_d|_dS)z>copy the map data from another revmap. do not affect self.pathNr)rrr�copyrrr)r�rhsrrr�copyfromSs
zrevmap.copyfromcCst|j�dS)z"return max linelog revision numberr)�lenr)rrrr�maxrev\sz
revmap.maxrevFcCs�||jvrt�dt|���t|�tkrt�dt��t|j�}d}|r(|t	O}|durC||j
dkrC|tO}|j�
|�|j
�
|�|j�
|�|j�
|�||j|<|rZ|��|S)z~add a binary hg hash and return the mapped linelog revision.
        if flush is True, incrementally update the file.
        s%r is in revmap alreadyshsh must be %d-char longrNr)rr�CorruptedFileErrorrr�_hshlen�hgerror�ProgrammingErrorr�sidebranchflagr�
renameflagr�appendrr)r�hsh�
sidebranchr
r�idx�flagrrrr'as,

��

z
revmap.appendcC� ||jks	|dkrdS|j|S)z>convert linelog revision to hg hash. return None if not found.rN)r r�r�revrrr�rev2hsh|s
zrevmap.rev2hshcCr,)zkget the flag (uint8) for a given linelog revision.
        return None if revision does not exist.
        rN)r rr-rrr�rev2flag�s
zrevmap.rev2flagcCs2||jks	|dkrdSt�|j|�d}|j|S)zcget the path for a given linelog revision.
        return None if revision does not exist.
        rNr)r �bisect�bisect_rightrr)rr.r*rrr�rev2path�s
zrevmap.rev2pathcCs|j�|�S)z>convert hg hash to linelog revision. return None if not found.)r�get)rr(rrr�hsh2rev�szrevmap.hsh2revcCs8dg|_dg|_i|_dg|_d|_|r|��dSdS)z3make the map empty. if flush is True, write to diskNrr)rrr�	_rev2pathrr)rrrrr�clear�s�zrevmap.clearcCs�|jsdS|jdkr9t|jd�� }|�|j�t�dt|j��D]}|�	||�q Wd�n1s3wYn+t|jd��}t�|jdt|j��D]}|�	||�qLWd�n1s_wY|j
|_dS)z write the state down to the fileNrswbrsab)r
rr�write�HEADERr�xrangerr�	_writerevr )r�f�irrrr�s$
������zrevmap.flushc	Cs|jsdSd}t}t|jd��e}|�t|j��|jkrt���|jdd�	|�|�}|s.n?t	|�}t|j
�}|t@rL|�|�}|j
�|�|j�|�|�|�}t|�|kr[t���||j|<|j�|�|j
�|�q&Wd�n1swwY|j|_dS)zload state from fileNr�rbF)r)r
r"r�readrr9rr!r7�ordrr&�	_readcstrrr'rrrr r)	r�flaglen�hshlenr<�bufr+r.r
r(rrrr�s8




��zrevmap._loadcCsj|j|}|j|}|�t�d|��|t@r.|�|�}|dur't�d|��|�|d�|�|�dS)zappend a revision data to file�BNscannot find path for %s�)	rrr8�struct�packr&r3rr!)rr.r<r+r(r
rrrr;�s


zrevmap._writerevcCs4d}	|�d�}|st���|dkr	|S||7}q)z,read a C-language-like ''-terminated stringrTrrF)r?rr!)r<rD�chrrrrA�s
��zrevmap._readcstrcCsht|t�r
|\}}n	|��|��}}|�|�}|durdS|dur+||�|�kr+dS|�|�t@dkS)z�(fctx or (node, path)) -> bool.
        test if (node, path) is in the map, and is not in a side branch.
        f can be either a tuple of (node, path), or a fctx.
        NFr)�
isinstance�tuple�noder
r5r3r0r%)rr<r(r
r.rrr�__contains__�s


zrevmap.__contains__)N)FNF)F)�__name__�
__module__�__qualname__�__doc__r9rr�propertyr r'r/r0r3r5r7rrr;�staticmethodrArMrrrrr
4s&
	

	

r
cCs�d}z9t|d��)}|�ttj�|��ttj�kr(|�	t�}Wd�W|SWd�W|S1s4wYW|St
yEY|Sw)z�return the last hash in a revmap, without loading its full content.
    this is equivalent to `m = revmap(path); m.rev2hsh(m.maxrev)`, but faster.
    Nr>)r�seekr"�io�SEEK_END�tellrr
r9r?�IOError)r
r(r<rrr�getlastnode�s"������rY)�
__future__rr1rUrrG�mercurial.noder�mercurial.pycompatr�	mercurialrr#r�r%r&r"�objectr
rYrrrr�<module>sH

https://t.me/RX1948 - 2025