
    q&fX	                     T    d dl mZmZ ej                  Z G d d      Z G d d      Zy)    )hgsshpeerc                       e Zd Zd Zd Zd Zy)connectionpoolc                 0    || _         t               | _        y N)_repodict_pool)selfrepos     D/usr/lib/python3/dist-packages/hgext/remotefilelog/connectionpool.py__init__zconnectionpool.__init__   s    
V
    c                 
   | j                   j                  |      }|t               }|| j                   |<   d }t        |      dkD  rI	 |j	                         }|j
                  }t        |t              r|j                  j                         d }|at        j
                  | j                  j                  i |      }t        |d      r G fdd|j                        |_        t!        ||      }|S # t        $ r Y pw xY w)Nr   _cleanupc                   $     e Zd Zd fd	Z xZS )"connectionpool.get.<locals>.mypeerc                 l    t        | d      r| j                  j                          t        |          S )Npipee)hasattrr   closesuperr   )r   warn	__class__mypeers     r   r   z+connectionpool.get.<locals>.mypeer._cleanup.   s/     #41 JJ,,.$VT;==r   r   )__name__
__module____qualname__r   __classcell__)r   r   s   @r   r   r   -   s    > >r   r   )r   getlistlenpoppeer
isinstance
_sshv1peer_subprocesspoll
IndexErrorr   r	   uir   r   
connection)r   pathpathpoolconnr%   r   s        @r   r!   zconnectionpool.get   s    ::>>$'vH'DJJtx=1||~yydJ/'',,.:# <774::=="d3DtZ(>T^^ > "(h-D+  s   	AC6 6	DDc                 z    | j                   j                         D ]  }|D ]  }|j                           |d d =   y r   )r   valuesr   )r   r.   r/   s      r   r   zconnectionpool.close<   s=    

))+ 	H  

	r   N)r   r   r   r   r!   r    r   r   r   r      s    $Lr   r   c                   $    e Zd Zd Zd Zd Zd Zy)r,   c                      || _         || _        y r   )r   r%   )r   poolr%   s      r   r   zconnection.__init__D   s    
	r   c                     | S r   r2   r   s    r   	__enter__zconnection.__enter__H   s    r   c                 `    || j                   j                  |        y | j                          y r   )r   appendr   )r   typevalue	tracebacks       r   __exit__zconnection.__exit__K   s$     <JJd#JJLr   c                 f    t        | j                  d      r| j                  j                          y y )Ncleanup)r   r%   r@   r7   s    r   r   zconnection.closeT   s%    499i(II )r   N)r   r   r   r   r8   r>   r   r2   r   r   r,   r,   C   s     r   r,   N)	mercurialr   r   	sshv1peerr'   r   r,   r2   r   r   <module>rC      s,   
 
/ /d   r   