
    .PhK                     \   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 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)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   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                 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        N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/git/index/util.py__init__zTemporaryFileSwap.__init__'   s    "Ii00!)!1w!O!O!OD
 )) 	; 	;Jt~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.   r/   r0   s       r'   __exit__zTemporaryFileSwap.__exit__2   s5     :d()) 	;Jt)4>:::ur-   )r   r   )__name__
__module____qualname____doc__	__slots__r   r(   r,   r   r   BaseExceptionr   r   r3   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 )zDecorator 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    tD*4***6**""$$$r-   r   r	   r   )r:   rA   s   ` r'   r   r   @   sY     4[[[  PS XZ      [ *)r-   c           	      l     t                     dddt          dt          dt          f fd            }|S )zDecorator 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AssertionErrorr4   )r#   r<   r=   r:   s      r'   check_default_indexz*default_index.<locals>.check_default_indexY   s\    ?d..0000 WZ^Zgg   tD*4***6***r-   rB   )r:   rH   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 )zDecorator 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          | j        j                             	  | g|R i |t          j        |           S # t          j        |           w xY wr*   )r   getcwdchdirstrrepoworking_tree_dir)r#   r<   r=   cur_wdr:   s       r'   set_git_working_dirz,git_working_dir.<locals>.set_git_working_dirj   sv    
TY/00111	4.t...v..HVBHVs   A! !A7rB   )r:   rQ   s   ` r'   r   r   f   sW     4[[+ c S R      [ r-   )r7   __all__r   	functoolsr   r   os.pathpathr   structr   typesr   typingr	   r
   r   r   r   	git.typesr   r   r   	git.indexr   packunpackr   r   r   r   r+   r-   r'   <module>r]      s    
W
W
W           				               @ ? ? ? ? ? ? ? ? ? ? ? ? ? + + + + + + + + + + $######
 {	       >*8CG, *#r'1B * * * *$b) hsBw.?    ((37+ b0A      r-   