yL iKDdZgdZddlZddlmZddlZddlmZddl Z ddl Z ddl m Z ddl mZmZmZmZmZddlmZmZmZerddlmZe j2Ze j4ZGd d Zd ed efd ed effdZd ed efd ed effdZd ed efd ed effdZy)zIndex utilities.)TemporaryFileSwappost_clear_cache default_indexgit_working_dirN)wraps) TracebackType)AnyCallable TYPE_CHECKINGOptionalType)LiteralPathLike_T) IndexFilec beZdZdZdZdeddfdZd dZdee e d ee d ee de d fd Z y)rzUtility 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_pathrreturnNcZ||_tj|\}}tj||\}|_t j|tjt5t j|j|j dddy#1swYyxYw)N)prefixdir) rospsplittempfilemkstemprosclose contextlibsuppressOSErrorreplace)selfrdirnamebasenamefds T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/git/index/util.py__init__zTemporaryFileSwap.__init__'s|"IIi0!)!1!1w!OD     ) ; JJt~~t'9'9 : ; ; ;s -+B!!B*c|SN)r#s r' __enter__zTemporaryFileSwap.__enter__/s exc_typeexc_valexc_tbFctj|jr*tj|j|j y)NF)risfilerrr"r)r#r.r/r0s r'__exit__zTemporaryFileSwap.__exit__2s1 ::d(( ) JJt))4>> :r-)rr)__name__ __module__ __qualname____doc__ __slots__rr(r,r r BaseExceptionrrr3r+r-r'rr!si6/I;(;t;4 ./-('   r-rfunc.rc Xtdddtdtdtffd }|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#rargskwargsrc@|g|i|}|j|Sr*)_delete_entries_cache)r#r<r=rvalr:s r'post_clear_cache_if_not_raisedz8post_clear_cache..post_clear_cache_if_not_raisedGs(D*4*6* ""$ r-rr r)r:rAs` r'rr@sA 4[[PSXZ *)r-c Xtdddtdtdtffd }|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#rr<r=rc|j|jk7rtdjz|g|i|S)NzECannot call %r on indices that do not represent the default git index) _file_path _index_pathAssertionErrorr4)r#r<r=r:s r'check_default_indexz*default_index..check_default_indexYsK ??d..0 0 WZ^ZgZgg D*4*6**r-rB)r:rHs` r'rrRs? 4[+++c+S+R++ r-c Xtdddtdtdtffd }|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#rr<r=rctj}tjt|jj  |g|i|tj|S#tj|wxYwr*)rgetcwdchdirstrrepoworking_tree_dir)r#r<r=cur_wdr:s r'set_git_working_dirz,git_working_dir..set_git_working_dirjsY TYY//01 .t.v. HHV BHHV s A**BrB)r:rQs` r'rrfs? 4[+cSR r-)r7__all__r functoolsrros.pathpathrstructrtypesrtypingr r r r r git.typesrrr git.indexrpackunpackrrrrr+r-r'r]s W  @?++# {{ >*8CG,*#r'1B*$b)hsBw.?((37+b0Ar-