ó
    ±“,ju  ã                   ó„   • S r SSKJrJrJr  SSKJr  SSKJrJ	r	J
r
  SSKJr  SSKJr  SSKrSSKrSr " S	 S
\\\\5      rg)z/Module containing a database to deal with packsé    )Ú
FileDBBaseÚ	ObjectDBRÚ	CachingDB)Ú	LazyMixin)Ú	BadObjectÚUnsupportedOperationÚAmbiguousObjectName)Ú
PackEntity)ÚreduceN)ÚPackedDBc                   ó|   ^ • \ rS 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S jrS rS rSrU =r$ )r   é    z-A database operating on a set of object packsiô  c                 ó@   >• [         TU ]  U5        SU l        SU l        g ©Nr   )ÚsuperÚ__init__Ú
_hit_countÚ	_st_mtime)ÚselfÚ	root_pathÚ	__class__s     €Ú›C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\gitdb/db/pack.pyr   ÚPackedDB.__init__)   s    ø€ Ü‰Ñ˜Ô#ð ˆŒØˆ�ó    c                 óN   • US:X  a  [        5       U l        U R                  SS9  g g )NÚ	_entitiesT)Úforce)Úlistr   Úupdate_cache)r   Úattrs     r   Ú_set_cache_ÚPackedDB._set_cache_3   s)   € Ø�;ÓÜ!›VˆDŒNØ×Ñ DÐÒ)ð r   c                 ó:   • U R                   R                  S SS9  g )Nc                 ó   • U S   $ r   © )Úls    r   Ú<lambda>Ú)PackedDB._sort_entities.<locals>.<lambda>:   s   € ¨!¨Aª$r   T)ÚkeyÚreverse)r   Úsort)r   s    r   Ú_sort_entitiesÚPackedDB._sort_entities9   s   € Ø�‰×Ñ¡¸ÐÒ=r   c                 ó
  • U R                   U R                  -  S:X  a  U R                  5         U R                   H<  nUS   " U5      nUc  M  US==   S-  ss'   U =R                   S-  sl         US   U4s  $    [	        U5      e)ay  :return: tuple(entity, index) for an item at the given sha
:param sha: 20 or 40 byte sha
:raise BadObject:
**Note:** This method is not thread-safe, but may be hit in multi-threaded
    operation. The worst thing that can happen though is a counter that
    was not incremented, or the list being in wrong order. So we safe
    the time for locking here, lets see how that goesr   é   é   )r   Ú_sort_intervalr,   r   r   )r   ÚshaÚitemÚindexs       r   Ú
_pack_infoÚPackedDB._pack_info<   s€   € ð �?‰?˜T×0Ñ0Ñ0°AÓ5Ø×ÑÔ!ð —N”NˆDØ˜’G˜C“LˆEØÓ Ø�Q“˜1‘“Ø—’ 1Ñ$•Ø˜Q™ Ð'Ò'ñ #ô ˜‹nÐr   c                 óH   •  U R                  U5        g! [         a     gf = f)NTF)r5   r   )r   r2   s     r   Ú
has_objectÚPackedDB.has_objectY   s(   € ð	Ø�O‰O˜CÔ ØøÜó 	Ùð	ús   ‚ ”
! !c                 óJ   • U R                  U5      u  p#UR                  U5      $ ©N)r5   Úinfo_at_index©r   r2   Úentityr4   s       r   ÚinfoÚPackedDB.infoa   s#   € ØŸ™¨Ó,‰ˆØ×#Ñ# EÓ*Ð*r   c                 óJ   • U R                  U5      u  p#UR                  U5      $ r;   )r5   Ústream_at_indexr=   s       r   ÚstreamÚPackedDB.streame   s#   € ØŸ™¨Ó,‰ˆØ×%Ñ% eÓ,Ð,r   c              #   óÆ   #   • U R                  5        HI  nUR                  5       nUR                  n[        UR	                  5       5       H  nU" U5      v •  M     MK     g 7fr;   )Úentitiesr4   r2   ÚrangeÚsize)r   r>   r4   Úsha_by_indexs       r   Úsha_iterÚPackedDB.sha_iteri   sI   é € Ø—m‘m–oˆFØ—L‘L“NˆEØ Ÿ9™9ˆLÜ˜uŸz™z›|Ö,�Ù" 5Ó)Ô)ó -ò &ùs   ‚AA!c                 óœ   • U R                    Vs/ s H#  oS   R                  5       R                  5       PM%     nn[        S US5      $ s  snf )Nr0   c                 ó
   • X-   $ r;   r%   )ÚxÚys     r   r'   ÚPackedDB.size.<locals>.<lambda>t   s   €  1¢5r   r   )r   r4   rH   r   )r   r3   Úsizess      r   rH   ÚPackedDB.sizer   sA   € Ø48·N²NÓC²N¨D�a‘—‘“×%Ñ%Ö'±NˆÐCÜÑ(¨%°Ó3Ð3ùò Ds   �*A	c                 ó   • [        5       e)z—Storing individual objects is not feasible as a pack is designed to
hold multiple objects. Writing or rewriting packs for single objects is
inefficient)r   )r   Úistreams     r   ÚstoreÚPackedDB.storez   s   € ô #Ó$Ð$r   c                 ó†  • [         R                  " U R                  5       5      nU(       d  UR                  U R                  ::  a  gUR                  U l        [        [        R                  " [         R                  R                  U R                  5       S5      5      5      nU R                   Vs1 s H#  oDS   R                  5       R                  5       iM%     nnX5-
   H_  n[        U5      nU R                  R                  UR                  5       R                  5       XwR                  5       R                  /5        Ma     XS-
   Ha  nSn[!        U R                  5       H.  u  p”US   R                  5       R                  5       U:X  d  M,  U	n  O   US:w  d   eU R                  U	 Mc     U R#                  5         gs  snf )a–  
Update our cache with the actually existing packs on disk. Add new ones,
and remove deleted ones. We keep the unchanged ones

:param force: If True, the cache will be updated even though the directory
    does not appear to have changed according to its modification timestamp.
:return: True if the packs have been updated so there is new information,
    False if there was no change to the pack databaseFzpack-*.packr0   éÿÿÿÿT)ÚosÚstatr   Úst_mtimer   ÚsetÚglobÚpathÚjoinr   Úpackr
   ÚappendrH   r4   Úsha_to_indexÚ	enumerater,   )
r   r   rZ   Ú
pack_filesr3   Úour_pack_filesÚ	pack_filer>   Ú	del_indexÚis
             r   r   ÚPackedDB.update_cache„   sW  € ô �wŠw�t—~‘~Ó'Ó(ˆÞ˜Ÿ™¨$¯.©.Ó8ØàŸ™ˆŒô œŸš¤2§7¡7§<¡<°·±Ó0@À-Ó#PÓQÓRˆ
Ø<@¿NºNÓKºN°D˜q™'Ÿ,™,›.×-Ñ-Ö/¹NˆÐKð %Ô5ˆIô   	Ó*ˆFØ�N‰N×!Ñ! 6§;¡;£=×#5Ñ#5Ó#7¸ÇÁÃ×A\ÑA\Ð"]Ö^ñ	 6ð )Ô5ˆIØˆIÜ$ T§^¡^Ö4‘�Ø˜‘7—<‘<“>×&Ñ&Ó(¨IÕ5Ø !�IÙñ 5ð  “?Ð"�?Ø—‘˜yÒ)ñ 6ð 	×ÑÔØùò3 Ls   Â1*F>c                 óJ   • U R                    Vs/ s H  oS   PM	     sn$ s  snf )z=:return: list of pack entities operated upon by this databaser0   )r   )r   r3   s     r   rF   ÚPackedDB.entities±   s    € à$(§N¢NÓ3¢N˜D�Q”¡NÑ3Ð3ùÒ3s   � c                 ó  • SnU R                    He  nUS   R                  5       R                  X5      nUc  M*  US   R                  5       R                  U5      nU(       a  X6:w  a  [	        U5      eUnMg     U(       a  U$ [        U5      e)as  :return: 20 byte sha as inferred by the given partial binary sha
:param partial_binsha: binary sha with less than 20 bytes
:param canonical_length: length of the corresponding canonical representation.
    It is required as binary sha's cannot display whether the original hex sha
    had an odd or even number of characters
:raise AmbiguousObjectName:
:raise BadObject: Nr0   )r   r4   Úpartial_sha_to_indexr2   r	   r   )r   Úpartial_binshaÚcanonical_lengthÚ	candidater3   Ú
item_indexr2   s          r   Úpartial_to_complete_shaÚ PackedDB.partial_to_complete_shaµ   s�   € ð ˆ	Ø—N”NˆDØ˜a™Ÿ™›×=Ñ=¸nÓ_ˆJØÓ%Ø˜1‘g—m‘m“o×)Ñ)¨*Ó5�Þ Ó!1Ü-¨nÓ=Ð=Ø’	ñ #ö ØÐô ˜Ó'Ð'r   )r   r   r   )F)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r1   r   r!   r,   r5   r8   r?   rC   rJ   rH   rU   r   rF   rr   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r       sT   ø† á7ð
 €Nõò*ò>òò:ò+ò-ò*ò4ò%ô+òZ4÷(ð (r   r   )rx   Úgitdb.db.baser   r   r   Ú
gitdb.utilr   Ú	gitdb.excr   r   r	   Ú
gitdb.packr
   Ú	functoolsr   rY   r]   Ú__all__r   r%   r   r   Ú<module>r�      sJ   ðñ
 6÷ñ õ !÷ñ õ "å ã 	Û à
€ô
l(ˆz˜9 i°õ l(r   