§
    |{Èc=  ã                   óò   — d Z ddlmZmZmZmZmZmZmZ  e	¦   «         Z
 ed¦  «        Z ed¦  «        Z G d„ deeef         ¦  «        Z G d„ deeef         ¦  «        Z G d	„ d
eeef         ¦  «        ZdS )z)A simple least-recently-used (LRU) cache.é    )ÚGenericÚTypeVarÚOptionalÚCallableÚDictÚIterableÚIteratorÚKÚVc                   ón   — e Zd ZU dZdZed         ed<   eed<   ee         ed<   dded	e	fd
„Z
d„ Zdd„ZdS )Ú_LRUNodez:This maintains the linked-list which is the lru internals.)ÚprevÚnext_keyÚkeyÚvalueÚcleanupÚsizez_LRUNode[K, V]r   r   r   Nr   r   c                 ód   — d | _         t          | _        || _        || _        || _        d | _        d S ©N)r   Ú	_null_keyr   r   r   r   r   )Úselfr   r   r   s       ú3/usr/lib/python3/dist-packages/dulwich/lru_cache.pyÚ__init__z_LRUNode.__init__+   s2   € ØˆŒ	Ý!ˆŒØˆŒØˆŒ
ØˆŒð ˆŒ	ˆ	ˆ	ó    c                 ó†   — | j         €d }n| j         j        }d                     | j        j        | j        | j        |¦  «        S )Nz{}({!r} n:{!r} p:{!r}))r   r   ÚformatÚ	__class__Ú__name__r   )r   Úprev_keys     r   Ú__repr__z_LRUNode.__repr__6   sG   € ØŒ9ÐØˆHˆHà”y”}ˆHØ'×.Ò.ØŒNÔ#ØŒHØŒMØñ	
ô 
ð 	
r   Úreturnc                 óf   — | j         � |                       | j        | j        ¦  «         d | _         | `d S r   )r   r   r   ©r   s    r   Úrun_cleanupz_LRUNode.run_cleanupB   s2   € ØŒ<Ð#Ø�LŠL˜œ 4¤:Ñ.Ô.Ð.ØˆŒàˆJˆJˆJr   r   ©r!   N)r   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   Ú__annotations__r
   Úintr   r   r    r$   © r   r   r   r   "   s–   € € € € € € ØDÐDàG€Ià
Ð#Ô
$Ð$Ð$Ñ$Ø€K€K�KØ
�3Œ-ÐÐÑð	ð 	˜Að 	 að 	ð 	ð 	ð 	ð

ð 

ð 

ðð ð ð ð ð r   r   c            
       ó  — e Zd ZU dZeeeef                  ed<   eeeef                  ed<   d de	dee	         ddfd	„Z
d
edefd„Zd
edefd„Zde	fd„Zdeeeef                  fd„Zd!d
ededeeeegdf                  ddfd„Zde	fd„Zd!d
edee         dee         fd„Zdee         fd„Zdeeef         fd„Zd„ Zd
ededdfd„Zdeeef         ddfd„Zdeeef         ddfd„Zd"d„Zd"d„Zd!de	dee	         ddfd„Zd!d„Z dS )#ÚLRUCachez?A class which manages a cache of entries, removing unused ones.Ú_least_recently_usedÚ_most_recently_usedéd   NÚ	max_cacheÚafter_cleanup_countr!   c                 ó\   — i | _         d | _        d | _        |                      ||¦  «         d S r   )Ú_cacher0   r/   Ú_update_max_cache©r   r2   r3   s      r   r   zLRUCache.__init__P   s6   € Ø/1ˆŒà#'ˆÔ à$(ˆÔ!Ø×Ò˜yÐ*=Ñ>Ô>Ð>Ð>Ð>r   r   c                 ó   — || j         v S r   )r5   )r   r   s     r   Ú__contains__zLRUCache.__contains__X   s   € Ø�d”kÐ!Ð!r   c                 ó  — | j         }||         }| j        }||u r|j        S |j        }|j        }|t
          u r|| _        n||         }||_        |sJ ‚|sJ ‚||_        |j        |_        ||_        || _        d |_        |j        S r   )r5   r0   r   r   r   r   r/   r   )r   r   ÚcacheÚnodeÚmruÚ	node_prevr   Ú	node_nexts           r   Ú__getitem__zLRUCache.__getitem__[   s©   € Ø”ˆØ�SŒzˆð
 Ô&ˆØ�3ˆ;ˆ;à”:Ðà”Iˆ	Ø”=ˆð •yÐ Ð ð )2ˆDÔ%Ð%à˜hœˆIØ&ˆIŒNØÐÐÐØˆ
ˆ
ˆ
Ø%ˆ	ÔàœˆŒØˆŒØ#'ˆÔ ØˆŒ	ØŒzÐr   c                 ó*   — t          | j        ¦  «        S r   )Úlenr5   r#   s    r   Ú__len__zLRUCache.__len__|   s   € Ý�4”;ÑÔÐr   c              #   ó¬  K  — | j         }|�|j        �t          d|›�¦  «        ‚|�­|j        t          u r|| j        urt          d|›�¦  «        ‚d}n-| j        |j                 }|j        |urt          d|›�¦  «        ‚|j        €|| j         urt          d|›�¦  «        ‚n'|j        j        |j        k    rt          d|›�¦  «        ‚|V — |}|­«dS dS )z2Walk the LRU list, only meant to be used in tests.NzGthe _most_recently_used entry is not supposed to have a previous entry z.only the last node should have no next value: z-inconsistency found, node.next.prev != node: z>only the _most_recently_used should not have a previous node: z-inconsistency found, node.prev.next != node: )r0   r   ÚAssertionErrorr   r   r/   r5   r   ©r   r<   r?   s      r   Ú	_walk_lruzLRUCache._walk_lru   sN  è è € àÔ'ˆØÐØŒyÐ$Ý$�nð "˜Tð$ñô ð ð
 ÐØŒ}¥	Ð)Ð)Ø˜tÔ8Ð8Ð8Ý(˜.ØQUÐQUÐWñô ð ð !�	�	à œK¨¬Ô6�	Ø”>¨Ð-Ð-Ý(˜.ØPTÐPTÐVñô ð ð ŒyÐ Ø˜tÔ7Ð7Ð7Ý(˜.à;?¸4ðBñô ð ð 8ð ”9Ô%¨¬Ò1Ð1Ý(˜.ØPTÐPTÐVñô ð ð ˆJˆJˆJØˆDð3 ÐÐÐÐÐr   r   r   c                 óp  — |t           u rt          d¦  «        ‚|| j        v r0| j        |         }|                     ¦   «          ||_        ||_        nt          |||¬¦  «        }|| j        |<   |                      |¦  «         t          | j        ¦  «        | j	        k    r|                      ¦   «          dS dS )á]  Add a new value to the cache.

        Also, if the entry is ever removed from the cache, call
        cleanup(key, value).

        Args:
          key: The key to store it under
          value: The object to store
          cleanup: None or a function taking (key, value) to indicate
                        'value' should be cleaned up.
        úcannot use _null_key as a key©r   N)
r   Ú
ValueErrorr5   r$   r   r   r   Ú_record_accessrB   Ú
_max_cache)r   r   r   r   r<   s        r   ÚaddzLRUCache.add¤   s½   € ð •)ÐÐÝÐ<Ñ=Ô=Ð=Ø�$”+ÐÐØ”;˜sÔ#ˆDØ×ÒÑÔÐØˆDŒJØ"ˆDŒLˆLå˜C °Ð8Ñ8Ô8ˆDØ#ˆDŒK˜ÑØ×Ò˜DÑ!Ô!Ð!åˆtŒ{ÑÔ˜dœoÒ-Ð-à�LŠL‰NŒNˆNˆNˆNð .Ð-r   c                 ó   — | j         S )z(Get the number of entries we will cache.)rN   r#   s    r   Ú
cache_sizezLRUCache.cache_sizeÀ   s
   € àŒÐr   Údefaultc                 óx   — | j                              |d ¦  «        }|€|S |                      |¦  «         |j        S r   )r5   ÚgetrM   r   )r   r   rR   r<   s       r   rT   zLRUCache.getÄ   s=   € ØŒ{�Š˜s DÑ)Ô)ˆØˆ<ØˆNØ×Ò˜DÑ!Ô!Ð!ØŒzÐr   c                 ó4   — | j                              ¦   «         S )a  Get the list of keys currently cached.

        Note that values returned here may not be available by the time you
        request them later. This is simply meant as a peak into the current
        state.

        Returns: An unordered list of keys that are currently cached.
        )r5   Úkeysr#   s    r   rV   zLRUCache.keysË   s   € ð Œ{×ÒÑ!Ô!Ð!r   c                 óH   — d„ | j                              ¦   «         D ¦   «         S )z"Get the key:value pairs as a dict.c                 ó$   — i | ]\  }}||j         “ŒS r,   )r   )Ú.0ÚkÚns      r   ú
<dictcomp>z"LRUCache.items.<locals>.<dictcomp>Ø   s    € Ð;Ð;Ð;™t˜q !��1”7Ð;Ð;Ð;r   )r5   Úitemsr#   s    r   r]   zLRUCache.itemsÖ   s$   € à;Ð; t¤{×'8Ò'8Ñ':Ô':Ð;Ñ;Ô;Ð;r   c                 ó¦   — t          | j        ¦  «        | j        k    r3|                      ¦   «          t          | j        ¦  «        | j        k    °1dS dS )z¯Clear the cache until it shrinks to the requested size.

        This does not completely wipe the cache, just makes sure it is under
        the after_cleanup_count.
        N)rB   r5   Ú_after_cleanup_countÚ_remove_lrur#   s    r   r   zLRUCache.cleanupÚ   sT   € õ �$”+ÑÔ Ô!:Ò:Ð:Ø×ÒÑÔÐõ �$”+ÑÔ Ô!:Ò:Ð:Ð:Ð:Ð:Ð:r   c                 ó6   — |                       ||d¬¦  «         dS )z<Add a value to the cache, there will be no cleanup function.NrK   )rO   )r   r   r   s      r   Ú__setitem__zLRUCache.__setitem__ä   s    € à�Š��e TˆÑ*Ô*Ð*Ð*Ð*r   r<   c                 óR  — | j         €|| _         || _        dS || j         u rdS || j        u r|j        | _        |j        �|j        |j        _        |j        t          ur| j        |j                 }|j        |_        | j         j        |_        || j         _        || _         d|_        dS )zRecord that key was accessed.N)r0   r/   r   r   r   r5   r   rF   s      r   rM   zLRUCache._record_accessè   s²   € ð Ô#Ð+Ø'+ˆDÔ$Ø(,ˆDÔ%ØˆFØ�TÔ-Ð-Ð-àˆFð �4Ô,Ð,Ð,Ø(,¬	ˆDÔ%ØŒ9Ð Ø!%¤ˆDŒIÔØŒ=¥	Ð)Ð)Øœ D¤MÔ2ˆIØ!œYˆIŒNàÔ0Ô4ˆŒØ(,ˆÔ Ô%Ø#'ˆÔ ØˆŒ	ˆ	ˆ	r   c                 ó`  — || j         u r|j        | _         | j                             |j        ¦  «         | j         €d | _        |                     ¦   «          |j        �|j        |j        _        |j        t          ur| j        |j                 }|j        |_        d |_        t          |_        d S r   )	r/   r   r5   Úpopr   r0   r$   r   r   rF   s      r   Ú_remove_nodezLRUCache._remove_node  s�   € Ø�4Ô,Ð,Ð,Ø(,¬	ˆDÔ%ØŒ�Š˜œÑ!Ô!Ð!àÔ$Ð,Ø'+ˆDÔ$Ø×ÒÑÔÐàŒ9Ð Ø!%¤ˆDŒIÔØŒ=¥	Ð)Ð)Øœ D¤MÔ2ˆIØ!œYˆIŒNàˆŒ	Ý!ˆŒˆˆr   c                 óL   — | j         sJ ‚|                      | j         ¦  «         dS )z¯Remove one entry from the lru, and handle consequences.

        If there are no more references to the lru, then this entry should be
        removed from the cache.
        N)r/   rf   r#   s    r   r`   zLRUCache._remove_lru  s0   € ð Ô(Ð(Ð(Ð(Ø×Ò˜$Ô3Ñ4Ô4Ð4Ð4Ð4r   c                 óN   — | j         r|                      ¦   «          | j         °dS dS )zClear out all of the cache.N)r5   r`   r#   s    r   ÚclearzLRUCache.clear  s@   € ð Œkð 	Ø×ÒÑÔÐð Œkð 	ð 	ð 	ð 	ð 	r   c                 ó4   — |                       ||¬¦  «         dS )z1Change the number of entries that will be cached.)r3   N)r6   r7   s      r   ÚresizezLRUCache.resize#  s"   € à×Ò˜yÐ>QÐÑRÔRÐRÐRÐRr   c                 óš   — || _         |€| j         dz  dz  | _        nt          || j         ¦  «        | _        |                      ¦   «          d S ©Né   é
   )rN   r_   Úminr   r7   s      r   r6   zLRUCache._update_max_cache'  sL   € Ø#ˆŒØÐ&Ø(,¬¸!Ñ(;¸bÑ(@ˆDÔ%Ð%å(+Ð,?ÀÄÑ(QÔ(QˆDÔ%Ø�Š‰Œˆˆˆr   )r1   Nr   r%   )!r   r&   r'   r(   r   r   r
   r   r*   r+   r   Úboolr9   r@   rC   r	   rG   r   rO   rQ   rT   r   rV   r   r]   r   rb   rM   rf   r`   ri   rk   r6   r,   r   r   r.   r.   J   sè  € € € € € € ØIÐIà" 8¨A¨q¨D¤>Ô2Ð2Ð2Ñ2Ø! (¨1¨a¨4¤.Ô1Ð1Ð1Ñ1ð?ð ? #ð ?À(È3Ä-ð ?Ð[_ð ?ð ?ð ?ð ?ð" ð " dð "ð "ð "ð "ð˜qð  Qð ð ð ð ðB ˜ð  ð  ð  ð  ð#˜8 H¨Q°¨T¤NÔ3ð #ð #ð #ð #ðJð �qð  ð ¨X°hÀÀ1¸vÀt¸|Ô6LÔ-Mð ÐY]ð ð ð ð ð8˜Cð ð ð ð ðð �qð  8¨A¤;ð ¸(À1¼+ð ð ð ð ð	"�h˜q”kð 	"ð 	"ð 	"ð 	"ð<�t˜A˜q˜D”zð <ð <ð <ð <ðð ð ð+˜qð +¨ð +¨tð +ð +ð +ð +ð 8¨A¨q¨D¤>ð °dð ð ð ð ð4" ¨!¨Q¨$¤ð "°Dð "ð "ð "ð "ð$5ð 5ð 5ð 5ðð ð ð ðSð S ð S¸(À3¼-ð SÐSWð Sð Sð Sð Sðð ð ð ð ð r   r.   c            
       ó  — e Zd ZU dZeegef         ed<   	 	 ddedee         deeegef                  ddfd	„Z	dd
e
dedeee
egdf                  ddfd„Zdd„Zdee
ef         ddfd„Zddedee         ddfd„Zddedee         ddfd„ZdS )ÚLRUSizeCacheaU  An LRUCache that removes things based on the size of the values.

    This differs in that it doesn't care how many actual items there are,
    it just restricts the cache to be cleaned up after so much data is stored.

    The size of items added will be computed using compute_size(value), which
    defaults to len() if not supplied.
    Ú_compute_sizeé   NÚmax_sizeÚafter_cleanup_sizeÚcompute_sizer!   c           	      óâ   — d| _         |€t          | _        n|| _        |                      ||¬¦  «         t                               | t          t          |dz  ¦  «        d¦  «        ¬¦  «         dS )a¤  Create a new LRUSizeCache.

        Args:
          max_size: The max number of bytes to store before we start
            clearing out entries.
          after_cleanup_size: After cleaning up, shrink everything to this
            size.
          compute_size: A function to compute the size of the values. We
            use a function here, so that you can pass 'len' if you are just
            using simple strings, or a more complex function if you are using
            something like a list of strings, or even a custom object.
            The function should take the form "compute_size(value) => integer".
            If not supplied, it defaults to 'len()'
        r   N©rw   é   é   )r2   )Ú_value_sizerB   rt   Ú_update_max_sizer.   r   Úmaxr+   )r   rv   rw   rx   s       r   r   zLRUSizeCache.__init__<  st   € ð$ ˆÔØÐÝ!$ˆDÔÐà!-ˆDÔØ×Ò˜hÐ;MÐÑNÔNÐNÝ×Ò˜$­#­c°(¸S±.Ñ.AÔ.AÀ1Ñ*EÔ*EÐÑFÔFÐFÐFÐFr   r   r   r   c                 ó  — |t           u rt          d¦  «        ‚| j                             |d¦  «        }|                      |¦  «        }|| j        k    r'|�|                      |¦  «         |� |||¦  «         dS |€t          |||¬¦  «        }|| j        |<   n|j        €J ‚| xj	        |j        z  c_	        ||_        | xj	        |z  c_	        |  
                    |¦  «         | j	        | j        k    r|                      ¦   «          dS dS )rI   rJ   NrK   )r   rL   r5   rT   rt   Ú_after_cleanup_sizerf   r   r   r}   rM   Ú	_max_sizer   )r   r   r   r   r<   Ú	value_lens         r   rO   zLRUSizeCache.addV  s1  € ð •)ÐÐÝÐ<Ñ=Ô=Ð=ØŒ{�Š˜s DÑ)Ô)ˆØ×&Ò& uÑ-Ô-ˆ	Ø˜Ô0Ò0Ð0ð Ðà×!Ò! $Ñ'Ô'Ð'ØÐ"Ø�˜˜UÑ#Ô#Ð#ØˆFØˆ<Ý˜C °Ð8Ñ8Ô8ˆDØ#ˆDŒK˜ÑÐà”9Ð(Ð(Ð(ØÐÔ ¤	Ñ)ÐÔØˆŒ	ØÐÔ˜IÑ%ÐÔØ×Ò˜DÑ!Ô!Ð!àÔ˜dœnÒ,Ð,à�LŠL‰NŒNˆNˆNˆNð -Ð,r   c                 ór   — | j         | j        k    r&|                      ¦   «          | j         | j        k    °$dS dS )z®Clear the cache until it shrinks to the requested size.

        This does not completely wipe the cache, just makes sure it is under
        the after_cleanup_size.
        N)r}   r�   r`   r#   s    r   r   zLRUSizeCache.cleanup}  sF   € ð Ô Ô!9Ò9Ð9Ø×ÒÑÔÐð Ô Ô!9Ò9Ð9Ð9Ð9Ð9Ð9r   r<   c                 óx   — |j         €J ‚| xj        |j         z  c_        t                               | |¦  «         d S r   )r   r}   r.   rf   )r   r<   s     r   rf   zLRUSizeCache._remove_node‡  sB   € ØŒyÐ$Ð$Ð$ØÐÔ˜DœIÑ%ÐÔÝ×Ò˜d DÑ)Ô)Ð)Ð)Ð)r   c                 óž   — |                       ||¬¦  «         t          t          |dz  ¦  «        d¦  «        }|                      |¦  «         dS )z/Change the number of bytes that will be cached.rz   r{   r|   N)r~   r   r+   r6   )r   rv   rw   r2   s       r   rk   zLRUSizeCache.resizeŒ  sQ   € à×Ò˜hÐ;MÐÑNÔNÐNÝ�˜H s™NÑ+Ô+¨QÑ/Ô/ˆ	Ø×Ò˜yÑ)Ô)Ð)Ð)Ð)r   c                 ót   — || _         |€| j         dz  dz  | _        d S t          || j         ¦  «        | _        d S rm   )r‚   r�   rp   )r   rv   rw   s      r   r~   zLRUSizeCache._update_max_size’  sD   € Ø!ˆŒØÐ%Ø'+¤~¸Ñ'9¸RÑ'?ˆDÔ$Ð$Ð$å'*Ð+=¸t¼~Ñ'NÔ'NˆDÔ$Ð$Ð$r   )ru   NNr   r%   )r   r&   r'   r(   r   r   r+   r*   r   r   r
   rO   r   r   rf   rk   r~   r,   r   r   rs   rs   0  s’  € € € € € € ðð ð ˜Q˜C ˜HÔ%Ð%Ð%Ñ%ð TXØ9=ðGð GØðGØCKÈCÄ=ðGà" 8¨Q¨C°¨HÔ#5Ô6ðGð 
ðGð Gð Gð Gð4%ð %�qð % ð %¨X°hÀÀ1¸vÀt¸|Ô6LÔ-Mð %ÐY]ð %ð %ð %ð %ðNð ð ð ð* ¨!¨Q¨$¤ð *°Dð *ð *ð *ð *ð
*ð *˜sð *¸À¼ð *ÐQUð *ð *ð *ð *ðOð O¨ð OÀ(È3Ä-ð OÐ[_ð Oð Oð Oð Oð Oð Or   rs   N)r(   Útypingr   r   r   r   r   r   r	   Úobjectr   r
   r   r   r.   rs   r,   r   r   ú<module>rŠ      s*  ðð, 0Ð /à QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ Qð ˆF‰HŒH€	ð €GˆC�L„L€Ø€GˆC�L„L€ð%ð %ð %ð %ð %ˆw�q˜!�tŒ}ñ %ô %ð %ðPcð cð cð cð cˆw�q˜!�tŒ}ñ cô cð cðLgOð gOð gOð gOð gO�8˜A˜q˜D”>ñ gOô gOð gOð gOð gOr   