
    q&f'                         d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
mZmZ ej                  Zej                  Z G d de
j                        Zy	)
z4remote largefile store; the base class for wirestore    )_)errorutil)
stringutilurlutil   )	basestorelfutil
localstorec                   X     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Z xZS )remotestorez)a largefile store accessed over a networkc                     t         t        |   |||       d | _        |;t	        j                  | j
                  | j                  | j                        | _        y y N)superr   __init___lstorer   uirepo)selfr   r   url	__class__s       >/usr/lib/python3/dist-packages/hgext/largefiles/remotestore.pyr   zremotestore.__init__"   sJ    k4)"dC8%00$))TYYODL     c                 4   | j                  ||      r@t        j                  t        d      |t	        j
                  | j                        fz        | j                  j                  t        d      |t	        j
                  | j                        fz         y )Ns0   remotestore: could not put %s to remote store %ss'   remotestore: put %s to remote store %s
)	sendfiler   Abortr   r   hidepasswordr   r   debug)r   sourcehashs      r   putzremotestore.put(   s}    ==&++EF7//9:;  	9:w++DHH567	
r   c                 z    | j                  |      j                         D ci c]  \  }}||dk(   c}}S c c}}w )Nr   )_statitems)r   hasheshss       r   existszremotestore.exists3   sB     **V,224
A qAvI
 	
 
s   7c                 b   | j                   j                  d||fz         	 t        j                  | j                   |      5 }| j	                  ||      cd d d        S # 1 sw Y   y xY w# t
        $ r;}t        j                  t        d      |t        j                  |      fz        d }~ww xY w)Ns   remotestore: sendfile(%s, %s)
s'   remotestore: could not open file %s: %s)r   r   r
   httpsendfile_putIOErrorr   r   r   r   forcebytestr)r   filenamer    fdes        r   r   zremotestore.sendfile:   s    8Hd;KKL	$$TWWh7 +2yyr*+ + + 	++<=Z44Q789 	s5    A* A	A* A'#A* 'A* *	B.36B))B.c           	      "   	 | j                  |      }t        j                   ||      S # t        j                  $ r:}t        j                  ||| j
                  t        j                  |            d }~wt        j                  $ rF}t        j                  dt        j                  | j
                        |j                  fz        d }~wt        $ r:}t        j                  ||| j
                  t        j                  |            d }~ww xY w)Ns   %s: %s)_geturlerr	httperrorr	   
StoreErrorr   r   r-   urlerrorr   r   r   r   reasonr,   r
   copyandhash)r   tmpfiler.   r    chunksr0   s         r   _getfilezremotestore._getfileE   s    	YYt_F& !!&'22%  	 &&$**A*A!*D   	 ++W11$((;QXXFF   	&&$**A*A!*D 	s-   ) D5A11DACD5D		Dc                 p    | j                   j                  |      }|D cg c]
  }||   s	| }}|S c c}w r   )r   r(   )r   r%   existslocallymapr    localhashess        r   _hashesavailablelocallyz#remotestore._hashesavailablelocally\   s>    <<..v6(.I2B42HtII Js   
33c                    d}|D cg c]  \  }}}|
 }}}}| j                  |      }| j                  |D cg c]  }||vr|
 c}      }	|D ]  \  }}}||v r(|||f}
| j                  j                  ||
g      }|s0d}3|	|   }|s;|dk(  r,| j                  j                  t        d      ||fz         d}l|dk(  r,| j                  j                  t        d      ||fz         d}t        d|z         |S c c}}}w c c}w )NFTr   s"   changeset %s: %s: contents differ
   s   changeset %s: %s missing
s6   verify failed: unexpected response from statlfile (%r))r?   r#   r   _verifyfilesr   warnr   RuntimeError)r   contentsfilestocheckfailedcsetr.   expectedhashexpectedhashesr>   statsfiletocheckverifyresultstats                r   rB   zremotestore._verifyfilesa   s[   =I
 
9T8\L
 
 22>B

 %3 {2 
 -9 	(D(L{*#X|<#||88{m   !F\*qyDE#X./ "&;<h?OO "&*359: /	6 O

s
   C>Dc                     t        d      )z1Put file with the given hash in the remote store.   abstract methodNotImplementedError)r   r    r/   s      r   r+   zremotestore._put       !"455r   c                     t        d      )z/Get a iterator for content with the given hash.rP   rQ   )r   r    s     r   r2   zremotestore._get   rS   r   c                     t        d      )zGet information about availability of files specified by
        hashes in the remote store. Return dictionary mapping hashes
        to return code where 0 means that file is available, other
        values if not.rP   rQ   )r   r%   s     r   r#   zremotestore._stat   s    
 ""455r   )__name__
__module____qualname____doc__r   r!   r(   r   r;   r?   rB   r+   r2   r#   __classcell__)r   s   @r   r   r      s:    3P	

	3.
)V666r   r   N)rY   mercurial.i18nr   	mercurialr   r   mercurial.utilsr   r    r	   r
   r   r3   urlreqr    r   r   <module>ra      sI    ; 

  
	z6)%% z6r   