§
    ÎÑßj\  ã                   ó`  — d Z g d¢ZddlZddlmZ ddlZddlmZ ddl	Z	ddl
Z
ddlmZ ddlmZmZmZmZmZmZ ddlmZmZmZ erddlmZ e	j        Ze	j        Z G d	„ d
¦  «        Zdedef         dedef         fd„Zdedef         dedef         fd„Zdedef         dedef         fd„ZdS )zIndex utilities.)ÚTemporaryFileSwapÚpost_clear_cacheÚdefault_indexÚgit_working_diré    N)Úwraps)ÚTracebackType)ÚAnyÚCallableÚTYPE_CHECKINGÚOptionalÚTypeÚcast)ÚLiteralÚPathLikeÚ_T)Ú	IndexFilec            	       ó‚   — e Zd ZdZdZdeddfd„Zdd„Zdee	e
                  d	ee
         d
ee         ded         fd„ZdS )r   z„Utility class moving a file to a temporary location within the same directory and
    moving it back on to where on object deletion.)Ú	file_pathÚtmp_file_pathr   ÚreturnNc                 óH  — || _         t          j        |¦  «        \  }}t          j        ||¬¦  «        \  }| _        t          j        |¦  «         t          j	        t          ¦  «        5  t          j        | j         | j        ¦  «         d d d ¦  «         d S # 1 swxY w Y   d S )N)ÚprefixÚdir)r   ÚospÚsplitÚtempfileÚmkstempr   ÚosÚcloseÚ
contextlibÚsuppressÚOSErrorÚreplace)Úselfr   ÚdirnameÚbasenameÚfds        úB/opt/saltstack/salt/lib/python3.11/site-packages/git/index/util.pyÚ__init__zTemporaryFileSwap.__init__'   sÓ   € Ø"ˆŒÝœI iÑ0Ô0Ñˆ�Ý!)Ô!1¸ÀwÐ!OÑ!OÔ!OÑˆˆDÔÝ
Œ�‰ŒˆÝÔ ¥Ñ)Ô)ð 	;ð 	;ÝŒJ�t”~ tÔ'9Ñ:Ô:Ð:ð	;ð 	;ð 	;ñ 	;ô 	;ð 	;ð 	;ð 	;ð 	;ð 	;ð 	;ð 	;øøøð 	;ð 	;ð 	;ð 	;ð 	;ð 	;s   Á* BÂBÂBc                 ó   — | S ©N© )r$   s    r(   Ú	__enter__zTemporaryFileSwap.__enter__/   s   € Øˆó    Úexc_typeÚexc_valÚexc_tbFc                 óv   — t          j        | j        ¦  «        rt          j        | j        | j        ¦  «         dS )NF)r   Úisfiler   r   r#   r   )r$   r/   r0   r1   s       r(   Ú__exit__zTemporaryFileSwap.__exit__2   s5   € õ Œ:�dÔ(Ñ)Ô)ð 	;ÝŒJ�tÔ)¨4¬>Ñ:Ô:Ð:Øˆur.   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r)   r-   r   r   ÚBaseExceptionr   r   r4   r,   r.   r(   r   r   !   s­   € € € € € ð6ð 6ð /€Ið; (ð ;¨tð ;ð ;ð ;ð ;ðð ð ð ðà˜4 Ô.Ô/ðð ˜-Ô(ðð ˜Ô'ð	ð
 
�Œðð ð ð ð ð r.   r   Úfunc.r   c           	      ól   ‡ — t          ‰ ¦  «        dddt          dt          dt          fˆ fd„¦   «         }|S )zøDecorator for functions that alter the index using the git command.

    When a git command alters the index, this invalidates our possibly existing entries
    dictionary, which is why it must be deleted to allow it to be lazily reread later.
    r$   r   ÚargsÚkwargsr   c                 óH   •—  ‰| g|¢R i |¤Ž}|                       ¦   «          |S r+   )Ú_delete_entries_cache)r$   r=   r>   Úrvalr;   s       €r(   Úpost_clear_cache_if_not_raisedz8post_clear_cache.<locals>.post_clear_cache_if_not_raisedG   s9   ø€ àˆt�DÐ*˜4Ð*Ð*Ð* 6Ð*Ð*ˆØ×"Ò"Ñ$Ô$Ð$Øˆr.   ©r   r	   r   )r;   rB   s   ` r(   r   r   @   sY   ø€ õ ˆ4�[„[ð¨[ð Åð ÕPSð ÕXZð ð ð ð ð ñ „[ðð *Ð)r.   c           	      ól   ‡ — t          ‰ ¦  «        dddt          dt          dt          fˆ fd„¦   «         }|S )z¬Decorator ensuring the wrapped method may only run if we are the default
    repository index.

    This is as we rely on git commands that operate on that index only.
    r$   r   r=   r>   r   c                 ó„   •— | j         |                      ¦   «         k    rt          d‰j        z  ¦  «        ‚ ‰| g|¢R i |¤ŽS )NzECannot call %r on indices that do not represent the default git index)Ú
_file_pathÚ_index_pathÚAssertionErrorr5   )r$   r=   r>   r;   s      €r(   Úcheck_default_indexz*default_index.<locals>.check_default_indexY   s\   ø€ àŒ?˜d×.Ò.Ñ0Ô0Ò0Ð0Ý ØWÐZ^ÔZgÑgñô ð ð ˆt�DÐ*˜4Ð*Ð*Ð* 6Ð*Ð*Ð*r.   rC   )r;   rI   s   ` r(   r   r   R   sW   ø€ õ ˆ4�[„[ð+ +ð +µcð +ÅSð +ÍRð +ð +ð +ð +ð +ñ „[ð+ð Ðr.   c           	      ól   ‡ — t          ‰ ¦  «        dddt          dt          dt          fˆ fd„¦   «         }|S )z�Decorator which changes the current working dir to the one of the git
    repository in order to ensure relative paths are handled correctly.r$   r   r=   r>   r   c                 ó   •— t          j        ¦   «         }t          j        t          t          | j        j        ¦  «        ¦  «         	  ‰| g|¢R i |¤Žt          j        |¦  «         S # t          j        |¦  «         w xY wr+   )r   ÚgetcwdÚchdirr   r   ÚrepoÚworking_tree_dir)r$   r=   r>   Úcur_wdr;   s       €r(   Úset_git_working_dirz,git_working_dir.<locals>.set_git_working_dirj   sx   ø€ å”‘”ˆÝ
Œ••h ¤	Ô :Ñ;Ô;Ñ<Ô<Ð<ð	Ø�4˜Ð.˜tÐ.Ð.Ð. vÐ.Ð.åŒH�VÑÔÐÐø�BŒH�VÑÔÐÐøøøs   ÁA' Á'A=rC   )r;   rQ   s   ` r(   r   r   f   sW   ø€ õ ˆ4�[„[ð +ð µcð ÅSð ÍRð ð ð ð ð ñ „[ðð Ðr.   ) r8   Ú__all__r    Ú	functoolsr   r   Úos.pathÚpathr   Ústructr   Útypesr   Útypingr	   r
   r   r   r   r   Ú	git.typesr   r   r   Ú	git.indexr   ÚpackÚunpackr   r   r   r   r,   r.   r(   ú<module>r]      s¾  ðð Ð à
WÐ
WÐ
W€à Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø 	€	€	€	Ø Ð Ð Ð Ð Ð Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð ð FÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ Eà +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +àð $Ø#Ð#Ð#Ð#Ð#Ð#ð
 „{€Ø	Œ€ðð ð ð ð ñ ô ð ð>*˜8 C¨ GÔ,ð *°¸#¸r¸'Ô1Bð *ð *ð *ð *ð$˜  b Ô)ð ¨h°s¸B°wÔ.?ð ð ð ð ð(˜( 3¨ 7Ô+ð °¸¸b¸Ô0Að ð ð ð ð ð r.   