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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/commandserver.cpython-310.pyc
o

�]Lb\b�@slddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	z	ddl
Z
e
jWney>ddl
mZ
YnwddlmZddlmZddlmZmZmZmZmZmZmZddlmZmZGd	d
�d
e�ZGdd�de�Z Gd
d�de�Z!ddd�iZ"dd�Z#Gdd�de�Z$d"dd�Z%Gdd�de�Z&dd�Z'dd�Z(Gdd�de�Z)Gd d!�d!e�Z*dS)#�)�absolute_importN�)�
selectors2)�_)�getattr)�encoding�error�loggingutil�pycompat�	repocache�util�vfs)�cborutil�procutilc@s4eZdZdZdd�Zedd��Zdd�Zdd	�Zd
S)�channeledoutputz^
    Write data to out in the following format:

    data length (unsigned int),
    data
    cC�||_||_dS�N)�out�channel)�selfrr�r�9/usr/lib/python3/dist-packages/mercurial/commandserver.py�__init__3�
zchanneledoutput.__init__cC�
d|jS�Ns<%c-channel>�r�rrrr�name7�
zchanneledoutput.namecCs6|sdS|j�t�d|jt|��|�|j��dS)N�>cI)r�write�struct�packr�len�flush)r�datarrrr!;s zchanneledoutput.writecC�|dvrt|��t|j|�S�N)�isatty�fileno�tell�seek)�AttributeErrorrr�r�attrrrr�__getattr__B�zchanneledoutput.__getattr__N)	�__name__�
__module__�__qualname__�__doc__r�propertyrr!r0rrrrr+s
rc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�channeledmessagea	
    Write encoded message and metadata to out in the following format:

    data length (unsigned int),
    encoded message and metadata, as a flat key-value dict.

    Each message should have 'type' attribute. Messages of unknown type
    should be ignored.
    TcCst||�|_||_||_dSr)r�_coutr�	_encodefn)rrr�
encodename�encodefnrrrrVs
zchanneledmessage.__init__cKs0t�|�}|dur
||d<|j�|�|��dS)Nsdata)r
�byteskwargsr8r!r9)rr&�optsrrrr![s
zchanneledmessage.writecCst|j|�Sr)rr8r.rrrr0aszchanneledmessage.__getattr__N)r2r3r4r5�
structuredrr!r0rrrrr7Hsr7c@s`eZdZdZdZdd�Zedd��Zddd	�Zd
d�Z	ddd
�Z
dd�Zdd�ZeZ
dd�ZdS)�channeledinputa/
    Read data from in_.

    Requests for input are written to out in the following format:
    channel identifier - 'I' for plain input, 'L' line based (1 byte)
    how many bytes to send at most (unsigned int),

    The client replies with:
    data length (unsigned int), 0 meaning EOF
    data
    icCs||_||_||_dSr)�in_rr)rr@rrrrrrts
zchanneledinput.__init__cCrrrrrrrryrzchanneledinput.name���cCsP|dkr!|j}|�||j�}|}|r|�||j�}||7}|s|S|�||j�S�Nr)�maxchunksize�_readr�r�size�s�bufrrr�read}s�zchanneledinput.readcCsd|sdS|dks
J�|j�t�d||��|j��|j�d�}t�d|�d}|s,dS|j�|�S)N�rr ��>I)rr!r"r#r%r@rI�unpack)rrFr�lengthrrrrD�s
zchanneledinput._readcCs^|dkr)|j}|�|d�}|}|r'|�d�s'|�|d�}||7}|r'|�d�r|S|�|d�S)Nr�L�
)rCrD�endswithrErrr�readline�s�zchanneledinput.readlinecCs|Srrrrrr�__iter__��zchanneledinput.__iter__cCs|��}|st�|Sr)rR�
StopIteration)r�lrrr�next�szchanneledinput.nextcCr'r()r-rr@r.rrrr0�r1zchanneledinput.__getattr__N)rA)r2r3r4r5rCrr6rrIrDrRrSrW�__next__r0rrrrr?es


r?scborcCsd�t�|��S�NrJ)�joinr�streamencode)�vrrr�<lambda>�sr]cCsD|�dd�}|D]}t�|�}|r||fSqt�dd�|���)N�	cmdserversmessage-encodingss"no supported message encodings: %s� )�
configlist�_messageencoders�getr�AbortrZ)�ui�encnames�n�frrr�_selectmessageencoder�s
��rhc@sleZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
ed�Z
dd�ZdS)�serverzm
    Listens for commands on fin, runs them and writes the output on a channel
    based stream to fout.
    NcCst��|_|r|j|_||_|j|_n	||_d|_|_||_t|d�|_	t|d�|_
t|d�|_t||d�|_
t|d�|_|j�dd�dkrV|j��|_t|jd|j	d	�d|_|�d
d�dkrot|�\}}t|d
||�|_||_|�dd�|_d|_|js�t�tjtj�|_dSdS)N�d�e�o�I�rr^�log�-)�repo�fp�uismessage-outputschannel�msshutdown-on-interrupt)r�getcwd�cwd�baseuirdrq�repoui�_prereposetupsr�cdebug�cerr�coutr?�cin�cresult�config�copy�setuplogging�cmsgrhr7�client�
configbool�_shutdown_on_interrupt�_old_inthandler�signal�SIGINT�SIG_IGN)rrdrq�fin�fout�
prereposetups�encname�encfnrrrr�s8

��zserver.__init__cCs|js
t�tj|j�dSdS)z9release and restore resources taken during server sessionN)r�r�r�r�rrrr�cleanups�zserver.cleanupcCs |sdS|j�|�}|st�|SrY)r�rI�EOFError)rrFr&rrrrDszserver._readcCs(t�d|�d��d}|sdS|�|�S)z[read a string from the channel

        format:
        data length (uint32), data
        rLrKrrJ)r"rMrD)rrNrrr�_readstrs
zserver._readstrcCs|��}|r|�d�SgS)z6read a list of NULL separated strings from the channel�)r��split)rrGrrr�	_readlists
zserver._readlistc
Cs�ddlm}|jr|�|�Sz3zt�tj|j�|�|�WWt�tjtj�Stjy/�t	y7YnwWt�tjtj�n	t�tjtj�w|j
�td��dS)Nr��dispatchs
interrupted!
rA)�r�r�r�r�r�r�r�SignalInterrupt�KeyboardInterruptrdr)r�reqr�rrr�_dispatchcommand$s 
��$zserver._dispatchcommandc	
Cs*ddlm}|��}|j��}|g}|jr7||j_|j�|j�}|j|_|�	|�||j_|jj
_|j��|D]}|�
�t�|jd�sN|�dddd�q9|j|dd�||j|j|j|j|j|jd	�}z"|�|�d
@}|j�t�dt|���Wd|vr�t�|j�dSdSd|vr�t�|j�ww)
zireads a list of  terminated arguments, executes
        and writes the return code to the result channelrr�sfilenorssnonttystrues
commandserverN�r��s>is--cwd) r�r�r�rdr�rqrwrx�	__class__�append�dirstate�_ui�
invalidateall�
resetstater�safehasattrr}�	setconfig�requestr|r{r�ryr�r~r!r"r#�int�os�chdirrv)	rr��args�copiedui�uisrxrdr��retrrr�
runcommand>sD


�
���zserver.runcommandcCs|j�tj�dS)z1writes the current encoding to the result channelN)r~r!rrrrr�getencodingpszserver.getencodingcCsP|j��dd�}|r$|j�|�}|r||�|dkSt�td�|��|dkS)NrAsunknown command %srJ)r�rR�capabilitiesrbrrcr)r�cmd�handlerrrr�serveonets�zserver.serveone)s
runcommandsgetencodingcCs�dd�t|j��}|d7}|dtj7}|d7}|jr$|d|jj7}|dt��7}t�t	d�r?|d7}|dt	�
d	�7}|j�|�z|�
�rR	|�
�sJWd	SWd	Sty^Yd
Sw)Nscapabilities: r_rPs
encoding: smessage-encoding: %s
spid: %dsgetpgidspgid: %drr)rZ�sortedr�rr�r�getpidrr�r��getpgidr|r!r�r�)r�hellomsgrrr�serve�s*
����zserver.server)r2r3r4r5rr�rDr�r�r�r�r�r�r�r�rrrrri�s
.2

ricCs�|�dd�}|s
dSt|�dd��}|dkr|rt�||�}n7|dkr+t�|j|�}n+t�t�|��}|�	dd�}|�
dd�}t�t
j�|��}tj|t
j�|�|||d�}|h}	|rg|	�|j�|	�|j�|	D]}
|
�d|�qidS)	z�Set up server logging facility

    If cmdserver.log is '-', log messages will be sent to the given fp.
    It should be the 'd' channel while a client is connected, and otherwise
    is the stderr of the server process.
    r^roNs	track-logrps
max-log-filessmax-log-size)�maxfiles�maxsize)r�setr`r	�fileobjectlogger�ferrr�abspath�
expandpath�	configint�configbytes�vfsmodr
r��path�dirname�
filelogger�basename�addrwrd�	setlogger)rdrqrr�logpath�tracked�loggerr�r�r
�	targetuis�urrrr��s4
��r�c@s$eZdZdd�Zdd�Zdd�ZdS)�pipeservicecCrr)rdrq)rrdrqr=rrrr�rzpipeservice.__init__cCsdSrrrrrr�init�rTzpipeservice.initc	Csd|j}|���!\}}t||j||�}z|��W|��Wd�S|��w1s+wYdSr)rd�protectedfinoutrirqr�r�)rrdr�r��svrrr�run�s�
�zpipeservice.runN)r2r3r4rr�r�rrrrr��sr�cCst�dd�t��dSrB)r��setpgid�random�seedrrrr�_initworkerprocess�sr�c
Cs�|�d�}|�d�}d}z�zZ||||||�}zJz|��Wn=tjy:}z|�td�|j�WYd}~n%d}~wtyR}z
|jtjkrH�WYd}~n
d}~wt	yZYnwW|�
�n|�
�wWn|rq|j}	nt|d�}	|	�
t�t�����W|��z|��WdSty�}z|jtjkr��WYd}~dSd}~ww|��z|��Wwty�}z
|jtjkr��WYd}~wd}~ww)N�rb�wbs
abort: %s
rk)�makefiler�rrcr�message�IOError�errno�EPIPEr�r�r{rr!r�
strtolocal�	traceback�
format_exc�close)
rdrq�conn�createcmdserverr�r�r�r��instr{rrr�
_serverequest�sZ

 �����
��������r�c@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�unixservicehandlerz�Set of pluggable operations for unix-mode services

    Almost all methods except for createcmdserver() are called in the main
    process. You can't pass mutable resource back from createcmdserver().
    NcCs
||_dSr)rd)rrdrrrrs
zunixservicehandler.__init__cCs:t�||�|�tj�|j�td�|�|j��dS)Nslistening at %s
)	r�bindunixsocket�listen�socket�	SOMAXCONNrd�statusrr%)r�sock�addressrrr�
bindsocketszunixservicehandler.bindsocketcCst�|�dSr)r��unlink)rr�rrr�unlinksocket#szunixservicehandler.unlinksocketcC�dS)z9True if server should shut down; checked per pollintervalFrrrrr�
shouldexit&szunixservicehandler.shouldexitcCr�)z/Called when main process notices new connectionNrrrrr�
newconnection*sz unixservicehandler.newconnectioncCst|j||||�S)zhCreate new command server instance; called in the process that
        serves for the current connection)rird)rrqr�r�r�r�rrrr�-sz"unixservicehandler.createcmdserver)r2r3r4r5�pollintervalrr�r�r�r�r�rrrrr�sr�c@sreZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�unixforkingservicezG
    Listens on unix domain socket and forks server per connection
    NcCs�||_||_|d|_t�td�st�td���|js"t�td���|p't	|�|_
d|_d|_d|_
d|_t�|_d|_|�dd�}|dkrMt�td���t�||�|_tjr]t��dSdS)	NsaddresssAF_UNIXsunsupported platforms'no socket path specified with --addressr^smax-repo-cachers(negative max-repo-cache size not allowed)rdrqr�rr�r�rrcrr��_servicehandler�_sock�_mainipc�
_workeripc�_oldsigchldhandlerr��_workerpids�_socketunlinkedr�r�
repoloader�_repoloaderr
�isdarwinr�gui)rrdrqr=r��maxlenrrrr8s*
�zunixforkingservice.__init__cCs~t�tj�|_t�tjtj�}|\|_|_|j�|j|j	�t
�td�r*t�
tj�t�tj|j�}||_d|_|j��dS)Ns
unblocksignalF)r��AF_UNIXr��
socketpair�
SOCK_DGRAMr�r�r�r�r�rr�r�
unblocksignalr��SIGCHLD�_sigchldhandlerr�r�r��start)r�orrrr�Qszunixforkingservice.initcCs"|js|j�|j�d|_dSdS)NT)r�r�r�r�rrrr�
_unlinksocket`s
�z unixforkingservice._unlinksocketcCsNt�tj|j�|j��|j��|j��|��|j�	�|�
d�dSrB)r�rr�r�r�r�r�r
r��stop�_reapworkersrrrr�_cleanupes



zunixforkingservice._cleanupcCs"z|��W|��dS|��wr)�	_mainloopr
rrrrr�os
zunixforkingservice.runc
Cs�d}|j}t��}|�|jtj|j�|�|jtj|j�	|s*|�	�r*|�
�d}z	|j|jd�}Wnt
yN}z|jtjkrB�g}WYd}~nd}~ww|sU|rTnq|D]\}}|�|j|�qWq|��dS)NFT)�timeout)r��	selectors�DefaultSelector�registerr��
EVENT_READ�_acceptnewconnectionr��_handlemainipcr�r
�selectr��OSErrorr��	ETIMEDOUTr&�fileobjr�)r�exiting�h�selector�eventsr��key�_maskrrrrus:�����zunixforkingservice._mainloopcCs|j}z|��\}}Wntjy(}z|jdtjkr#WYd}~dS�d}~wwt��}|rNz|j	�
dd|�|j�|�|�
�W|��dS|��wz#|��|��|j��|�|�|��|j��t�d�WdSz|j	jdd�Wt�d�YdSt�d�w)Nrr^sforked worker process (pid=%d)
T)�forcer�)r��acceptr�rr�r��EINTRr��forkrd�logr�r�r�r�r��
_runworkerr��_exitr�)rr�rrr��_addrr��pidrrrr�s<��	�



z'unixforkingservice._acceptnewconnectionc
CsZz|�d�}Wntjy$}z|jdtjkrWYd}~dS�d}~ww|j�|�dS)z#Process messages sent from a workeri�rN)�recvr�rr�r�r"r��load)rr�rr�r�rrrr�s��z!unixforkingservice._handlemainipccCs|�tj�dSr)rr��WNOHANG)rr��framerrrr�sz"unixforkingservice._sigchldhandlerc
Cs�|jrRz
t�d|�\}}Wn+ty8}z|jtjkr!WYd}~q|jtjkr(�|j��WYd}~dSd}~ww|dkr?dS|j�	dd|�|j�
|�|jsdSdS)NrArr^sworker process exited (pid=%d)
)r�r��waitpidrr�r"�ECHILD�clearrdr$�discard)r�optionsr(�_statusr�rrrr�s"
���zunixforkingservice._reapworkerscCsRt�tj|j�t�|j}zt|j|j||j|j	gd�Wt
��dSt
��w)Nr�)r�rr�r�r�r�rdrqr��
_reposetup�gc�collect)rr�rrrrr%�s�zunixforkingservice._runworkercsl|��sdSG�fdd�d|j���|_|j|_|j�|j�}|dur%dS|j�dd|j�t	�
||�dS)NcseZdZ��fdd�Z�ZS)z8unixforkingservice._reposetup.<locals>.unixcmdserverrepocsHt�|���z
|j�|j�WdStjy#|j�dd�YdSw)Nr^s#failed to send repo root to master
)	�superr��
_cmdserveripc�send�rootr�rrdr$r)r��unixcmdserverreporrr��s
��z>unixforkingservice._reposetup.<locals>.unixcmdserverrepo.close)r2r3r4r��
__classcell__r�r:)r�rr:�sr:s	repocachesrepo from cache: %s
)�localr�r�r7r�rbr9rdr$r�	copycache)rrdrq�
cachedreporr<rr3�s
zunixforkingservice._reposetupr)r2r3r4r5rr�r
r
r�rrrrrr%r3rrrrr�3s

%&
r�)NN)+�
__future__rr�r4r�r�r�r�r"r�r�BaseSelector�ImportError�
thirdpartyr�i18nrr
rr�rrr	rrr
r��utilsrr�objectrr7r?rarhrir�r�r�r�r�r�rrrr�<module>sB
�$	X�
R)%"

https://t.me/RX1948 - 2025