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

�]LbV�@s�ddlmZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZm
ZmZmZmZmZmZmZddlmZmZdd	lmZejZd
d�Zdd
�ZGdd�dejj�Ze� ej!�Gdd�de"��Z#e� ej$ej%�Gdd�dej&��Z'dS)�)�absolute_importN�)�_)�bin)�getattr�setattr)�bundle2�changegroup�encoding�error�pushkey�pycompat�util�wireprototypes)�
repositoryr)�hashutilcs*�fdd�}t|d��t|d�j�|S)a�annotation for batchable methods

    Such methods must implement a coroutine as follows:

    @batchable
    def sample(self, one, two=None):
        # Build list of encoded arguments suitable for your wire protocol:
        encoded_args = [('one', encode(one),), ('two', encode(two),)]
        # Return it, along with a function that will receive the result
        # from the batched request.
        return encoded_args, decode

    The decorator returns a function which wraps this coroutine as a plain
    method, but adds the original method as an attribute called "batchable",
    which is used by remotebatch to split the call into separate encoding and
    decoding phases.
    csB�|i|��\}}|s
|S|d}t��j�}|�||�}||�S)Nr)r
�bytesurl�__name__�
_submitone)�args�opts�encoded_args_or_res�decode�self�cmd�encoded_res��f��;/usr/lib/python3/dist-packages/mercurial/wireprotov1peer.py�plain9szbatchable.<locals>.plain�	batchabler)rr)rr rrrr!&s	r!csltj�g}|D])\}}t�fdd�|D��sJ�d��fdd�t�|�D��}|�d||f�qd�|�S)z;Return a ``cmds`` argument value for the ``batch`` command.c3s�|]	}�|�|kVqdS�Nr)�.0�k��	escapeargrr�	<genexpr>Ps�z"encodebatchcmds.<locals>.<genexpr>�,c3s(�|]\}}d�|��|�fVqdS)s%s=%sNr)r#r$�vr%rrr'Rs
��
�s%s %s�;)r�escapebatcharg�all�joinr
�	iteritems�append)�req�cmds�op�argsdictrrr%r�encodebatchcmdsGs�
r4c@seZdZdZddd�ZdS)�unsentfuturea0A Future variation to represent an unsent command.

    Because we buffer commands and don't submit them immediately, calling
    ``result()`` on an unsent future could deadlock. Futures for buffered
    commands are represented by this type, which wraps ``result()`` to
    call ``sendcommands()``.
    NcCs,|��rtjj�||�S|j��|�|�Sr")�doner
�futures�Future�result�
_peerexecutor�sendcommands)r�timeoutrrrr9ds

zunsentfuture.resultr")r�
__module__�__qualname__�__doc__r9rrrrr5[sr5c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�peerexecutorcCs2||_d|_d|_g|_t��|_d|_d|_dS)NF)	�_peer�_sent�_closed�_calls�weakref�WeakSet�_futures�_responseexecutor�
_responsef)r�peerrrr�__init__rs

zpeerexecutor.__init__cCs|Sr"r�rrrr�	__enter__{szpeerexecutor.__enter__cCs|��dSr")�close)r�exctype�excvalee�exctbrrr�__exit__~szpeerexecutor.__exit__cs��jrt�d���jrt�d��t�jt���d���s#t�d�������fdd�}t�dd�r=|�}t|_	�|_
|S�jrGt�d���|�}���|S)	Ns4callcommand() cannot be used after commands are sents*callcommand() cannot be used after close()sAcannot call command %s: method of same name not available on peercs.tj��}�j�|��j����|f�|Sr")r
r7r8rG�addrDr/r�r�command�fnrrr�addcall�s
z)peerexecutor.callcommand.<locals>.addcallr!FsX%s is not batchable and cannot be called on a command executor along with other commands)
rBr�ProgrammingErrorrCrrAr
�sysstrr5�	__class__r:rDr;)rrUrrWrrrTr�callcommand�s<�������zpeerexecutor.callcommandc
Cs�|jrdS|js
dSd|_|jD]}t|t�rtjj|_d|_	q|j}d|_t
|�dkrd|d\}}}}|��s:dSz|dit�|���}Wnt
y\t�|t��dd��YdSw|�|�dSg}g}|D]L\}}}}|��suqjz|j|jfit�|���\}	}
Wnt
y�t�|t��dd��YdSw|
s�|�|	�qj|�||	f�|�||t|
f�qj|s�dS|j�|�}tj�d�|_|j�|j||�|_dS)NTrrr)rBrDrG�
isinstancer5r
r7r8rZr:�len�set_running_or_notify_cancel�	strkwargs�	Exception�future_set_exception_info�sys�exc_info�
set_resultr!�__self__r/rA�_submitbatch�ThreadPoolExecutorrH�submit�_readbatchresponserI)rr�callsrUrrVr9�requests�statesrr�wireresultsrrrr;�sd


��
	���
�zpeerexecutor.sendcommandsc
Cs�|��|jr	dSd|_|jsdSz-|j��W|jjdd�d|_d|_|jD]}|��s9|�t	�
td�d��q(d|_dS|jjdd�d|_d|_|jD]}|��s`|�t	�
td�d��qOd|_w)NT)�wait�"unfulfilled batch command response)r;rCrIr9rH�shutdownrGr6�
set_exceptionr�
ResponseErrorr)rrrrrrN
s@
���
�
���zpeerexecutor.closec	
Cs�|D]B\}}}}zt|�}Wnty"|�t�td�d��Yqwz||�}Wnty>t�|t	�
�dd��Yqw|�|�qdS)Nror)�next�
StopIterationrqrrrrr`r
rarbrcrd)	rrlrmrUrr!r�remoteresultr9rrrri*s"���
��zpeerexecutor._readbatchresponseN)
rr=r>rKrMrRr[r;rNrirrrrr@ps	7R r@c@s�eZdZdZdd�Zdd�Zedd��Zedd	��Zed
d��Z	edd
��Z
edd��Zedd��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd3d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd$S)4�wirepeerz�Client-side interface for communicating with a peer repository.

    Methods commonly call wire protocol commands of the same name.

    See also httppeer.py and sshpeer.py for protocol-specific
    implementations of this interface.
    cCst|�Sr")r@rLrrr�commandexecutorPszwirepeer.commandexecutorcCs|�dtd��|�d�S)Nsclonebundless
clone bundles)�
requirecapr�_callrLrrr�clonebundlesUs
zwirepeer.clonebundlescs.��dtd���fdd�}dt�|�i|fS)Nslookupslook up remote revisioncs<|dd��dd�\}}t|�rt|�S��t�|��dS)N���� r)�split�intr�_abortr�	RepoError)�d�success�datarLrrr]szwirepeer.lookup.<locals>.decode�key)rxrr
�	fromlocal)r�keyrrrLr�lookupYszwirepeer.lookupc��fdd�}i|fS)Nc	s@z
t�|dd��WSty��t�td�|��YdSw)Nr{�unexpected response:)r�
decodelist�
ValueErrorrrrrr�r�rLrrrhs
�zwirepeer.heads.<locals>.decoder�rrrrLr�headsfszwirepeer.headscs�fdd�}dt�|�i|fS)Nc	sBzdd�t�|�D�WSty ��t�td�|��YdSw)NcSsg|]}tt|���qSr)�boolr~�r#�brrr�
<listcomp>tsz2wirepeer.known.<locals>.decode.<locals>.<listcomp>r�)r
�iterbytestrr�rrrrrr�rLrrrrs
�zwirepeer.known.<locals>.decode�nodes�r�
encodelist)r�nodesrrrLr�knownpszwirepeer.knowncr�)Nc	svz%i}|��D]}|�dd�\}}t�t�|��}t�|�}|||<q|WSty:��	t
�td�|��YdSw)Nr|rr�)
�
splitlinesr}r
�tolocal�urlreq�unquoterr��	TypeErrorrrrrr)r��	branchmap�
branchpart�
branchname�branchheadsrLrrr|s

�z"wirepeer.branchmap.<locals>.decoderr�rrLrr�zszwirepeer.branchmapcsB��d�s	idfS�j�d����fdd�}dt���i|fS)N�pushkeyspreparing listkeys for "%s"
cs"�j�d�t|�f�t�|�S)Ns$received listkey for "%s": %i bytes
)�ui�debugr]�
pushkeymod�
decodekeysr���	namespacerrrr�s�
z!wirepeer.listkeys.<locals>.decode�	namespace��capabler�r�r
r�)rr�rrr�r�listkeys�s

zwirepeer.listkeyscsX��d�sdS�j�d||f��fdd�}t�|�t�|�t�|�t�|�d�|fS)Nr�)FNspreparing pushkey for "%s:%s"
csf|�dd�\}}ztt|��}Wntyt�td�|��w|�d�D]}�j�	td�|�q%|S)N�
r�"push failed (unexpected response):T�remote: )
r}r�r~r�rrrrr�r��status)r��output�lrLrrr�s��z wirepeer.pushkey.<locals>.decode)r�r�soldsnewr�)rr�r��old�newrrrLrr�s

��zwirepeer.pushkeycCs
|�d�S)Ns
stream_out)�_callstreamrLrrr�
stream_out�s
zwirepeer.stream_outc	Ks"t�|�}|�dtd��i}|�d�pt�}t�|�D]S\}}|dur%qtj�|�}|dur6t	�
d|��|dkr@t�|�}n+|dkrJd�|�}n!|dkrVd�t
|��}n|d	krad
t|�}n
|dkrktd|��|||<q|jdit�|���}td
d�|D��r�t�|j|�St�|d�S)N�	getbundle�look up remote changess
bundlecapss$Unexpectedly None keytype for key %sr�scsvr(sscsvsbooleans%isplains unknown getbundle option type %scss�|]}|�d�VqdS)sHG2N)�
startswith)r#�caprrrr'�s�z%wirepeer.getbundle.<locals>.<genexpr>�UN)r�)r
�byteskwargsrxr�get�setr.r�GETBUNDLE_ARGUMENTSrrXr�r-�sortedr��KeyError�_callcompressabler_�anyr�getunbundlerr��changegroupmod�cg1unpacker)	r�source�kwargsr�
bundlecapsr��value�keytyperrrr�	getbundle�s6
�
zwirepeer.getbundlec	Cs�|dgkr|�d�rt�dt�d�t|�����g�}nt�|�}t�	|d�rf|j
d||d�\}}|dkr=t�t
d�|��zt|�}WntyRt�t
d	�|��w|�d
�D]}|j�t
d�|�qX|S|jd||d�}t�|j|�}|S)a�Send cg (a readable file-like object representing the
        changegroup to push, typically a chunkbuffer object) to the
        remote server as a bundle.

        When pushing a bundle10 stream, return an integer indicating the
        result of the push (see changegroup.apply()).

        When pushing a bundle20 stream, return a bundle20 stream.

        `url` is the url the client thinks it's pushing to, which is
        visible to hooks.
        sforcesunbundlehashshashed�sdeltaheadersunbundle)r�spush failed:r�Tr�)r�rr�r�sha1r-r��digestr�safehasattr�	_callpushrrrrr~r�r�r�r��_calltwowaystreamrr�)r�bundler��url�retr�r��streamrrr�unbundle�s,�
���zwirepeer.unbundlec	Cs\t�|�}|jd|d�}zdd�|��D�}|WSty-|�t�td�|��YdSw)Nsbranches)r�cSsg|]	}tt�|���qSr)�tuplerr�r�rrrr�sz%wirepeer.branches.<locals>.<listcomp>r�)	rr�ryr�r�rrrrr)rr��nr��brrrr�branches�s
�zwirepeer.branchesc
Cs�d}g}t�dt|�|�D];}d�dd�||||�D��}|jd|d�}z|�dd	�|��D��Wq
tyH|�t	�
td
�|��Yq
w|S)N�rr|cSsg|]}t�|d��qS)�-r�)r#�prrrr�
s
��z$wirepeer.between.<locals>.<listcomp>sbetween)�pairscss"�|]}|rt�|�pgVqdSr")rr�)r#r�rrrr's
��
�z#wirepeer.between.<locals>.<genexpr>r�)r
�xranger]r-ry�extendr�r�rrrrr)rr��batch�r�ir�r�rrr�betweens"��
��zwirepeer.betweencCs$t�|�}|jd|d�}t�|d�S)Nschangegroup)�rootsr�)rr�r�r�r�)rr�r�r�rrrrr	s
zwirepeer.changegroupcCs@|�dtd��t�|�}t�|�}|jd||d�}t�|d�S)Nschangegroupsubsetr�)�basesr�r�)rxrrr�r�r�r�)rr�r�r�rrrr�changegroupsubset!s

�zwirepeer.changegroupsubsetccs�|j}|jr&|�dd�r&|�d�|D]\}}d}|�||t|�f�qtj}|jdt|�d�}|�	d�}|g}	|rwd|vrR|rR|�	d�}|	�
|�d|vrR|sBd	�|	�}
d|
vrl|
�dd
�\}}
||�Vd|
vs[|�	d�}|
|g}	|s<|d	�|	��VdS)zqrun batch request <req> on the server

        Returns an iterator of the raw responses from the server.
        sdevelsdebug.peer-requests$devel-peer-request: batched-content
s+devel-peer-request:    - %s (%d arguments)
sbatch)r1ir*r�rN)
r��	debugflag�
configboolr�r]r�unescapebatchargr�r4�readr/r-r})rr0r�r2r�msg�unescapearg�rsp�chunk�work�merged�onerrrrf,s2�



�

�
�
zwirepeer._submitbatchcCs|j|fit�|���Sr")ryr
r_)rr2rrrrrIszwirepeer._submitoneNcCs:i}|dur
||d<|dur||d<|jd||d�|��S)N�three�four�
debugwireargs)r��two)r�)ry)rr�r�r�r��fiverrrr�
debugwireargsLszwirepeer.debugwireargscK�t��)z�execute <cmd> on the server

        The command is expected to return a simple string.

        returns the server reply as a string.��NotImplementedError�rrrrrrryUszwirepeer._callcKr�)aexecute <cmd> on the server

        The command is expected to return a stream. Note that if the
        command doesn't return a stream, _callstream behaves
        differently for ssh and http peers.

        returns the server reply as a file like object.
        r�r�rrrr�]�	zwirepeer._callstreamcKr�)aEexecute <cmd> on the server

        The command is expected to return a stream.

        The stream may have been compressed in some implementations. This
        function takes care of the decompression. This is the only difference
        with _callstream.

        returns the server reply as a file like object.
        r�r�rrrr�hszwirepeer._callcompressablecKr�)z�execute a <cmd> on server

        The command is expected to be related to a push. Push has a special
        return method.

        returns the server reply as a (ret, output) tuple. ret is either
        empty (error) or a stringified int.
        r��rr�fprrrrr�ur�zwirepeer._callpushcKr�)zqexecute <cmd> on server

        The command will send a stream to the server and get a stream in reply.
        r�r�rrrr��szwirepeer._calltwowaystreamcCr�)zBclearly abort the wire protocol connection and raise the exceptionr�)r�	exceptionrrrr�szwirepeer._abort)NNN)rr=r>r?rwrzr!r�r�r�r�r�rr�r�r�r�r�r	r�rfrr�ryr�r�r�r�rrrrrrvDs@

	
	


-	
	
rv)(�
__future__rrbrE�i18nr�noderr
rr�rr	r�r
rrr�rr�
interfacesr�
interfaceutil�utilsrr�r!r4r7r8r5�implementer�ipeercommandexecutor�objectr@�
ipeercommands�ipeerlegacycommandsrJrvrrrr�<module>s((
!
T�

https://t.me/RX1948 - 2025