403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/hgext/remotefilelog/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/hgext/remotefilelog/__pycache__/basestore.cpython-39.opt-1.pyc
a

�+�b�?�@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|_||_||_||_tjs.t��nd|_	|j�
dd�|_|j�
ddd�|_|jdvrfd|_|jdkrvd|_|r�t
�|j|�dS)	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�_sharedrZ	iswindows�os�getuid�_uidZconfig�_validatecachelog�_validatecacher
�mkstickygroupdir)�selfr�pathZreponameZshared�r �C/usr/lib64/python3.9/site-packages/hgext/remotefilelog/basestore.py�__init__s$
��

zbasestore.__init__cCs^g}|D]P\}}|�||�}tj�|�}|rF|jdkrF|�|d�sFd}|s|�||f�q|S)NrscontainsF)�_getfilepathrr�existsr�_validatekey�append)r�keys�missing�name�node�filepathr$r r r!�
getmissing8s��
�zbasestore.getmissingNcCsV|r|�tj�rdS|jrR|��D].\}}|D] }|�|||�|�|||�q.q"dS�N)�getrZOPTION_PACKSONLYr�	_getfilesZ
markdataentryZmarkhistoryentry)r�ledger�options�filenameZnodesr*r r r!�
markledgerJszbasestore.markledgercCs�|j}|j�|g�}d}|jtd�dt|�d�}|D]B}|jsJ|jrn|jrn|�	|�|�
|j|j�}t
�|�|d7}q4|��|�|���dS)Nrscleaning up�files��unit�totalr)rZsourcesr.�makeprogressr�lenZgcedZdatarepackedZhistoryrepacked�updater#r2r*r	�	tryunlink�complete�_cleanupdirectory�_getrepocachepath)rr0r�entries�count�progress�entryrr r r!�cleanupSs�


zbasestore.cleanupc		Cs�t�}t�}tj�|�D]�\}}t�|�rftj�||�}|�	|�zt�
|�Wq�tybYq�0qt�|�r|�
d�r�|�|dd��q|�|�q||D] }tj�||d�}t�|�q�dS)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	Zosutil�listdir�stat�S_ISDIRrr�joinr=�rmdir�OSError�S_ISREG�endswith�addr;)	rZrootdirZoldfilesZ
otherfilesr)�mode�dirpathr2r+r r r!r=gs"



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'rZ	iteritems)r�existing�filenamehashr*Zfilenamemapr2�shar r r!r/�szbasestore._getfilesc	Cs�|siSi}t|�}|jd��D],}t�|���}||vr"|||<|�|�q"|j��j}t	�
t|�ddd�D]N}|s~q�|�|�
|��}|D],}t�|���}||vr�|||<|�|�q�qr|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���)rFrZmanifestr
Zsha1�digest�discardZ
unfilteredZ	changelogrZxranger9Z	readfilesr*)	rZhashes�	filenamesZmissingfilenamer2rWZclZrev�filesr r r!rT�s(zbasestore._resolvefilenamescCs|jrtj�|j|j�S|jSr-)rrrrJrr)rr r r!r>�s��zbasestore._getrepocachepathccsxt�|���D]d\}}}|D]T}t|�dkr.q|}|jrR|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�walkr>r9rr)r�root�dirsr\r2r*rVr r r!rR�szbasestore._listkeyscCs<t|�}|jr t�|j||�}nt�||�}tj�|j	|�Sr-)
rrr
ZgetcachekeyrZgetlocalkeyrrrJr)rr)r*�keyr r r!r#�s
zbasestore._getfilepathc	Cs�|�||�}z|t�|�}|jr�|�||�s�|jrjt|jd��}|�d|�Wd�n1s`0Yt�	||d�t
d|��Wn(ty�t
d||t|�f��Yn0|S)N�ab+scorrupt %s during read
�.corruptscorrupt local cache file %ssno file found at %s for %s:%s)
r#r
Zreadfiler�
_validatedatarr�writer�rename�KeyError�IOErrorr)rr)r*r+�data�fr r r!�_getdata�s
,�
zbasestore._getdatac	Cs�|�||�}t�d�}z�tj�|�rN|d}tj�|�rBt�|�t�||�t�	|j
tj�|��tj||dd�|j
r�|�|d�s�t�td�|��Wt�|�nt�|�0dS)N�rDT)�readonlyswrites"local cache write was corrupted %s)r#r�umaskrr$r
�
unlinkfile�shutil�copyrr�dirnameZ	writefilerr%rZAbortr)rr)r*rir+ZoldumaskZnewfilenamer r r!�addremotefilelognode�s 


�zbasestore.addremotefilelognodecCsvtj�|jd�}t|d��&}|�tj�|�d�Wd�n1sF0Yt�|�}|j|j	krrt�
|d�dS)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�)rrrJrrrerrrH�st_uidr�chmod)rrZ	repospathZ	reposfileZ
repospathstatr r r!�markrepo	s4
zbasestore.markrepocCs�t|d��}|��}Wd�n1s(0Y|�||�rBdS|jr�t|jd��"}|�d||f�Wd�n1s|0Yt�||d�dS)NsrbTrbscorrupt %s during %s
rcF)r�readrdrrerrf)rr�actionrjrir r r!r%s&0zbasestore._validatekeyc	Cs�zjt|�dkrht�|�\}}}t|�|kr0WdS||7}|||d�}tj�|�t|�krbWdSWdSWnttjfy�Yn0dS)NrF�T)	r9r
Zparsesizeflagsrr�basenamer�
ValueErrorZBadRemotefilelogHeader)rrir�offset�size�flagsZdatanoder r r!rd%s
zbasestore._validatedatacCs�|j}|j}tj��}d}d}d}d}t��d}	|jtd�dd�}
|
�d�t	�
|�D�]l\}}}
|
D�]Z}|dkrxqhd|vr�qh|
�|�t	j�||�}t	j�
||�}|d7}zt	�|�}WnVt�y}z<|jtjkrނtd	�}|�||�WYd}~qhWYd}~n
d}~00||j7}||v�s6|j|	k�rT|�|j||f�||j7}qhzt�|�WnXt�y�}z>|jtjk�r��td	�}|�||�WYd}~qhWYd}~n
d}~00|d7}qhqX|
��|�d
d�}	||	k�r�||	}|jtd�d
|d�}
d}|�r�||	k�r�|dk�r�|
�|�|��\}}}zt�|�WnLt�y�}z2|jtjk�rh�td	�}|�||�WYd}~n
d}~00||j8}|d7}||j7}�q|
��|�td�||t|�dddt|�dddf�dS)Nri�Qsremoving unnecessary filesr4)r6rts/packs/rs0warning: file %s was removed by another process
rs
cachelimitsenforcing cache limitsbytesr5s8finished: removed %d of %d files (%0.2f GB to %0.2f GB)
g�@)rrr�queueZ
PriorityQueue�timer8rr:rr^rrJ�relpathrHrL�errno�ENOENT�warn�st_size�st_atimeZputr
ror<Zconfigbytesr.�status�float)rZkeepkeysrZ	cachepathr�Zoriginalsizerr@Zremoved�limitrAr_r`r\�filerraZpathstat�e�msgZexcessZ
removedexcessZatimeZoldpathZoldpathstatr r r!�gc<s�
�


�"
�"

�
�$
���zbasestore.gc)F)N)�__name__�
__module__�__qualname__r"r,r3rCr=r/rTr>rRr#rkrsrxr%rdr�r r r r!rs 

	""	rc@s(eZdZdd�Zdd�Zedd��ZdS)�baseunionstorecOs$|�dd�d|_|�dd�|_dS)NZ
numretriesrr�retrylog)r.�numattemptsr�)r�args�kwargsr r r!r"�szbaseunionstore.__init__cCs$|jD]}t�|d�r|��qdS)Nsmarkforrefresh)Zstoresr	Zsafehasattr�markforrefresh)r�storer r r!r��s
zbaseunionstore.markforrefreshcsdd����fdd�}|S)NcWsdSr-r )r�r r r!�noop�sz&baseunionstore.retriable.<locals>.noopcs�|jp�}�j}d}||jkr�|dkrD|d|t�|�f�|��|d7}z�|g|�Ri|��WSty�||jkr�|dt�|���Yq0qdS)Nrsre-attempting (n=%d) %s
rs*retries exhausted in %s, raising KeyError
)r�r�r�rZsysbytesr�rg)rr�r�r��funcname�i��fnr�r r!�wrapped�s,

��
��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�)Z
__future__rr�rrprHr�Zmercurial.i18nrZmercurial.noderrZmercurial.pycompatrZ	mercurialrrr	Zmercurial.utilsr
�rr
�objectrr�r r r r!�<module>s 

Youez - 2016 - github.com/yon3zu
LinuXploit