
    	^c3                     f   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZ dZd	Zd
ZdZeefZedd dddd diZ G d d          Z G d d          Z G d d          Z G d d          Z G d d          Z G d d          Zd4dZd4dZd Zd  Zd!d"d!d"d"d#d$d"d"d"d$d$d%Z  G d& d'ej!                  Z" G d( d)          Z# G d* d+e$          Z%d, Z&ej'         G d- d.                      Z(ej'         G d/ d0                      Z)ej'         G d1 d2                      Z*d3S )5   )binhex)_)getattr)attr)errorutil)r	   )compressions   ssh-v1s   exp-narrow-1s   exp-ellipses-1s   exp-ellipses-2s   ssh)s	   transports   versions   http-v1s   httpc                       e Zd ZdZd ZdS )bytesresponsez1A wire protocol response consisting of raw bytes.c                     || _         d S N)data)selfr   s     :/usr/lib/python3/dist-packages/mercurial/wireprototypes.py__init__zbytesresponse.__init__-   s    			    N__name__
__module____qualname____doc__r    r   r   r   r   *   s)        ;;    r   r   c                       e Zd ZdZd ZdS )ooberrorzwireproto reply: failure of a batch of operation

    Something failed during a batch call. The error message is stored in
    `self.message`.
    c                     || _         d S r   )message)r   r   s     r   r   zooberror.__init__8   s    r   Nr   r   r   r   r   r   1   s-             r   r   c                       e Zd ZdZd ZdS )pushreszwireproto reply: success with simple integer return

    The call was successful and returned an integer contained in `self.res`.
    c                 "    || _         || _        d S r   resoutputr   r"   r#   s      r   r   zpushres.__init__B       r   Nr   r   r   r   r   r   <   -         
    r   r   c                       e Zd ZdZd ZdS )pusherrzhwireproto reply: failure

    The call failed. The `self.res` attribute contains the error message.
    c                 "    || _         || _        d S r   r!   r$   s      r   r   zpusherr.__init__M   r%   r   Nr   r   r   r   r(   r(   G   r&   r   r(   c                       e Zd ZdZddZdS )	streamresaE  wireproto reply: binary stream

    The call was successful and the result is a stream.

    Accepts a generator containing chunks of data to be sent to the client.

    ``prefer_uncompressed`` indicates that the data is expected to be
    uncompressable and that the stream should therefore use the ``none``
    engine.
    NFc                 "    || _         || _        d S r   )genprefer_uncompressed)r   r-   r.   s      r   r   zstreamres.__init__^   s    #6   r   )NFr   r   r   r   r+   r+   R   s2        	 	7 7 7 7 7 7r   r+   c                       e Zd ZdZddZdS )streamreslegacya:  wireproto reply: uncompressed binary stream

    The call was successful and the result is a stream.

    Accepts a generator containing chunks of data to be sent to the client.

    Like ``streamres``, but sends an uncompressed data for "version 1" clients
    using the application/mercurial-0.1 media type.
    Nc                     || _         d S r   )r-   )r   r-   s     r   r   zstreamreslegacy.__init__n   s    r   r   r   r   r   r   r0   r0   c   s2              r   r0       c                 H    | rd |                      |          D             S g S )Nc                 ,    g | ]}t          |          S r   )r   ).0vs     r   
<listcomp>zdecodelist.<locals>.<listcomp>u   s    ---1A---r   )splitlseps     r   
decodelistr<   s   s-     .------Ir   c                 r    	 |                     t          t          |                     S # t          $ r  w xY wr   )joinmapr   	TypeErrorr9   s     r   
encodelistrA   y   s?    xxC$$$   s   '* 6c                     |                      dd                               dd                               dd                               dd          S )	N   :   :c   ,   :o   ;   :s   =   :ereplace)plains    r   escapebatchargrN      sE    dE""	u			u			u			r   c                     |                      dd                               dd                               dd                               dd          S )	NrJ   rI   rH   rG   rF   rE   rD   rC   rK   )escapeds    r   unescapebatchargrQ      sE    t$$										r   s   nodess   booleans   scsvs   csv)s   headss	   bookmarkss   commons
   obsmarkerss   phasess
   bundlecapss   listkeyss   cgs   cbattempteds   streams   includepatss   excludepatsc                   \    e Zd ZdZ ej        d          Zd Zd Zd Z	d Z
d Zd Zd	 Zd
S )baseprotocolhandleraF  Abstract base class for wire protocol handlers.

    A wire protocol handler serves as an interface between protocol command
    handlers and the wire protocol transport layer. Protocol handlers provide
    methods to read command arguments, redirect stdio for the duration of
    the request, handle response types, etc.
    zlThe name of the protocol implementation.

        Used for uniquely identifying the transport type.
        c                     dS )zreturn the value for arguments in <args>

        For version 1 transports, returns a list of values in the same
        order they appear in ``args``. For version 2 transports, returns
        a dict mapping argument name to value.
        Nr   )argss    r   getargszbaseprotocolhandler.getargs         r   c                      dS )zReturns the list of protocol-level capabilities of client

        Returns a list of capabilities as declared by the client for
        the current request (or connection for stateful protocol handlers).Nr   r   r   r   getprotocapsz baseprotocolhandler.getprotocaps   rW   r   c                      dS )zProvide a generator for the raw payload.

        The caller is responsible for ensuring that the full payload is
        processed.
        Nr   r   r   r   
getpayloadzbaseprotocolhandler.getpayload   rW   r   c                      dS )a  Context manager to possibly redirect stdio.

        The context manager yields a file-object like object that receives
        stdout and stderr output when the context manager is active. Or it
        yields ``None`` if no I/O redirection occurs.

        The intent of this context manager is to capture stdio output
        so it may be sent in the response. Some transports support streaming
        stdio to the client in real time. For these transports, stdio output
        won't be captured.
        Nr   r   r   r   mayberedirectstdioz&baseprotocolhandler.mayberedirectstdio   rW   r   c                      dS )z:Returns a string representation of this client (as bytes).Nr   r   r   r   clientzbaseprotocolhandler.client   rW   r   c                     dS )zAdds advertised capabilities specific to this protocol.

        Receives the list of capabilities collected so far.

        Returns a list of capabilities. The passed in argument can be returned.
        Nr   )repocapss     r   addcapabilitiesz#baseprotocolhandler.addcapabilities   rW   r   c                     dS )a  Validate that the client has permissions to perform a request.

        The argument is the permission required to proceed. If the client
        doesn't have that permission, the exception should raise or abort
        in a protocol specific manner.
        Nr   )perms    r   	checkpermzbaseprotocolhandler.checkperm   rW   r   N)r   r   r   r   interfaceutil	AttributenamerV   rY   r[   r]   r_   rc   rf   r   r   r   rS   rS      s          #="	 D  O O O    I I I      r   rS   c                   6    e Zd ZdZ	 	 	 	 	 d	dZd Zd Zd ZdS )
commandentryz,Represents a declared wire protocol command.r   N   pushc                 v    || _         || _        |pt                      | _        || _        || _        || _        d S r   )funcrU   set
transports
permission
cachekeyfnextracapabilitiesfn)r   rn   rU   rp   rq   rr   rs   s          r   r   zcommandentry.__init__   s>     		$-$$#6   r   c                 V    t          ||t          | j                  | j                  S )a<  Merge this instance with an incoming 2-tuple.

        This is called when a caller using the old 2-tuple API attempts
        to replace an instance. The incoming values are merged with
        data not captured by the 2-tuple and a new instance containing
        the union of the two objects is returned.
        rU   rp   rq   )rk   ro   rp   rq   )r   rn   rU   s      r   _mergezcommandentry._merge	  s3     4?++	
 
 
 	
r   c              #   .   K   | j         V  | j        V  d S r   )rn   rU   )r   s    r   __iter__zcommandentry.__iter__  s       iir   c                 T    |dk    r| j         S |dk    r| j        S t          d          )N    r   s    can only access elements 0 and 1)rn   rU   
IndexError)r   is     r   __getitem__zcommandentry.__getitem__  s3    669!VV9@AAAr   )r   Nrl   NN)r   r   r   r   r   rv   rx   r}   r   r   r   rk   rk      sq        66
  7 7 7 7 
 
 
   B B B B Br   rk   c                   (     e Zd ZdZ fdZd Z xZS )commanddictzContainer for registered wire protocol commands.

    It behaves like a dict. But __setitem__ is overwritten to allow silent
    coercion of values from 2-tuples for API compatibility.
    c                    t          |t                    rnt          |t                    rt          |          dk    rt	          d          || v r)| |                             |d         |d                   }nAt          |d         |d         t          t                    d          }nt	          d          t          t          |           
                    ||          S )N   s+   command tuples must have exactly 2 elementsrz   r   rl   ru   s:   command entries must be commandentry instances or 2-tuples)
isinstancerk   tuplelen
ValueErrorrv   ro   
TRANSPORTSsuperr   __setitem__)r   kr6   	__class__s      r   r   zcommanddict.__setitem__-  s    a&& 	5!! 	1vv{{ !OPPP DyyGNN1Q41.. !aD1":&	     
 [$''33Aq999r   c                 x    |j         t          v sJ |                     |          }|sdS |j         |j        vrdS dS )z?Determine if a command is available for the requested protocol.FT)ri   r   getrp   )r   commandprotoentrys       r   commandavailablezcommanddict.commandavailableK  sM    zZ''''!! 	5:U---5tr   )r   r   r   r   r   r   __classcell__)r   s   @r   r   r   &  sQ         : : : : :<      r   r   c           	         |t           j        t           j        fv sJ t           j                            |          }|t           j        k    r|                     dd          d}n|                     dd          d}s"|t          j        k    rdndfd	|D             S d
 |D             fdD             }|rFt          j        t          d          |d
                    t          |                    fz            fd|D             }t          |fd          }|sIt          j        t          d          |z  t          d          d                              z            |S )z?Obtain the list of supported compression engines for a request.s   servers   compressionenginess   server.compressionenginess   experimentals   clientcompressionenginess%   experimental.clientcompressionenginess   serverprioritys   clientpriorityc                 `    g | ]*}t          |                                          d k    (|+S )rz   )r   wireprotosupport)r5   er   s     r   r7   z(supportedcompengines.<locals>.<listcomp>u  s@     
 
 
ga.@.@.B.BD&I&IA&M&MA&M&M&Mr   c                 6    h | ]}|                                 S r   ri   )r5   r   s     r   	<setcomp>z'supportedcompengines.<locals>.<setcomp>}  s     000q!&&((000r   c                     h | ]}|v|	S r   r   )r5   r   
validnamess     r   r   z'supportedcompengines.<locals>.<setcomp>~  s#    DDD!0C0CA0C0C0Cr   s,   invalid compression engine defined in %s: %ss   , c                 @    g | ]}|                                 v |S r   r   )r5   r   configenginess     r   r7   z(supportedcompengines.<locals>.<listcomp>  s+    GGGQVVXX-F-F1-F-F-Fr   c                 R                         |                                           S r   )indexri   )r   r   s    r   <lambda>z&supportedcompengines.<locals>.<lambda>  s    =#6#6qvvxx#@#@ r   )keys?   %s config option does not specify any known compression enginess   usable compression engines: %s)hint)r
   
CLIENTROLE
SERVERROLEcompenginessupportedwireengines
configlistr	   r   Abortr   r>   sorted)uiroler   configinvalidnamesr   r   r   s        @@@r   supportedcompenginesr   Z  s   K*K,BCCCCC)>>tDDK {%%%i1FGG- 8
 
 :  
!%!8!8>O 	
 
 
 
"
 
 
 	
 10K000JDDDD}DDDL 
k=>>uzz&"6"67789
 
 	

 HGGGkGGGK@@@@  K  	
k'  	
 455ll:&&'
 
 
 	
 r   c                   0    e Zd ZdZ ej                    ZdS )encodedresponsea7  Represents response data that is already content encoded.

    Wire protocol version 2 only.

    Commands typically emit Python objects that are encoded and sent over the
    wire. If commands emit an object of this type, the encoding step is bypassed
    and the content from this object is used instead.
    N)r   r   r   r   r   ibr   r   r   r   r   r     s'          4799DDDr   r   c                       e Zd ZdZ ej                    Z ej                    Z ej        d          Z ej        d          Z	 ej        d          Z
 ej        d          Z ej        d          ZdS )alternatelocationresponsezRepresents a response available at an alternate location.

    Instances are sent in place of actual response objects when the server
    is sending a "content redirect" response.

    Only compatible with wire protocol version 2.
    N)default)r   r   r   r   r   r   url	mediatypesize
fullhashesfullhashseedserverdercertsservercadercertsr   r   r   r   r     s          $'))C		I474   D&&&J474(((LTWT***Ntwt,,,r   r   c                   0    e Zd ZdZ ej                    ZdS )indefinitebytestringresponsezRepresents an object to be encoded to an indefinite length bytestring.

    Instances are initialized from an iterable of chunks, with each chunk being
    a bytes instance.
    N)r   r   r   r   r   r   chunksr   r   r   r   r     s'          TWYYFFFr   r   N)r2   )+noder   r   i18nr   pycompatr   
thirdpartyr    r   r	   
interfacesrg   utilsr
   SSHV1	NARROWCAPELLIPSESCAP1ELLIPSESCAPSUPPORTED_ELLIPSESCAPr   r   r   r   r(   r+   r0   r<   rA   rN   rQ   GETBUNDLE_ARGUMENTS	InterfacerS   rk   dictr   r   sr   r   r   r   r   r   <module>r      s                                   . - - - - -       		 %{3  
   	
                            7 7 7 7 7 7 7 7"                  *    C C C C C-1 C C CL-B -B -B -B -B -B -B -B`1 1 1 1 1$ 1 1 1h; ; ;| 
 
 
 
 
 
 
 
 - - - - - - - -$          r   