§
    	^µcÔ  ã                   ó|   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
  G d„ d	e¦  «        Z G d
„ d¦  «        ZdS )zCbase class for store implementations and store-related utility codeé    )Ú_)Úshort)Úutil)Úurlutilé   )Úlfutilc                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )Ú
StoreErrorzZRaised when there is a problem getting files from or putting
    files to a central store.c                 ó>   — || _         || _        || _        || _        d S ©N)ÚfilenameÚhashÚurlÚdetail)Úselfr   r   r   r   s        ú</usr/lib/python3/dist-packages/hgext/largefiles/basestore.pyÚ__init__zStoreError.__init__   s"   € Ø ˆŒØˆŒ	ØˆŒØˆŒˆˆó    c                 óz   — t          d¦  «        | j        t          j        | j        ¦  «        | j        | j        fz  S )Ns0   error getting id %s from url %s for file %s: %s
)r   r   r   Úhidepasswordr   r   r   ©r   s    r   ÚlongmessagezStoreError.longmessage    s=   € ÝÐEÑFÔFØŒIÝÔ  ¤Ñ*Ô*ØŒMØŒKð	J
ñ 
ð 	
r   c                 óH   — dt          j        | j        ¦  «        | j        fz  S )Ns   %s: %s)r   r   r   r   r   s    r   Ú__str__zStoreError.__str__(   s!   € Ø�GÔ0°´Ñ:Ô:¸D¼KÐHÑHÐHr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   © r   r   r
   r
      sP   € € € € € ð!ð !ðð ð ð
ð 
ð 
ðIð Ið Ið Ið Ir   r
   c                   ó@   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Z	d	„ Z
d
S )Ú	basestorec                 ó0   — || _         || _        || _        d S r   )ÚuiÚrepor   )r   r#   r$   r   s       r   r   zbasestore.__init__-   s   € ØˆŒØˆŒ	ØˆŒˆˆr   c                 ó    — t          d¦  «        ‚)z>Put source file into the store so it can be retrieved by hash.ó   abstract method©ÚNotImplementedError)r   Úsourcer   s      r   Úputzbasestore.put2   s   € å!Ð"4Ñ5Ô5Ð5r   c                 ó    — t          d¦  «        ‚)z€Check to see if the store contains the given hashes. Given an
        iterable of hashes it returns a mapping from hash to bool.r&   r'   )r   Úhashess     r   Úexistszbasestore.exists6   s   € õ "Ð"4Ñ5Ô5Ð5r   c           
      óþ  — g }g }| j         }d}|                      d„ |D ¦   «         ¦  «        }|                     t          d¦  «        t          d¦  «        t	          |¦  «        ¬¦  «        5 }|D ]ó\  }}	|                     |¦  «         |dz  }|                     t          d¦  «        ||	fz  ¦  «         |                     |	¦  «        sU|                     t          d¦  «        ||	t          j
        | j        ¦  «        fz  ¦  «         |                     |¦  «         Œ°|                      ||	¦  «        r|                     ||	f¦  «         ŒÞ|                     |¦  «         Œô	 d	d	d	¦  «         n# 1 swxY w Y   ||fS )
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   c                 ó   — h | ]\  }}|’ŒS r   r   )Ú.0Ú	_filenamer   s      r   ú	<setcomp>z basestore.get.<locals>.<setcomp>I   s   € Ð EÐ EÐ EÑ*;¨9°d Ð EÐ EÐ Er   s   getting largefiless   files)ÚunitÚtotalr   s   getting %s:%s
s'   %s: largefile %s not available from %s
N)r#   r-   Úmakeprogressr   ÚlenÚupdateÚnoteÚgetÚwarnr   r   r   ÚappendÚ_gethash)
r   ÚfilesÚsuccessÚmissingr#   ÚatÚ	availableÚprogressr   r   s
             r   r9   zbasestore.get;   sÖ  € ð ˆØˆØŒWˆàˆØ—K’KÐ EÐ E¸uÐ EÑ EÔ EÑFÔFˆ	Ø�_Š_ÝÐ#Ñ$Ô$­1¨X©;¬;½cÀ%¹j¼jð ñ 
ô 
ð 	-àØ"'ð -ð -‘�˜$Ø—’ Ñ#Ô#Ð#Ø�a‘�Ø—’�Ð,Ñ-Ô-°¸4Ð0@Ñ@ÑAÔAÐAà —}’} TÑ*Ô*ð Ø—G’GÝÐEÑFÔFØ# T­7Ô+?ÀÄÑ+IÔ+IÐJñKñô ð ð —N’N 8Ñ,Ô,Ð,Øà—=’= ¨4Ñ0Ô0ð -Ø—N’N H¨dÐ#3Ñ4Ô4Ð4Ð4à—N’N 8Ñ,Ô,Ð,Ð,ð!-ð	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-ð* ˜Ð!Ð!s   Á,C7E0Å0E4Å7E4c                 óÎ  — t          j        t          j        | j        d¦  «        ¦  «         t          j        | j        |¦  «        }|dz   }t          j        || j        j        j        ¬¦  «        5 }	 |                      |||¦  «        }nE# t          $ r8}| j
                             |                     ¦   «         ¦  «         d}Y d}~nd}~ww xY wddd¦  «         n# 1 swxY w Y   ||k    rI|dk    r-| j
                             t          d¦  «        |||fz  ¦  «         t          j        |¦  «         dS t          j        ||¦  «         t          j        | j        |¦  «         dS )z¢Get 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ÚstorerD   Ú_getfiler
   r#   r:   r   r   ÚunlinkÚrenameÚlinktousercache)r   r   r   ÚstorefilenameÚtmpnameÚtmpfileÚgothashÚerrs           r   r<   zbasestore._gethasha   sª  € õ
 	Œ•fÔ& t¤y°#Ñ6Ô6Ñ7Ô7Ð7ÝÔ(¨¬°DÑ9Ô9ˆà 'Ñ)ˆÝÔ Ø ¤	¤Ô :ð
ñ 
ô 
ð 	àðØŸ-š-¨°¸4Ñ@Ô@��øÝð ð ð Ø”—’˜SŸ_š_Ñ.Ô.Ñ/Ô/Ð/Ø������øøøøðøøøð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð �dŠ?ˆ?Ø˜#Š~ˆ~Ø”—’ÝÐDÑEÔEØ  wÐ/ñ0ñô ð õ ŒK˜Ñ Ô Ð Ø�5åŒ�G˜]Ñ+Ô+Ð+ÝÔ˜tœy¨$Ñ/Ô/Ð/Øˆts<   Á1CÁ3BÂ
CÂ
CÂ.CÃCÃCÃCÃC Ã#C Fc                 óp  — | j                              t          d¦  «        t          |¦  «        z  ¦  «         t	          ¦   «         }g }|D ]Å}| j        |         }d|                     ¦   «         t          |                     ¦   «         ¦  «        fz  }|D ]{}t          j
        |¦  «        }	|	rc||         }
|	|
                     ¦   «         f}||vrA|                     |¦  «         t          j        |
¦  «        }|                     ||	|f¦  «         Œ|ŒÆ|                      ||¦  «        }t          |¦  «        }t          d„ |D ¦   «         ¦  «        }|r-| j                              t          d¦  «        ||fz  ¦  «         n,| j                              t          d¦  «        ||fz  ¦  «         t!          |¦  «        S )z³Verify 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:%sc                 ó   — h | ]\  }}|’ŒS r   r   )r0   ÚfnameÚfnodes      r   r2   z#basestore.verify.<locals>.<setcomp>›   s   € Ð>Ð>Ð>¡> E¨5˜Ð>Ð>Ð>r   s3   verified contents of %d revisions of %d largefiles
s4   verified existence of %d revisions of %d largefiles
)r#   Ústatusr   r6   Úsetr$   Úrevr   Únoder   ÚsplitstandinÚfilenodeÚaddÚreadasstandinr;   Ú_verifyfilesÚint)r   ÚrevsÚcontentsÚverifiedÚfilestocheckrX   ÚcctxÚcsetÚstandinr   ÚfctxÚkeyÚexpectedhashÚfailedÚnumrevsÚ	numlfiless                   r   Úverifyzbasestore.verify€   s×  € ð
 	Œ�ŠÝÐ9Ñ:Ô:½SÀ¹Y¼YÑFñ	
ô 	
ð 	
õ ‘5”5ˆØˆØð 	Lð 	LˆCØ”9˜S”>ˆDØ˜tŸxšx™zœz­5°·²±´Ñ+=Ô+=Ð>Ñ>ˆDàð Lð L�Ý!Ô.¨wÑ7Ô7�Øð LØ œ=�DØ# T§]¢]¡_¤_Ð5�CØ (Ð*Ð*Ø Ÿš SÑ)Ô)Ð)Ý'-Ô';¸DÑ'AÔ'A˜Ø$×+Ò+¨T°8¸\Ð,JÑKÔKÐKøðLð ×"Ò" 8¨\Ñ:Ô:ˆå�h‘-”-ˆÝÐ>Ð>°XÐ>Ñ>Ô>Ñ?Ô?ˆ	Øð 		ØŒG�NŠNÝÐIÑJÔJØ˜IÐ&ñ'ñô ð ð ð
 ŒG�NŠNÝÐJÑKÔKØ˜IÐ&ñ'ñô ð õ �6‰{Œ{Ðr   c                 ó    — t          d¦  «        ‚)a  Fetch 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&   r'   )r   rO   r   r   s       r   rI   zbasestore._getfile¨   ó   € õ "Ð"4Ñ5Ô5Ð5r   c                 ó    — t          d¦  «        ‚)zÝPerform 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&   r'   )r   ra   rc   s      r   r^   zbasestore._verifyfiles°   ro   r   N)F)r   r   r   r   r*   r-   r9   r<   rm   rI   r^   r   r   r   r!   r!   ,   s“   € € € € € ðð ð ð
6ð 6ð 6ð6ð 6ð 6ð
$"ð $"ð $"ðLð ð ð>&ð &ð &ð &ðP6ð 6ð 6ð6ð 6ð 6ð 6ð 6r   r!   N)r   Úmercurial.i18nr   Úmercurial.noder   Ú	mercurialr   Úmercurial.utilsr   Ú r   Ú	Exceptionr
   r!   r   r   r   ú<module>rw      sä   ðð JÐ Ià Ð Ð Ð Ð Ð à  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð Ð Ð Ð Ð Ð ðIð Ið Ið Ið I�ñ Iô Ið Ið,J6ð J6ð J6ð J6ð J6ñ J6ô J6ð J6ð J6ð J6r   