
    chA                        S r / SQrSSKJr  SSKrSSKJr  SSKJ	r	  SSK
JrJrJrJrJrJrJr  SSKrSSKrSSKJr  SSKJr  SS	KJrJr  SS
KJrJrJrJr  SSK J!r!J"r"  SSK#J$r$J%r%J&r&  SSK'J(r(J)r)  SSK*J+r+J,r,J-r-J.r.  SSK/J0r0J1r1  SSK2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;  SSK<J=r=  \7(       a  SSK>J?r?  SSK@JArA  SSKBJCrC  \\-  rD \-) rES\FS\=S\F4S jrGS\FS\F4S jrHS\FSSS\FSS4S jrIS \JS\J4S! jrKS\(4S"\6\:\+S#4      S$\4\L   S%\:S\L4   S&\9\(   SS4
S' jjrMS$\4\L   S\8\J\J4   4S( jrNS)\:\+\=\J4   S\8\=\J4   4S* jrOS$\4\L   S\8\J\3\8\=\J4   S#4   \L\L4   4S+ jrP S7S"\5\,   S,S-S.\QS/\JS\8\L\5S0   4   4
S1 jjrRS2S0S3\JS\+4S4 jrSS,S-S5\6\L   S\5\+   4S6 jrTg)8zVStandalone functions to accompany the index implementation and make it more
versatile.)write_cache
read_cachewrite_tree_from_cache	entry_keystat_mode_to_index_modeS_IFGITLINKrun_commit_hook	hook_path    )BytesION)Path)S_IFDIRS_IFLNKS_IFMTS_IFREGS_ISDIRS_ISLNKS_IXUSR)IStream)str_tree_type)handle_process_outputsafer_popen)defencforce_bytes
force_textsafe_decode)HookExecutionErrorUnmergedEntriesError)traverse_tree_recursivetraverse_trees_recursivetree_to_stream)IndexFileSHA1Writerfinalize_process   )BaseIndexEntry
IndexEntryCE_NAMEMASKCE_STAGESHIFT)packunpack)	DictIOListSequenceTYPE_CHECKINGTupleTypeUnioncast)PathLike)GitCmdObjectDB)TreeCacheTup)	IndexFilenamegit_dirreturnc                 2    [         R                  " USU 5      $ )zK:return: path to the given named hook in the given git repository directoryhooks)ospjoin)r7   r8   s     `C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\git/index/fun.pyr	   r	   >   s    88GWd++    pathc                 4    [         R                  " U 5      S   $ )Nr#   )r<   splitext)r@   s    r>   _has_file_extensionrC   C   s    <<a  r?   indexr6   argsc                    [        XR                  R                  5      n[        R                  " U[        R
                  5      (       d  g[        R                  R                  5       n[        [        UR                  5      5      US'   SUS'   U/n [        R                  S:X  aP  [        U5      (       d@  [        U5      R                  UR                  R                   5      R#                  5       nSU/n[%        U['        U5      -   U[(        R*                  [(        R*                  UR                  R                   S9n/ n/ n	[-        XxR.                  U	R.                  [0        5        SR3                  U5      n
SR3                  U	5      nUR4                  S	:w  a6  [7        U
[8        5      n
[7        U[8        5      n[;        X7R4                  X5      eg! [<         a  n[;        X<5      UeSnAff = f)
a  Run the commit hook of the given name. Silently ignore hooks that do not exist.

:param name:
    Name of hook, like ``pre-commit``.

:param index:
    :class:`~git.index.base.IndexFile` instance.

:param args:
    Arguments passed to hook file.

:raise git.exc.HookExecutionError:
NGIT_INDEX_FILE:
GIT_EDITORwin32zbash.exe)envstdoutstderrcwd r
   )r	   repor8   osaccessX_OKenvironcopyr   strr@   sysplatformrC   r   relative_toworking_diras_posixr   list
subprocessPIPEr   appendr"   r=   
returncoder   r   r   	Exception)r7   rD   rE   hprK   cmdrelative_hpprocessstdout_liststderr_listrL   rM   exs                r>   r   r   G   s    
4++	,B99R!!
**//
C'EJJ8CC$CM<<7"+>r+B+B r(..uzz/E/EFOOQK{+C$t*????

&&
 "$!#g'9'9;;M;MO_`%%"/F/F$R););VLL #  1 (b01s   B-G 
G-G((G-modec                     [        U 5      (       a  [        $ [        U 5      (       d  [        U 5      [        :X  a  [        $ [
        U [        -  =(       a    S=(       d    S-  $ )zVConvert the given mode from a stat call to the corresponding index mode and
return it.i  i  )r   r   r   r   r   r   r   )ri   s    r>   r   r   z   sE     t}}t}}t3dWn.7%88r?   entriesr%   streamextension_dataShaStreamClsc                 6   U" U5      nUR                   nUR                  nSnU" S5        U" [        SU[        U 5      5      5        U  GH(  nU" 5       n	U" UR                  5        U" UR
                  5        [        UR                  5      n
[        U
[        S9n[        U5      [        -  nU[        U5      :X  d   SUR                  -  5       eXR                  [        -  -  nU" [        SUR                  UR                  UR                  UR                   UR"                  UR$                  UR&                  U5	      5        U" U5        U" 5       U	-
  S-   S-  nU" S	X-   U" 5       -
  -  5        GM+     Ub  UR                  U5        UR)                  5         g
)a  Write the cache represented by entries to a stream.

:param entries:
    **Sorted** list of entries.

:param stream:
    Stream to wrap into the AdapterStreamCls - it is used for final output.

:param ShaStreamCls:
    Type to use when writing to the stream. It produces a sha while writing to it,
    before the data is passed on to the wrapped stream.

:param extension_data:
    Any kind of data to write as a trailer, it must begin a 4 byte identifier,
    followed by its size (4 bytes).
      DIRC>LL)encodingz"Path %s too long to fit into index>LLLLLL20sH       N)tellwriter(   lenctime_bytesmtime_bytesrV   r@   r   r   r&   flagsCE_NAMEMASK_INVdevinoderi   uidgidsizebinsha	write_sha)rk   rl   rm   rn   
stream_sharx   ry   versionentrybeginoffsetpath_strr@   plenr}   	real_sizes                  r>   r   r      sn   . f%J??DE G	'N	$ugs7|
,- fe e uzz?!(V<4y;&s4y S"F"SS o56		

				


	
 	dVk)A-3	e/469:;1 8 !( r?   c           	          U R                  S5      nUS:w  a  [        SU-  5      e[        [        [        [        4   [        SU R                  S5      5      5      nUu  p4US;   d
   SU-  5       eX44$ )z>Return tuple(version_long, num_entries) from the given stream.   rq   zInvalid index file header: %rrr   ru   r#   rp   z<Unsupported git index version %i, only 1 and 2 are supported)readAssertionErrorr2   r/   intr)   )rl   type_idunpackedr   num_entriess        r>   read_headerr      sy    kk!nG'<wFGGE#s(OVE6;;u3E%FGH#G ff\_fffr?   r   c                      [        U 5      S:X  a4  U S   n[        U[        5      (       d   eUR                  UR                  4$ [        [        [        [        4   U 5      n U $ )z
:return:
    Key suitable to be used for the
    :attr:`index.entries <git.index.base.IndexFile.entries>` dictionary.

:param entry:
    One instance of type BaseIndexEntry or the path and the stage.
r#   r
   )	rz   
isinstancer$   r@   stager2   r/   r3   r   )r   entry_firsts     r>   r   r      s^     5zQAh+~6666  +"3"344 U8S=)51r?   c                 b   [        U 5      u  pSn0 nU R                  nU R                  nX2:  a  U" 5       n[        SU" S5      5      S   n[        SU" S5      5      S   n	[        SU" S5      5      u  pppnnU[        -  nU" U5      R                  [        5      nU" 5       U-
  S-   S-  nU" UU-   U" 5       -
  5        [        UUUUXXXU45      nUUUUR                  4'   US-  nX2:  a  M  U R                  S5      n[        U5      S	:  d   S
[        U5      -  5       eUSS nUSS nXUU4$ )a  Read a cache file from the given stream.

:return:
    tuple(version, entries_dict, extension_data, content_sha)

    * *version* is the integer version number.
    * *entries_dict* is a dictionary which maps IndexEntry instances to a path at a
      stage.
    * *extension_data* is ``""`` or 4 bytes of type + 4 bytes of size + size bytes.
    * *content_sha* is a 20 byte sha on all cache file contents.
r
   z>8sru   rt   .   rv   r#      zNIndex Footer was not at least a sha on content as it was only %i bytes in sizeiN)
r   r   rx   r)   r&   decoder   r%   r   rz   )rl   r   r   countrk   r   rx   r   ctimemtimer   inori   r   r   r   shar}   	path_sizer@   r   r   rm   content_shas                           r>   r   r      sj    'v.GE8:G;;D;;D

fud1g&q)ud1g&q)7=mTR`Ma7b44ceK'	I%%f-Vk)A-3	kI%/0D#udE#CVZ[\',u{{#$
 
, [[_N~# X[^_m[nn# !&K $DS)Nnk::r?   odbr4   slsir5   c           	      Z   / nUR                   nUR                  nXV:  Ga  X   nUR                  S:w  a  [        U5      eUS-  nUR                  R                  SU5      nUS:X  a6  UR                  UR                  UR                  UR                  US 45        OUR                  X8 n	Un
X:  aE  X
   nUR                  R                  SU5      nUS:X  d  UR                  X< U	:w  a  OU
S-  n
X:  a  ME  [        X[        US-
  U
5      US-   5      u  pUR                  U[        U	45        U
nXV:  a  GM  [        5       n[        XOR                  5        UR                  S5        UR!                  [#        [$        ['        UR)                  5       5      U5      5      nUR                  U4$ )a  Create a tree from the given sorted list of entries and put the respective
trees into the given object database.

:param entries:
    **Sorted** list of :class:`~git.index.typ.IndexEntry`\s.

:param odb:
    Object database to store the trees in.

:param si:
    Start index at which we should start creating subtrees.

:param sl:
    Slice indicating the range we should process on the entries list.

:return:
    tuple(binsha, list(tree_entry, ...))

    A tuple of a sha and a list of tree entries being a tuple of hexsha, mode, name.
r
   r#   /r   N)startstopr   r   r@   findr_   r   ri   r   slicer   r   r    ry   seekstorer   r   rz   getvalue)rk   r   r   r   
tree_itemsciendr   rboundbasexioentryorboundr   _tree_entry_listsioistreams                    r>   r   r   %  s   . (*J	B
''C
(;;!&u--
ab)R<u||UZZBCIJ ::b(DB(  ++**33b=FKK$;t$Ca ( %:'bSTfVXHY[ade[e$f!CsGT23 B; (D )C:yy)HHQKiis3<<>/BCHIGNNJ''r?   
tree_entryr   c                 @    [        U S   U S   U[        -  U S   45      $ )Nr#   r
   rp   )r$   r'   )r   r   s     r>   _tree_entry_to_baseindexentryr   j  s*    :a=*Q--9OQ[\]Q^_``r?   	tree_shasc                    / n[        U5      S;   a3  [        XS   S5       H  nUR                  [        US5      5        M      U$ [        U5      S:  a  [	        S[        U5      -  5      e[        XS5       GH`  u  pEnUGb  UGbD  Ub  US   US   :w  a  US   US   :w  a  US   US   :w  d$  US   US   :w  ak  US   US   :w  a_  US   US   :w  aS  UR                  [        US5      5        UR                  [        US5      5        UR                  [        US5      5        M  US   US   :w  d  US   US   :w  a  UR                  [        US5      5        M  UR                  [        US5      5        M  US   US   :w  d  US   US   :w  a9  UR                  [        US5      5        UR                  [        US5      5        GMP  GMS  Uc  GMY  US   US   :w  d  US   US   :w  a9  UR                  [        US5      5        UR                  [        US5      5        GM  GM  Uc#  Uc   eUR                  [        US5      5        GM  Uc  UR                  [        US5      5        GM  US   US   :w  d  US   US   :w  a9  UR                  [        US5      5        UR                  [        US5      5        GME  UR                  [        US5      5        GMc     U$ )	a  
:return:
    List of :class:`~git.index.typ.BaseIndexEntry`\s representing the aggressive
    merge of the given trees. All valid entries are on stage 0, whereas the
    conflicting ones are left on stage 1, 2 or 3, whereas stage 1 corresponds to the
    common ancestor tree, 2 to our tree and 3 to 'their' tree.

:param tree_shas:
    1, 2 or 3 trees as identified by their binary 20 byte shas. If 1 or two, the
    entries will effectively correspond to the last given tree. If 3 are given, a 3
    way merge is performed.
r   r   rO   r
      zCannot handle %i trees at oncer#   rp   )rz   r   r_   r   
ValueErrorr   )r   r   outr   r   ourstheirss          r>   aggressive_tree_merger   n  s    !#C 9~,SB-DEJJ4UA>? E 
 9~9C	NJKK 7srJF% Q47*tAw&)/CQSYZ[S\H\Q47*tAw&)/CQSYZ[S\H\ 

#@q#IJ

#@q#IJ

#@#KLaDG+tAw$q'/A

#@q#IJ 

#@#KL Aw$q')T!WQ-?

#@q#IJ

#@q#IJ .@ >ayDG+vayDG/C

#@q#IJ

#@#KL 0D |)))

8CD

8qAB 7fQi'47fQi+?JJ<T1EFJJ<VQGH JJ<T1EFC KN Jr?   )r
   )U__doc____all__ior   rQ   os.pathr@   r<   pathlibr   statr   r   r   r   r   r   r   r]   rW   
gitdb.baser   	gitdb.typr   git.cmdr   r   
git.compatr   r   r   r   git.excr   r   git.objects.funr   r   r    git.utilr!   r"   typr$   r%   r&   r'   utilr(   r)   typingr*   r+   r,   r-   r.   r/   r0   r1   r2   	git.typesr3   git.dbr4   git.objects.treer5   r   r6   r   r~   rV   r	   rC   r   r   r   bytesr   r   r   r   r   r   r   r    r?   r>   <module>r      sm  	  	   M M M  
  # 6 C C < 
 ; G G  U T T %-  ,,C ,( ,s ,
!c !c !/M# /Mk /M# /M$ /Mf9# 9# 9 *..A	BeNL89:BuIB $+&B *+	B
 
BJ
 5	 
 eCHo 
 eNHc9: uXs]?S 04;uI4;
3U8S=)<78%FG4;p LMB(*B($4B(:?B(EHB(
5$~&&'B(Jan aS a^ ac/ cHUO cPTUcPd cr?   