HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/git/index/__pycache__/util.cpython-310.pyc
o

;j\�@sdZgd�ZddlZddlmZddlZddlmZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZmZddlmZmZmZerJddlmZe	jZe	jZGd	d
�d
�Zdedefd
edeffdd�Zdedefd
edeffdd�Zdedefd
edeffdd�ZdS)zIndex utilities.)�TemporaryFileSwap�post_clear_cache�
default_index�git_working_dir�N)�wraps)�
TracebackType)�Any�Callable�
TYPE_CHECKING�Optional�Type�cast)�Literal�PathLike�_T)�	IndexFilec	@s^eZdZdZdZdeddfdd�Zddd	�Zd
ee	e
dee
deeded
fdd�Z
dS)rz�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�returnNcCsr||_t�|�\}}tj||d�\}|_t�|�t�	t
��t�|j|j�Wd�dS1s2wYdS)N)�prefix�dir)r�osp�split�tempfileZmkstempr�os�close�
contextlib�suppress�OSError�replace)�selfr�dirname�basename�fd�r$�B/opt/saltstack/salt/lib/python3.10/site-packages/git/index/util.py�__init__'s
"�zTemporaryFileSwap.__init__cCs|S�Nr$)r r$r$r%�	__enter__/szTemporaryFileSwap.__enter__�exc_type�exc_val�exc_tbFcCs t�|j�rt�|j|j�dS)NF)r�isfilerrrr)r r)r*r+r$r$r%�__exit__2szTemporaryFileSwap.__exit__)rr)�__name__�
__module__�__qualname__�__doc__�	__slots__rr&r(rr�
BaseExceptionrrr-r$r$r$r%r!s

����r�func.rc	�*t��dddtdtdtf�fdd��}|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�kwargsrcs"�|g|�Ri|��}|��|Sr')Z_delete_entries_cache)r r6r7Zrval�r4r$r%�post_clear_cache_if_not_raisedGsz8post_clear_cache.<locals>.post_clear_cache_if_not_raised�rrr)r4r9r$r8r%r@s rc	r5)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 rr6r7rcs2|j|��krtd�j���|g|�Ri|��S)NzECannot call %r on indices that do not represent the default git index)Z
_file_pathZ_index_path�AssertionErrorr.)r r6r7r8r$r%�check_default_indexYs
�z*default_index.<locals>.check_default_indexr:)r4r<r$r8r%rRs 	rc	r5)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 rr6r7rc	sLt��}t�tt|jj��z�|g|�Ri|��Wt�|�St�|�wr')r�getcwd�chdirr
rZrepoZworking_tree_dir)r r6r7Zcur_wdr8r$r%�set_git_working_dirjs
z,git_working_dir.<locals>.set_git_working_dirr:)r4r?r$r8r%rfs r) r1�__all__r�	functoolsrrZos.path�pathr�structr�typesr�typingrr	r
rrr
Z	git.typesrrrZ	git.indexr�pack�unpackrrrrr$r$r$r%�<module>s& ""&