
    6h                    z    S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr   " S	 S
\5      r " S S5      rg)zCbase class for store implementations and store-related utility code    )annotations)_)short)util)urlutil   )lfutilc                  *    \ rS rSrSrS rS rS rSrg)
StoreError   zVRaised when there is a problem getting files from or putting
files to a central store.c                4    Xl         X l        X0l        X@l        g N)filenamehashurldetail)selfr   r   r   r   s        </usr/lib/python3/dist-packages/hgext/largefiles/basestore.py__init__StoreError.__init__   s     	    c                    [        S5      U R                  [        R                  " U R                  5      U R
                  U R                  4-  $ )Ns0   error getting id %s from url %s for file %s: %s
)r   r   r   hidepasswordr   r   r   r   s    r   longmessageStoreError.longmessage"   sB    EFII  *MMKK	J
 
 	
r   c                `    S[         R                  " U R                  5      U R                  4-  $ )Ns   %s: %s)r   r   r   r   r   s    r   __str__StoreError.__str__*   s%    G00:DKKHHHr   )r   r   r   r   N)	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__ r   r   r   r      s    !
Ir   r   c                  H    \ rS rSrS rS rS rS rS rSS jr	S r
S	 rS
rg)	basestore.   c                (    Xl         X l        X0l        g r   )uirepor   )r   r+   r,   r   s       r   r   basestore.__init__/   s    	r   c                    [        S5      e)z>Put source file into the store so it can be retrieved by hash.   abstract methodNotImplementedError)r   sourcer   s      r   putbasestore.put4   s    !"455r   c                    [        S5      e)zxCheck to see if the store contains the given hashes. Given an
iterable of hashes it returns a mapping from hash to bool.r/   r0   )r   hashess     r   existsbasestore.exists8   s     ""455r   c           
        / n/ nU R                   nSnU R                  U VVs1 s H  u  pgUiM	     snn5      nUR                  [        S5      [        S5      [	        U5      S9 n	U H  u  pU	R                  U5        US-  nUR                  [        S5      X4-  5        UR                  U5      (       dP  UR                  [        S5      X[        R                  " U R                  5      4-  5        UR                  U
5        M  U R                  X5      (       a  UR                  X45        M  UR                  U
5        M     SSS5        X#4$ s  snnf ! , (       d  f       X#4$ = f)	a  Get the specified largefiles from the store and write to local
files under repo.root.  files is a list of (filename, hash)
tuples.  Return (success, missing), lists of files successfully
downloaded and those not found in the store.  success is a list
of (filename, hash) tuples; missing is a list of filenames that
we could not get.  (The detailed error message will already have
been presented to the user, so missing is just supplied as a
summary.)r   s   getting largefiless   files)unittotalr   s   getting %s:%s
s'   %s: largefile %s not available from %s
N)r+   r7   makeprogressr   lenupdatenotegetwarnr   r   r   append_gethash)r   filessuccessmissingr+   at	_filenamer   	availableprogressr   s              r   r@   basestore.get=   sH    WWKKu Eu*;9u EF	__#$1X;c%j  
"'#a,-0@@A }}T**GGEF#7+?+?+IJK NN8,==00NNH#34NN8,! #(
* !!- !F
 
* !!s   E
%C!E
E'c                   [         R                  " [        R                  " U R                  S5      5        [        R                  " U R                  U5      nUS-   n[         R
                  " X@R                  R                  R                  S9 n U R                  XQU5      nSSS5        WU:w  aF  US:w  a)  U R                  R                  [        S5      XU4-  5        [         R                  " U5        g[         R                  " XC5        [        R                   " U R                  U5        g! [         a5  nU R                  R                  UR                  5       5        Sn SnANSnAff = f! , (       d  f       N= f)zGet file with the provided hash and store it in the local repo's
store and in the usercache.
filename is for informational messages only.
r   s   .tmp)
createmodeNs*   %s: data corruption (expected %s, got %s)
FT)r   makedirsr	   	storepathr,   atomictempfilestorerM   _getfiler   r+   rA   r   r   unlinkrenamelinktousercache)r   r   r   storefilenametmpnametmpfilegothasherrs           r   rC   basestore._gethashc   s    
 	f&&tyy#67((D9')  		 : :
--4@	
 d?#~DEw/0 KK G+tyy$/  S__./
 
s0   E0D..
E-8+E(#E0(E--E00
E>c                N   U R                   R                  [        S5      [        U5      -  5        [	        5       n/ nU H  nU R
                  U   nSUR                  5       [        UR                  5       5      4-  nU Hx  n[        R                  " U5      n	U	(       d  M"  Xh   n
XR                  5       4nX;  d  M>  UR                  U5        [        R                  " U
5      nUR                  XyU45        Mz     M     U R                  X$5      n[        U5      n[        U VVs1 s H  u  nnUiM
     snn5      nU(       a*  U R                   R                  [        S5      UU4-  5        O)U R                   R                  [        S5      UU4-  5        [!        U5      $ s  snnf )zVerify the existence (and, optionally, contents) of every big
file revision referenced by every changeset in revs.
Return 0 if all is well, non-zero on any errors.s'   searching %d changesets for largefiles
s   %d:%ss3   verified contents of %d revisions of %d largefiles
s4   verified existence of %d revisions of %d largefiles
)r+   statusr   r=   setr,   revr   noder	   splitstandinfilenodeaddreadasstandinrB   _verifyfilesint)r   revscontentsverifiedfilestocheckr_   cctxcsetstandinr   fctxkeyexpectedhashfailednumrevsfnamefnode	numlfiless                     r   verifybasestore.verify   sn   
 	9:SYF	
 5C99S>Dtxxz5+=>>D!..w78=D#]]_5C* S)'-';';D'A$++T\,JK  	  ""8:h-X>X>E5X>?	GGNNIJI&'
 GGNNJKI&' 6{ ?s   %F!
c                    [        S5      e)zFetch one revision of one file from the store and write it
to tmpfile.  Compute the hash of the file on-the-fly as it
downloads and return the hash.  Close tmpfile.  Raise
StoreError if unable to download the file (e.g. it does not
exist in the store).r/   r0   )r   rX   r   r   s       r   rR   basestore._getfile        ""455r   c                    [        S5      e)zPerform the actual verification of files in the store.
'contents' controls verification of content hash.
'filestocheck' is list of files to check.
Returns _true_ if any problems are found!
r/   r0   )r   rh   rj   s      r   re   basestore._verifyfiles   rz   r   )r,   r+   r   N)F)r    r!   r"   r#   r   r3   r7   r@   rC   rv   rR   re   r%   r&   r   r   r(   r(   .   s,    
66
$"L>&P66r   r(   N)r$   
__future__r   mercurial.i18nr   mercurial.noder   	mercurialr   mercurial.utilsr    r	   	Exceptionr   r(   r&   r   r   <module>r      s;    J "     I I,J6 J6r   