
    6h:                        S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	J
r
  SSKJrJrJr  \R                  r\R                   r " S S	\R                  5      rg
)z4remote largefile store; the base class for wirestore    )annotations)_)errorutil)
stringutilurlutil   )	basestorelfutil
localstorec                  b   ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	 rS
 rS rS rSrU =r$ )remotestore!   z)a largefile store accessed over a networkc                   > [         TU ]  XU5        S U l        Ub<  [        R                  " U R                  U R
                  U R
                  5      U l        g g N)super__init___lstorer   uirepo)selfr   r   url	__class__s       >/usr/lib/python3/dist-packages/hgext/largefiles/remotestore.pyr   remotestore.__init__$   sF    3'%00$))TYYODL     c                B   U R                  X5      (       aB  [        R                  " [        S5      U[        R
                  " U R                  5      4-  5      eU R                  R                  [        S5      U[        R
                  " U R                  5      4-  5        g )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   putremotestore.put*   s~    ==&&++EF7//9:;  	9:w++DHH567	
r   c                |    U R                  U5      R                  5        VVs0 s H
  u  p#X#S:H  _M     snn$ s  snnf )Nr   )_statitems)r   hasheshss       r   existsremotestore.exists5   sC     **V,224
4 AvI4
 	
 
s   8c                p   U R                   R                  SX4-  5         [        R                  " U R                   U5       nU R	                  X#5      sS S S 5        $ ! , (       d  f       g = f! [
         a=  n[        R                  " [        S5      U[        R                  " U5      4-  5      eS nAff = f)Ns   remotestore: sendfile(%s, %s)
s'   remotestore: could not open file %s: %s)r   r!   r   httpsendfile_putOSErrorr   r   r   r   forcebytestr)r   filenamer#   fdes        r   r   remotestore.sendfile<   s    8H;KKL	$$TWWh72yy* 877 	++<=Z44Q789 	s5   !A. A	A. 
A+'A. +A. .
B588B00B5c           	     0    U R                  U5      n[        R                   " XA5      $ ! [        R                   a;  n[        R                  " X#U R
                  [        R                  " U5      5      eS nAf[        R                   aH  n[        R                  " S[        R                  " U R
                  5      UR                  4-  5      eS nAf[         a;  n[        R                  " X#U R
                  [        R                  " U5      5      eS nAff = f)Ns   %s: %s)_geturlerr	httperrorr
   
StoreErrorr   r   r2   urlerrorr   r   r   r    reasonr1   r   copyandhash)r   tmpfiler3   r#   chunksr5   s         r   _getfileremotestore._getfileG   s    	YYt_F& !!&22%  	 &&**A*A!*D   	 ++W11$((;QXXFF   	&&**A*A!*D 	s-   ) D6A33D
ACD6DDc                    U R                   R                  U5      nU Vs/ s H  o2U   (       d  M  UPM     nnU$ s  snf r   )r   r,   )r   r)   existslocallymapr#   localhashess        r   _hashesavailablelocally#remotestore._hashesavailablelocally^   s<    <<..v6(.I42HtI Js   ;;c                <   SnU VVVs/ s H  u  pEofPM	     nnnnU R                  U5      nU R                  U Vs/ s H  nXh;  d  M
  UPM     sn5      n	U H  u  pEnXh;   a-  XEU4n
U R                  R                  X/5      nU(       a  SnM6  M8  X   nU(       d  ME  US:X  a,  U R                  R                  [        S5      XE4-  5        SnMw  US:X  a,  U R                  R                  [        S5      XE4-  5        SnM  [        SU-  5      e   U$ s  snnnf s  snf )NFTr	   s"   changeset %s: %s: contents differ
   s   changeset %s: %s missing
s6   verify failed: unexpected response from statlfile (%r))rF   r'   r   _verifyfilesr   warnr   RuntimeError)r   contentsfilestocheckfailedcsetr3   expectedhashexpectedhashesrE   statsfiletocheckverifyresultstats                r   rJ   remotestore._verifyfilesc   sP   =I
=I9T\L\ 	 
 22>B

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

s   D	DDc                    [        S5      e)z1Put file with the given hash in the remote store.   abstract methodNotImplementedError)r   r#   r4   s      r   r0   remotestore._put       !"455r   c                    [        S5      e)z/Get a iterator for content with the given hash.rY   rZ   )r   r#   s     r   r8   remotestore._get   r]   r   c                    [        S5      e)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.rY   rZ   )r   r)   s     r   r'   remotestore._stat   s    
 ""455r   )r   )__name__
__module____qualname____firstlineno____doc__r   r$   r,   r   rA   rF   rJ   r0   r8   r'   __static_attributes____classcell__)r   s   @r   r   r   !   s?    3P	

	3.
)V666 6r   r   N)rf   
__future__r   mercurial.i18nr   	mercurialr   r   mercurial.utilsr   r    r
   r   r   r9   urlreqr    r   r   <module>rp      sL    ; " 

  
	z6)%% z6r   