
    ch"                        S r / SQrSSKJr  SSKJrJr  SSKJrJ	r	J
r
JrJrJrJrJr  \(       a  SSKJr  SSKJr  \\\\4   r\\S4   rS	\\   S
\S/\\S4   4   SS4S jrS\S\	\   4S jrS\
\   S\S\S\S\4
S jr\SSS\SS4S j5       r\S\S\S\4S j5       rS\S\S\4S jrSSS\\\S4      S\S\	\\S4      4S jrSSS\S\S\	\   4S  jrg)!z6Functions that are supposed to be as fast as possible.)tree_to_streamtree_entries_from_datatraverse_trees_recursivetraverse_tree_recursive    )S_ISDIR)safe_decodedefenc)CallableListMutableSequenceSequenceTupleTYPE_CHECKINGUnionoverload)ReadableBuffer)GitCmdObjectDBNentrieswriter   returnc           
      @   [        S5      nSnU  H  u  pEnSn[        S5       H  n[        XXS-  -	  U-  U-   /5      U-   nM     US   U:X  a  USS n[        U[        5      (       a  UR                  [        5      n	OUn	U" SR                  US	U	S
U45      5        M     g)zWrite the given list of entries into a stream using its ``write`` method.

:param entries:
    **Sorted** list of tuples with (binsha, mode, name).

:param write:
    A ``write`` method which takes a data string.
0             r      N        )ordrangebytes
isinstancestrencoder	   join)
r   r   ord_zerobit_maskbinshamodenamemode_stri
name_bytess
             bC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\git/objects/fun.pyr   r   )   s     3xHH%dqAQ8;xGHIHTH 
 A;("|H dC  V,JJchh$
E6BCD) &r   datac                 V   [        S5      n[        S5      n[        U 5      nSn/ nXC:  a~  SnX   U:w  a  US-  X   U-
  -   nUS-  nX   U:w  a  M  US-  nUnX   S:w  a  US-  nX   S:w  a  M  XU n[        U5      n	US-  nXUS-    n
US-   nUR                  XU	45        XC:  a  M~  U$ )zRead the binary representation of a tree and returns tuples of
:class:`~git.objects.tree.Tree` items.

:param data:
    Data block with tree data (as bytes).

:return:
    list(tuple(binsha, mode, tree_relative_path), ...)
r    r   r   r      )r    lenr   append)r0   r'   	space_ordlen_datar-   outr*   nsr.   r+   shas              r/   r   r   M   s     3xHCI4yH	A
C
,
 g" AI$'H"45DFA	 g" 	
Q glFA gl QZ
:& 	
Qq2vF

Ct$%A ,D Jr   	tree_datar+   is_dirstart_atc                     X   nU(       a!  US   U:X  a  [        US   5      U:X  a  SX'   U$ [        U 5       H3  u  pTU(       d  M  US   U:X  d  M  [        US   5      U:X  d  M-  SX'   Us  $    g! [         a     NOf = f)zReturn data entry matching the given name and tree mode or ``None``.

Before the item is returned, the respective data item is set None in the `tree_data`
list to mark it done.
   r   N)r   
IndexError	enumerate)r;   r+   r<   r=   itemindexs         r/   _find_by_namerD      s    "DGtOQ(8F(B"&IK !+4DGtOQ(8F(B#IK ,   s   +A1 1
A>=A>rB   path_prefixc                     g N rB   rE   s     r/   _to_full_pathrJ      s    9<r   c                     g rG   rH   rI   s     r/   rJ   rJ      s    ADr   c                 4    U (       d  U $ U S   U S   XS   -   4$ )z%Rebuild entry with given path prefix.r   r   r?   rH   rI   s     r/   rJ   rJ      s&    GT!WkG344r   odbr   	tree_shas.c                   ^ / n[        U5      nU HK  nUc  / nO1[        [        U R                  U5      R	                  5       5      5      nUR                  U5        MM     / n[        U5       GH   u  p[        U	5       H  u  pU(       d  M  [        U5       Vs/ s H  nSPM     nnXU'   Uu  pn[        U5      n[        US-   X-   5       H  nUU-  n[        UU   UUU
5      UU'   M     U(       aI  UR                  [        U U Vs/ s H  nU=(       a    US   =(       d    SPM     snTU-   S-   5      5        O$UR                  [        U4S jU 5       5      5        SX'   M     U	SS2	 GM     U$ s  snf s  snf )a  
:return:
    List of list with entries according to the given binary tree-shas.

    The result is encoded in a list
    of n tuple|None per blob/commit, (n == len(tree_shas)), where:

    * [0] == 20 byte sha
    * [1] == mode as int
    * [2] == path relative to working tree root

    The entry tuple is ``None`` if the respective blob/commit did not exist in the
    given tree.

:param tree_shas:
    Iterable of shas pointing to trees. All trees must be on the same level.
    A tree-sha may be ``None``, in which case ``None``.

:param path_prefix:
    A prefix to be added to the returned paths on this level.
    Set it ``""`` for the first iteration.

:note:
    The ordering of the returned items will be partially lost.
Nr   r   /c              3   <   >#    U  H  n[        UT5      v   M     g 7frG   )rJ   ).0erE   s     r/   	<genexpr>+traverse_trees_recursive.<locals>.<genexpr>   s      P1q+!>!>s   )r4   listr   streamreadr5   rA   r!   r   rD   extendr   tuple)rM   rN   rE   
trees_datanttree_shar0   r8   tir;   iirB   _r   _shar*   r+   r<   tioeis     `                 r/   r   r      s   8 .0J	YB)+D .szz(/C/H/H/JKLD$  -/C
 #:.!),HB &+2Y/YtYG/BK#DT]F
 R!VRW-Bh,Z_dFBO . 

,<CDGb2<"Q%0D0GD#d*S0 

5 P PPQ !IMA -H aLK /N JC 0$ Es   E4!E9r]   c           	          / n[        U R                  U5      R                  5       5      nU HM  u  pVn[        U5      (       a"  UR	                  [        XX'-   S-   5      5        M8  UR                  XVX'-   45        MO     U$ )a  
:return:
    List of entries of the tree pointed to by the binary `tree_sha`.

    An entry has the following format:

    * [0] 20 byte sha
    * [1] mode as int
    * [2] path relative to the repository

:param path_prefix:
    Prefix to prepend to the front of all returned paths.
rP   )r   rW   rX   r   rY   r   r5   )rM   r]   rE   r   r0   r:   r*   r+   s           r/   r   r      sv     G!#**X"6";";"=>D  44==NN23[=ORU=UVWNNC{'9:;	   Nr   ) __doc____all__statr   
git.compatr   r	   typingr
   r   r   r   r   r   r   r   	_typeshedr   gitr   r"   intr$   EntryTupEntryTupOrNoner   r   boolrD   rJ   r   r   rH   r   r/   <module>rp      s   =  *	 	 	 ("S!x~&
 EHX.  ExAQ@RTYZ]_cZcTd@d7e  Ejn  EH1 14> 1h_^< C QU ad iw 0 
 < <3 <4 < 
 < 
 D Ds Dx D 
 D5 5S 5^ 5U	U&.uUD[/A&BUQTU	%#
$%Up!1 U QT Y]^fYg r   