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

�]Lb-Y�@sddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
mZmZmZmZmZddlmZmZddlmZmZmZejZdadadadadZ d	d
�Z!dd�Z"d
d�Z#Gdd�de$�Z%dd�Z&dd�Z'dd�Z(Gdd�de$�Z)dS)�)�absolute_importN)�_)�bin�hex)�error�pycompat�revlog�sshpeer�util�wireprotov1peer)�hashutil�procutil�)�	constants�contentstore�
metadatastorecCs4tt�|����}tj�||dd�|dd�|�S)N��rr�sha1�digest�os�path�join)�reponame�file�id�pathhash�r�F/usr/lib/python3/dist-packages/hgext/remotefilelog/fileserverclient.py�getcachekey0s"rcCs tt�|����}tj�||�S�Nr)rrrrrr�getlocalkey5sr!cs G�fdd�d|j���|_dS)NcsPeZdZejdd��Zejdd��Zdd�Z��fdd�Z��fd	d
�Z	�Z
S)z!peersetup.<locals>.remotefilepeercs0|�d�s
t�d����fdd�}��d�|fS)N�
x_rfl_getfiles5configured remotefile server does not support getfilecs*|�dd�\}}t|�rt���|��|S)N�r)�split�intr�LookupError)�d�code�data�r�noderr�decodeCsz?peersetup.<locals>.remotefilepeer.x_rfl_getfile.<locals>.decode�sfilesnode��capabler�Abort)�selfrr+r,rr*r�
x_rfl_getfile<s
�z/peersetup.<locals>.remotefilepeer.x_rfl_getfilecSs(|�d�s
t�d��dd�}d|i|fS)Nsx_rfl_getflogheadss:configured remotefile server does not support getflogheadscSs|r|�d�SgS)N�
)r$)r'rrrr,S�zDpeersetup.<locals>.remotefilepeer.x_rfl_getflogheads.<locals>.decodespathr.)r1rr,rrr�x_rfl_getflogheadsKs
�z4peersetup.<locals>.remotefilepeer.x_rfl_getflogheadscSs�|dkrdStj|��vrdSt�|d�sdStj|jjvr dS|�d�}|r+|g}ng}|�	tj
�|jjrGd�|jj�}d|}|�	|�|jj
r[d�|jj
�}d|}|�	|�d�|�|d<dS)Ns	getbundle�
_localrepos
bundlecapsr#sincludepattern=sexcludepattern=�,)r�NETWORK_CAP_LEGACY_SSH_GETFILES�capabilitiesr
�safehasattr�SHALLOWREPO_REQUIREMENTr6�requirements�get�append�BUNDLE2_CAPABLITY�includepatternr�excludepattern)r1�command�opts�
bundlecaps�patterns�
includecap�
excludecaprrr�_updatecallstreamoptsXs4��
	

z7peersetup.<locals>.remotefilepeer._updatecallstreamoptscs&|�||�t�|�j||fi|��Sr )rH�super�_sendrequest)r1rB�argsrC��	__class__�remotefilepeerrrrJ�s
��z.peersetup.<locals>.remotefilepeer._sendrequestcs@t�|�}t�|d�s|�|t�|��t�|�j|fi|��S)NrJ)rIr
r:rHr�byteskwargs�_callstream)r1rBrC�	supertyperLrrrP�s
z-peersetup.<locals>.remotefilepeer._callstream)�__name__�
__module__�__qualname__r�	batchabler2r5rHrJrP�
__classcell__r�rN�rMrrN;s

(rNrX)�ui�peerrrWr�	peersetup:s
Qr[c@s:eZdZdZdd�Zdd�Zdd�Zdd	d
�Zdd�Zd
S)�cacheconnectionz�The connection for communicating with the remote cache. Performs
    gets and sets by communicating with an external process that has the
    cache-specific implementation.
    cCs"d|_|_|_d|_d|_dS)NF)�pipeo�pipei�pipee�
subprocess�	connected�r1rrr�__init__�s
zcacheconnection.__init__cCs8|jr
t�td���t�|�\|_|_|_|_d|_	dS)Nscache connection already openT)
r]rr0rr
�popen4r^r_r`ra)r1�cachecommandrrr�connect�s�
zcacheconnection.connectcCs�dd�}|jrEz|j�d�Wn	tyYnw||j�d|_||j�d|_||j�d|_z|j��Wn	tyAYnwd|_d|_dS)NcSs$z|��WdStyYdSwr )�close�	Exception)�piperrr�tryclose�s
�z'cacheconnection.close.<locals>.tryclosesexit
F)rar^�writerhr]r_r`�communicate)r1rjrrrrg�s(�


�
zcacheconnection.closeTcCsN|jr%z|j�|�|r|j��WdSWdSty$|��YdSwdSr )rar^rk�flush�IOErrorrg)r1�requestrmrrrro�s���zcacheconnection.requestcCsR|jsdSz|j��dd�}|s|��W|SW|Sty(|��Y|Sw)N���)rar]�readlinergrn)r1�resultrrr�receiveline�s
��
�zcacheconnection.receivelineN�T)	rRrSrT�__doc__rcrfrgrorsrrrrr\�s
	r\c
Cs�|���Q}g}|D]}|�|�d|||dd�d���q	t|�D]*\}	}||	��}
d||	<||}|dd�}|t�dt|
�|
f�||�|�q"Wd�dS1sXwYdS)Nr"����r-s%d
%s)�commandexecutorr>�callcommand�	enumeraterr�io�BytesIO�len)
�remote�receivemissing�progresstick�missed�idmap�	batchsize�e�futures�m�i�r�file_r+rrr�_getfilesbatch�s"

���"�r�cCs�|�d�d}|j}|j}|t|�krd|}	tt|�|	|�}
|
}||	|
�D]}|dd�}||}
d||
f}|�|�q&|��||	|
�D]}|dd�}||}
|||
|�|�qH|t|�ks|�d�|��dS)N�x_rfl_getfilesrrv�%s%s
r3)rP�_pipeo�_pipeir|�minrkrm)r}r~rr�r��stepr�r]r^�start�end�	missingid�	versionidr�
sshrequestrrr�_getfiles_optimistic�s,
�
r�cs�|�d�|j�|j}���fdd�}tj|d�}d|_|���D]}	|	dd�}
�|	}||||
�|�q"|����d���	�dS)Nr�cs@�D]}|dd�}�|}d||f}��|�q���dS)Nrvr�)rkrm)r�r�rr��r�r�r]rr�writersz"_getfiles_threaded.<locals>.writer)�targetTrvr3)
rPr�r��	threading�Thread�daemonr�rrkrm)r}r~rr�r�r�r^r��writerthreadr�r�rrr�r�_getfiles_threadeds

r�c@sdeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
	ddd�Zdd�Zdd�Z
dS)�fileserverclientz:A client for requesting files from the remote file server.cCs\|j}||_||_|�dd�|_|jrt�|j�|_|�dd�|_|�dd�|_t	�|_
dS)N�
remotefilelogscacheprocessscacheprocess.includepathsdebug)rY�repo�config�cacheprocessr
�
expandpath�
configbool�cacheprocesspasspath�debugoutputr\�remotecache)r1r�rYrrrrc5s�zfileserverclient.__init__cCs||_||_||_||_dSr )�	datastore�historystore�	writedata�writehistory)r1r�r�r�r�rrr�setstoreGs
zfileserverclient.setstorecCs|jj�|jj�Sr )r��connectionpoolr=�fallbackpathrbrrr�_connectMr4zfileserverclient._connectc	CsH|jjs|��|j}|j}|j}t|�}d|}i}|j}|D]\}	}
t||	|
�}|jr3||	d7}||d7}|	||<q |�	|�|j
jtd�|d�}|�
d�g}
	|��}|svt|
�}|D]}||vrl|
�|�qa|j
�td��n|d	kr{n|�d
�r�|�d�}|�t|d��qT|
�|�qUtt|
�7a|t|
�}|j
||d�|j
jd
d||||d�t�d�}z�|
�r�|j
j}d|j
_z�z�|���s}|j}|�tj��rt |t!�s�t"�#d��|j
�$d
d�}|j
�%d
d�}|dkr�t&}nt'}|||j(|j|
||�n4|�d��r2|�d��rd}nd}|j
�$d
d|�}|j
�)dt|
��t*||j(|j|
||�nt"�#d��Wd�n	1�sBwY|j
jdd|j+|||d�Wnt,�yo|j
jdd |j+|||d��wW||j
_n||j
_wd!t|
�d�-|
�f}|�	|�|�.�|�/|jj0�Wt�|�dSt�|�w)"z�Takes a list of filename/node pairs and fetches them from the
        server. Files are stored in the local cache.
        A list of nodes that the server couldn't find is returned.
        If the connection fails, an exception is raised.
        sget
%d
r#r3sdownloading)�totalrTs@warning: cache connection closed early - falling back to server
�0s_hits_�_rr�s"remote cache hit rate is %r of %r
)�hitr�Fs"remotefilelog requires ssh serverssgetfilesstepsgetfilestypesthreadedr"sbatch�d�
s	batchsizes1requesting %d files from remotefilelog server...
s>configured remotefilelog server does not support remotefilelogNsremotefilefetchlogsSuccess
)�
fetched_files�total_to_fetchsFail
s
set
%d
%s
)1r�rarfr�r�r|�namerr�rorY�makeprogressr�updaters�setr>�warn�
startswithr$�	incrementr%�fetchmisses�logr�umask�verboser�rZr/rr8�
isinstance�
_sshv1peerrr0�	configintr�r�r�r~�debugr��posrhr�complete�markrepor)r1�fileids�cacher�r�r�ror�rrr�fullid�progressr�r��	missedset�parts�	fromcache�oldumaskr��connr}r��getfilestype�	_getfiles�batchdefaultr�rrrroPs



���


��
	
�
��������	���5
����
zfileserverclient.requestcCs�|��dd�}|st�td�td���t|�}|�|�}t|�|kr3t�td�td�t|�|f��|j�|t	|�t
�|��dS)Nrps error downloading file contents:sconnection closed earlysonly received %s of %s bytes)rqr�
ResponseErrorrr%�readr|r��addremotefilelognoder�zlib�
decompress)r1ri�filenamer+�line�sizer)rrrr~�s �
��zfileserverclient.receivemissingcCsD|jrd|j|jjf}|j�|�dSGdd�dt�}|�|_dS)Ns%s %sc@s.eZdZdd�Zdd�Zddd�Zdd	�Zd
S)z-fileserverclient.connect.<locals>.simplecachecSsg|_d|_dS)NT)�
missingidsrarbrrrrc
s
z6fileserverclient.connect.<locals>.simplecache.__init__cSsdSr rrbrrrrgsz3fileserverclient.connect.<locals>.simplecache.closeTcSs8|�d�}|ddkr
dS|dd�|_|j�d�dS)Nr3rsgetrrpr�)r$r�r>)r1�valuerm�linesrrrros

z5fileserverclient.connect.<locals>.simplecache.requestcSst|j�dkr
|j�d�SdS)Nr)r|r��poprbrrrrssz9fileserverclient.connect.<locals>.simplecache.receivelineNrt)rRrSrTrcrgrorsrrrr�simplecache	s

r�)r�r��_pathr�rf�object)r1�cmdr�rrrrfs
zfileserverclient.connectcCsztr0dtttttt�tt�dtf}|jr|j�|�|jjd|�	dd�ttttdd�|j
jr;|j
��dSdS)NsN%d files fetched over %d fetches - (%d misses, %0.2f%% hit ratio) over %0.2fs
gY@sremotefilelog.prefetch�%s%%i�)�remotefilelogfetched�remotefilelogfetches�remotefilelogfetchmisses�remotefilelogfetchtime)
�fetches�fetchedr��float�	fetchcostr�rYr�r��replacer�rarg)r1�msgrrrrgs,��

�	�zfileserverclient.closeFTcs��j}g}|D]\}}|dkst|�dks|�|�sq|�|t|�f�q�j}	�j}
|r9tj|j	�}	t
j|j�}
t
�}|rF|�|	�|��|rP|�|
�|��t�fdd�|D��}|rp�fdd�|D�}|jjd|dd�|r�td	7atd
kr�tdkr�td
kr��j�dd
�}
|
r��j�|
d����dd�t|�D�}tt|�7at��}��|�}|r�t�td�t|���tt��|7a��|�dSdS)z.downloads the given file versions to the caches.hgtags�*cs g|]\}}|�jjkrd�qSr �r��nullid)�.0�unusedrrbrr�
<listcomp>^s z-fileserverclient.prefetch.<locals>.<listcomp>cs$g|]\}}|�jjkr||f�qSrr�)r��frrbrrr�assDremotefilelog not fetching %d null revs - this is likely hiding bugssremotefilelog-ext)r�r��r�sfetchwarningr3cSsg|]
\}}|t|�f�qSr)r)r�rrrrrr�yssunable to download %d filesN)r�r|�shallowmatchr>rr�r�r�unioncontentstore�shareddatastoresr�unionmetadatastore�sharedhistorystoresr�r��
getmissingrY�	develwarnr�r�r��
logstacktrace�sortedr��timerorr0rr��_lfsprefetch)r1r��force�	fetchdata�fetchhistoryr��
idstocheckrrr�r�r��nullids�fetchwarningr�rrbr�prefetch9sn���
����
��zfileserverclient.prefetchc
s�tr
t�|jjd�sdStj�|j�sdSg}|jjj�|D]/\}}t|�}|j�	|�}|�
|�tj@rM|�
|�}tj�|�}|��}	��|	�sM|�|�qt|�dkrj|jjj�|��t�fdd�|D��slJ�dSdS)Nslfslocalblobstorerc3s�|]
}��|���VqdSr )�has�oid)r��p��storerr�	<genexpr>�s�z0fileserverclient._lfsprefetch.<locals>.<genexpr>)�_lfsmodr
r:r��svfs�wrapper�candownload�lfslocalblobstorerr�flagsr�REVIDX_EXTSTORED�rawdata�pointer�deserializer
rr>r|�lfsremoteblobstore�	readbatch�all)
r1r��pointersrrr+�rlog�textrr
rrrr�s.�



��zfileserverclient._lfsprefetchc	Cs0ddl}|j�ddd�dd�|��D���dS)Nrr�s"excess remotefilelog fetching:
%s
�css�|]}t�|�VqdSr )r�sysbytes)r��srrrr�s�z1fileserverclient.logstacktrace.<locals>.<genexpr>)�	tracebackrYr�r�format_stack)r1r%rrrr�s�zfileserverclient.logstacktraceN)FTF)rRrSrTrurcr�r�ror~rfrgrrrrrrrr�2s
�Kr�)*�
__future__rrzrr�rr��mercurial.i18nr�mercurial.noderr�	mercurialrrrr	r
r�mercurial.utilsrr
�rrr�	sshv1peerr�r�r�r�r�rrr!r[r�r\r�r�r�r�rrrr�<module>s2 UE 

https://t.me/RX1948 - 2025