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

�]Lb�?�@s�ddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
ddlmZmZmZddlmZdd	lmZmZGd
d�de�ZGdd
�d
e�ZdS)�)�absolute_importN)�_)�bin�hex)�open)�error�pycompat�util)�hashutil�)�	constants�shallowutilc@s�eZdZd#dd�Zdd�Zd$dd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�ZdS)%�	basestoreFcCs�||_|j|_||_||_||_tjst��nd|_	|j�
dd�|_|j�
ddd�|_|jdvr3d|_|jdkr;d|_|rFt
�|j|�dSdS)	a�Creates a remotefilelog store object for the given repo name.

        `path` - The file path where this store keeps its data
        `reponame` - The name of the repo. This is used to partition data from
        many repos.
        `shared` - True if this store is a shared cache of data from the central
        server, for many repos on this machine. False means this store is for
        the local data for one repo.
        N�
remotefilelogsvalidatecachelogs
validatecache�on)r�strict�offrF)�repo�ui�_path�	_reponame�_sharedr�	iswindows�os�getuid�_uid�config�_validatecachelog�_validatecacher
�mkstickygroupdir)�selfr�path�reponame�shared�r$�?/usr/lib/python3/dist-packages/hgext/remotefilelog/basestore.py�__init__s&
��

�zbasestore.__init__cCs^g}|D](\}}|�||�}tj�|�}|r#|jdkr#|�|d�s#d}|s,|�||f�q|S)NrscontainsF)�_getfilepathrr!�existsr�_validatekey�append)r �keys�missing�name�node�filepathr(r$r$r%�
getmissing8s�

��zbasestore.getmissingNcCsZ|r
|�tj�r
dS|jr)|��D]\}}|D]}|�|||�|�|||�qqdSdS�N)�getr�OPTION_PACKSONLYr�	_getfiles�
markdataentry�markhistoryentry)r �ledger�options�filename�nodesr.r$r$r%�
markledgerJs��zbasestore.markledgercCs�|j}|j�|g�}d}|jtd�dt|�d�}|D]!}|js%|jr7|jr7|�	|�|�
|j|j�}t
�|�|d7}q|��|�|���dS)Nrscleaning up�files��unit�totalr)r�sourcesr2�makeprogressr�len�gced�datarepacked�historyrepacked�updater'r9r.r	�	tryunlink�complete�_cleanupdirectory�_getrepocachepath)r r7r�entries�count�progress�entryr!r$r$r%�cleanupSs�


zbasestore.cleanupc		Cs�t�}t�}tj�|�D]?\}}t�|�r2tj�||�}|�	|�zt�
|�Wqty1Yqwt�|�rK|�
d�rF|�|dd��q|�|�q||D]}tj�||d�}t�|�qPdS)z�Removes the empty directories and unnecessary files within the root
        directory recursively. Note that this method does not remove the root
        directory itself.�_oldN���)�setr	�osutil�listdir�stat�S_ISDIRrr!�joinrI�rmdir�OSError�S_ISREG�endswith�addrG)	r �rootdir�oldfiles�
otherfilesr-�mode�dirpathr9r/r$r$r%rIgs(

�


��zbasestore._cleanupdirectoryccs^�i}|��D]
\}}|�|g��|�q|�|���}t�|�D]\}}|||fVq!dS)a8Return a list of (filename, [node,...]) for all the revisions that
        exist in the store.

        This is useful for obtaining a list of all the contents of the store
        when performing a repack to another store, since the store API requires
        name+node keys and not namehash+node keys.
        N)�	_listkeys�
setdefaultr*�_resolvefilenamesr+r�	iteritems)r �existing�filenamehashr.�filenamemapr9�shar$r$r%r4�s��zbasestore._getfilesc	Cs�|siSi}t|�}|jd��D]}t�|���}||vr'|||<|�|�q|j��j}t	�
t|�ddd�D](}|s@|S|�|�
|��}|D]}t�|���}||vr`|||<|�|�qJq9|S)z�Given a list of filename hashes that are present in the
        remotefilelog store, return a mapping from filename->hash.

        This is useful when converting remotefilelog blobs into other storage
        formats.
        stipr���)rRr�manifestr
�sha1�digest�discard�
unfiltered�	changelogr�xrangerB�	readfilesr.)	r �hashes�	filenames�missingfilenamer9ri�cl�rev�filesr$r$r%rd�s0
��
��zbasestore._resolvefilenamescCs|jrtj�|j|j�S|jSr1)rrr!rWrr)r r$r$r%rJ�s
���zbasestore._getrepocachepathccsz�t�|���D]2\}}}|D]*}t|�dkrq|}|jr*|dd�|dd�}n|dd�}t|�t|�fVqqdS)z�List all the remotefilelog keys that exist in the store.

        Returns a iterator of (filename hash, filecontent hash) tuples.
        �(i���i���i���Ni���)r�walkrJrBrr)r �root�dirsrxr9r.rgr$r$r%rb�s���zbasestore._listkeyscCs<t|�}|jrt�|j||�}nt�||�}tj�|j	|�Sr1)
rrr
�getcachekeyr�getlocalkeyrr!rWr)r r-r.�keyr$r$r%r'�s
zbasestore._getfilepathc	Cs�|�||�}zBt�|�}|jrC|�||�sF|jr5t|jd��}|�d|�Wd�n1s0wYt�	||d�t
d|��W|SW|StyZt
d||t|�f��w)N�ab+scorrupt %s during read
�.corruptscorrupt local cache file %ssno file found at %s for %s:%s)
r'r
�readfiler�
_validatedatarr�writer�rename�KeyError�IOErrorr)r r-r.r/�data�fr$r$r%�_getdata�s&
������zbasestore._getdatac	Cs�|�||�}t�d�}zPtj�|�r'|d}tj�|�r!t�|�t�||�t�	|j
tj�|��tj||dd�|j
rL|�|d�sTt�td�|��Wt�|�dSWt�|�dSt�|�w)N�rPT)�readonlyswrites"local cache write was corrupted %s)r'r�umaskr!r(r
�
unlinkfile�shutil�copyrr�dirname�	writefilerr)r�Abortr)r r-r.r�r/�oldumask�newfilenamer$r$r%�addremotefilelognode�s&


���zbasestore.addremotefilelognodecCsztj�|jd�}t|d��}|�tj�|�d�Wd�n1s#wYt�|�}|j|j	kr;t�
|d�dSdS)aCall this to add the given repo path to the store's list of
        repositories that are using it. This is useful later when doing garbage
        collection, since it allows us to insecpt the repos to see what nodes
        they want to be kept alive in the store.
        �repossab�
Ni�)rr!rWrrr�r�rU�st_uidr�chmod)r r!�	repospath�	reposfile�
repospathstatr$r$r%�markrepo	s�
�zbasestore.markrepocCs�t|d��}|��}Wd�n1swY|�||�r!dS|jrCt|jd��}|�d||f�Wd�n1s>wYt�||d�dS)NsrbTr�scorrupt %s during %s
r�F)r�readr�rr�rr�)r r!�actionr�r�r$r$r%r)s
��zbasestore._validatekeyc	Cs�z6t|�dkr4t�|�\}}}t|�|krWdS||7}|||d�}tj�|�t|�kr1WdSWdSWdSttjfyCYdSw)NrF�T)	rBr
�parsesizeflagsrr!�basenamer�
ValueError�BadRemotefilelogHeader)r r�r!�offset�size�flags�datanoder$r$r%r�%s ���zbasestore._validatedatacCs�|j}|j}tj��}d}d}d}d}t��d}	|jtd�dd�}
|
�d�t	�
|�D]�\}}}
|
D]�}|dkr:q3d|vr?q3|
�|�t	j�||�}t	j�
||�}|d7}zt	�|�}Wn$ty�}z|jtjkrl�td	�}|�||�WYd}~q3d}~ww||j7}||vs�|j|	kr�|�|j||f�||j7}q3zt�|�Wn$ty�}z|jtjkr��td	�}|�||�WYd}~q3d}~ww|d7}q3q,|
��|�d
d�}	||	k�rU||	}|jtd�d
|d�}
d}|�rQ||	k�rQ|dk�rQ|
�|�|��\}}}zt�|�Wn&t�y6}z|jtjk�r!�td	�}|�||�WYd}~nd}~ww||j8}|d7}||j7}|�rQ||	k�rQ|dks�|
��|�td�||t|�dddt|�dddf�dS)Nri�Qsremoving unnecessary filesr<)r>r�s/packs/rs0warning: file %s was removed by another process
rs
cachelimitsenforcing cache limitsbytesr=s8finished: removed %d of %d files (%0.2f GB to %0.2f GB)
g�@)rrr�queue�
PriorityQueue�timerArrFrrzr!rW�relpathrUrY�errno�ENOENT�warn�st_size�st_atime�putr
r�rH�configbytesr2�status�float)r �keepkeysr�	cachepathr��originalsizer�rL�removed�limitrMr{r|rx�filer!r�pathstat�e�msg�excess�
removedexcess�atime�oldpath�oldpathstatr$r$r%�gc<s�
�

���

���

�+

�
���

����zbasestore.gc)Fr1)�__name__�
__module__�__qualname__r&r0r;rOrIr4rdrJrbr'r�r�r�r)r�r�r$r$r$r%rs"

	""	rc@s(eZdZdd�Zdd�Zedd��ZdS)�baseunionstorecOs$|�dd�d|_|�dd�|_dS)N�
numretriesrr�retrylog)r2�numattemptsr�)r �args�kwargsr$r$r%r&�szbaseunionstore.__init__cCs$|jD]}t�|d�r|��qdS)Nsmarkforrefresh)�storesr	�safehasattr�markforrefresh)r �storer$r$r%r��s

��zbaseunionstore.markforrefreshcsdd����fdd�}|S)NcWsdSr1r$)r�r$r$r%�noop�sz&baseunionstore.retriable.<locals>.noopcs�|jp�}�j}d}||jkrR|dkr"|d|t�|�f�|��|d7}z�|g|�Ri|��WStyJ||jkrH|dt�|���Ynw||jksdSdS)Nrsre-attempting (n=%d) %s
rs*retries exhausted in %s, raising KeyError
)r�r�r�r�sysbytesr�r�)r r�r�r��funcname�i��fnr�r$r%�wrapped�s2

��
�����z)baseunionstore.retriable.<locals>.wrappedr$)r�r�r$r�r%�	retriable�szbaseunionstore.retriableN)r�r�r�r&r��staticmethodr�r$r$r$r%r��s

r�)�
__future__rr�rr�rUr��mercurial.i18nr�mercurial.noderr�mercurial.pycompatr�	mercurialrrr	�mercurial.utilsr
�rr
�objectrr�r$r$r$r%�<module>s"

https://t.me/RX1948 - 2025