2uˬ dZddlmZddlmZmZddlmZmZm Z m Z m Z m Z m Z mZe r ddlmZddlmZe eeefZe edfZdZd e ed ed ge edffd dfd Zded eefdZde edededed ef dZeddded dfdZededed efdZdeded efdZddde e edfded ee edffdZdddeded eefd ZdS)!zBModule with functions which are supposed to be as fast as possible)S_ISDIR) safe_decodedefenc)CallableListMutableSequenceSequenceTuple TYPE_CHECKINGUnionoverload)ReadableBuffer)GitCmdObjectDBN)tree_to_streamtree_entries_from_datatraverse_trees_recursivetraverse_tree_recursiveentrieswriterreturnc vtd}d}|D]\}}}d}tdD]!}t||dzz |z|zg|z}"|d|kr |dd}t|tr|t } n|} |d|d | d |fdS) zWrite the give list of entries into a stream using its write method :param entries: **sorted** list of tuples with (binsha, mode, name) :param write: write method which takes a data string0rN )ordrangebytes isinstancestrencoderjoin) rrord_zerobit_maskbinshamodenamemode_stri name_bytess /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/git/objects/fun.pyrr&s 3xxHH%EEdq U UAQ8;xGHIIHTHH A;( " "|H dC  V,,JJJ chh$ E6BCCDDDD)EErdatactd}td}t|}d}g}||krd}|||kr"|dz|||z z}|dz }|||k"|dz }|}||dkr|dz }||dk|||}t|} |dz }|||dz} |dz}|| || f||k|S)zReads the binary representation of a tree and returns tuples of Tree items :param data: data block with tree data (as bytes) :return: list(tuple(binsha, mode, tree_relative_path), ...)r rrr)r lenrappend) r0r' space_ordlen_datar-outr*nsr.r+shas r/rrFs' 3xxHCI4yyH A C h,, 1g""AI$q'H"45D FA 1g"" Q1gll FA1gll "Q$Z :&& Q1q2v: F Ct$%%%A h,,D Jr tree_datar+is_dirstart_atc  ||}|r,|d|kr t|d|krd||<|Sn#t$rYnwxYwt|D]5\}}|r.|d|kr"t|d|kr d||<|cS6dS)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 donerN)r IndexError enumerate)r;r+r<r=itemindexs r/ _find_by_namerDus  "  DGtOOQ(8(8F(B(B"&Ih K      !++ t  DGtOOQ(8(8F(B(B#Ie KKK 4s59 AArB path_prefixcdSNrBrEs r/ _to_full_pathrJCrcdSrGrHrIs r/rJrJrKrc>|s|S|d|d||dzfS)z$Rebuild entry with given path prefixrrr?rHrIs r/rJrJs-  GT!WkDG3 44rodbr tree_shas.c g}t|}|D]]}|g}nAtt||}||^g}t |D]\}} t | D]\} } | sdt|D} | | |<| \} }}t|}t|dz||zD]"}||z}t||||| | |<#|r5| t|d| D|zdzn.|tfd| Dd| | <| dd=|S)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 lostNcg|]}dSrGrH).0_s r/ z,traverse_trees_recursive..s///t///rrc&g|]}|r|dpdS)rNrH)rReis r/rTz,traverse_trees_recursive..s%DDDb2<"Q%0DDDDr/c38K|]}t|VdSrG)rJ)rRerEs r/ z+traverse_trees_recursive..s- P P1q+!>!> P P P P P Pr) r4listrstreamreadr5rAr!rrDextendrtuple)rNrOrE trees_datanttree_shar0r8tir;iirBr_shar*r+r<tios ` r/rrs".0J YB    )+DD.szz(/C/C/H/H/J/JKKLLD$-/C #:..&& I!),, ! !HB 0/U2YY///GGBK# D$T]]F R!VR"W-- P PBh,Z_dFBOO  R ,DDGDDD#d*S0 5 P P P P P P PPPQQQ!IbMM aaaLL Jrrbc .g}t||}|D][\}}}t|r+|t ||||zdz@|||||zf\|S)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 pathsrW)rr\r]rr^rr5)rNrbrErr0r:r*r+s r/rrsG !#**X"6"6";";"="= > >D <<T4 4== < NN23[4=ORU=UVV W W W W NNC{T'9: ; ; ; ; Nr) __doc__statr git.compatrrtypingrrrr r r r r _typeshedrgitrr"intr$EntryTupEntryTupOrNone__all__rrboolrDrJrrrHrr/rssHH+*******                    #(((((("""""" S !x~&  EHX.ExAQ@RTYZ]_cZcTd@d7eEjnEEEE@,,4>,,,,^_^<CQUadiw. 34  sx 55S5^5555K K&.uUD[/A&BKQTK %# $%KKKK\!1UQTY]^fYgr