
    64%e                     Z   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ ddlmZmZmZmZmZ ddlmZmZ erddlmZ d	Zej        Zej        Z G d
 de          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!Module containing index utilities    )wrapsN)TracebackType)is_win)AnyCallableTYPE_CHECKINGOptionalType)PathLike_T)	IndexFile)TemporaryFileSwappost_clear_cachedefault_indexgit_working_dirc                   v    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fdZdS )r   zUtility 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                     || _         t          | j                   t          j        ddd          z   | _        	 t          j        | j         | j                   d S # t          $ r Y d S w xY w)N )r   strtempfilemktempr   osrenameOSError)selfr   s     .lib/python3.11/site-packages/git/index/util.py__init__zTemporaryFileSwap.__init__*   sr    " 008?2r23N3NN	Idnd&899999 	 	 	DD	s   A 
A('A(c                     | S N )r   s    r   	__enter__zTemporaryFileSwap.__enter__3   s        exc_typeexc_valexc_tbc                     t          j        | j                  rXt          r2t          j        | j                  rt          j        | j                   t          j        | j        | j                   dS )NF)	ospisfiler   r   existsr   r   remover   )r   r&   r'   r(   s       r   __exit__zTemporaryFileSwap.__exit__6   sb     :d()) 	: *#*T^44 *	$.)))Id($.999ur%   )r   r   )__name__
__module____qualname____doc__	__slots__r   r    r$   r	   r
   BaseExceptionr   boolr.   r#   r%   r   r   r   #   s        : : /I( t       4./ -( '	
 
     r%   r   func.r   c           	      l     t                     dddt          dt          dt          f fd            }|S )a  Decorator for functions that alter the index using the git command. This would
    invalidate our possibly existing entries dictionary which is why it must be
    deleted to allow it to be lazily reread later.

    :note:
        This decorator will not be required once all functions are implemented
        natively which in fact is possible, but probably not feasible performance wise.
    r   r   argskwargsr   c                 H     | g|R i |}|                                   |S r"   )_delete_entries_cache)r   r8   r9   rvalr6   s       r   post_clear_cache_if_not_raisedz8post_clear_cache.<locals>.post_clear_cache_if_not_raisedQ   s9    tD*4***6**""$$$r%   r   r   r   )r6   r=   s   ` r   r   r   G   sY     4[[[  PS XZ      [ *)r%   c           	      l     t                     dddt          dt          dt          f fd            }|S )zDecorator assuring 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   r8   r9   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AssertionErrorr/   )r   r8   r9   r6   s      r   check_default_indexz*default_index.<locals>.check_default_indexa   s\    ?d..0000 WZ^Zgg   tD*4***6***r%   r>   )r6   rD   s   ` r   r   r   \   sW    
 4[[++ +c +S +R + + + + + [+ r%   c           	      l     t                     dddt          dt          dt          f fd            }|S )zDecorator which changes the current working dir to the one of the git
    repository in order to assure relative paths are handled correctlyr   r   r8   r9   r   c                     t          j                    }t          j        t          | j        j                             	  | g|R i |t          j        |           S # t          j        |           w xY wr"   )r   getcwdchdirr   repoworking_tree_dir)r   r8   r9   cur_wdr6   s       r   set_git_working_dirz,git_working_dir.<locals>.set_git_working_dirr   sv    
TY/00111	4.t...v..HVBHVs   A! !A7r>   )r6   rL   s   ` r   r   r   n   sW     4[[+ c S R      [ r%   ) r2   	functoolsr   r   structr   typesr   
git.compatr   os.pathpathr*   typingr   r   r   r	   r
   	git.typesr   r   	git.indexr   __all__packunpackobjectr   r   r   r   r#   r%   r   <module>rZ      s   ' '       				                    
 @ ? ? ? ? ? ? ? ? ? ? ? ? ? " " " " " " " " $######
 X {	       H*8CG, *#r'1B * * * **b) hsBw.?    $(37+ b0A      r%   