(~<ddlmZddlmZmZmZmZddlmZ ddl m Z ddl mZddlmZmZmZddlmZmZmZer$ddlmZdd lmZdd lmZdd lmZdd lm Z dd l!m"Z"edZ#dZ$dZ%GddeZ&Gdde&Z'dS))WorkTreeRepositoryUnsupported) LazyMixinjoin_path_native stream_copy bin_to_hexN)get_object_type_by_name)Any TYPE_CHECKINGUnion)PathLike Commit_ishLit_commit_ish)Repo)OStream)Tree)Blob) Submodule) Reference)rrrzSCreated object %r whose python type %r disagrees with the actual git object type %r)Object IndexObjectcxeZdZUdZdZdZejejej ej fZ dZ dZ eedfed<ddd effd Zeddd eed fd efdZeddded efdZded dffd Zded efdZded efdZd efdZd efdZd efdZ e!d efdZ"e!ddZ#ddZ$xZ%S) rz@Implements an Object which may be Blobs, Trees, Commits and Tags(0000000000000000000000000000000000000000s)repobinshasizeNtyperrrctt|||_||_t |dksJd|t |fzdS)zInitialize an object by identifying it by its binary sha. All keyword arguments will be set on demand if None. :param repo: repository this object is located in :param binsha: 20 byte SHA1z,Require 20 byte binary sha, got %r, len = %iN)superr__init__rrlen)selfrr __class__s /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/base.pyr!zObject.__init__8sl fd$$&&&  6{{b   "P  KKT #      idrreturncF|t|S)a :return: New Object instance of a type appropriate to the object type behind id. The id of the newly created object will be a binsha even though the input id may have been a Reference or Rev-Spec :param id: reference, rev-spec, or hexsha :note: This cannot be a __new__ method as it would always call __init__ with the input id which is not necessarily a binsha.) rev_parsestr)clsrr's r%newz Object.newGs~~c"gg&&&r&sha1c||jkrtd||S|j|}t|j||j}|j|_|S)z :return: new object instance of a type appropriate to represent the given binary sha1 :param sha1: 20 byte binary sha1scommit) NULL_BIN_SHAr odbinforrr)r,rr.oinfoinsts r% new_from_shazObject.new_from_shaTsl 3# # #5*955dDAA A d##2&uz224FFJ  r&attrc|dkr2|jj|j}|j|_dSt t ||dS)zRetrieve object informationrN)rr1r2rrr r _set_cache_)r#r6r3r$s r%r8zObject._set_cache_csX 6>>IM&&t{33E DIII &$   + +D 1 1 1 1 1r&othercFt|dsdS|j|jkS)z/:return: True if the objects have the same SHA1rFhasattrrr#r9s r%__eq__z Object.__eq__ls(uh'' 5{el**r&cFt|dsdS|j|jkS)z6:return: True if the objects do not have the same SHA1rTr;r=s r%__ne__z Object.__ne__rs(uh'' 4{el**r&c*t|jS)zE:return: Hash of our id allowing objects to be used in dicts and sets)hashrr#s r%__hash__zObject.__hash__xsDK   r&c|jS)z=:return: string of our SHA1 as understood by all git commands)hexsharCs r%__str__zObject.__str__|s {r&c2d|jjd|jdS)z::return: string with pythonic representation of our objectz)r$__name__rFrCs r%__repr__zObject.__repr__s "&."9"9"94;;;GGr&cPt|jdS)z6:return: 40 byte hex version of our 20 byte binary shaascii)rrdecoderCs r%rFz Object.hexshas"$+&&--g666r&rcJ|jj|jS)z:return: File Object compatible stream to the uncompressed raw data of the object :note: returned streams must be read in order)rr1streamrrCs r% data_streamzObject.data_streamsy}##DK000r&ostreamcn|jj|j}t |||S)zWrites our data directly to the given output stream :param ostream: File object compatible stream object. :return: self)rr1rOrr)r#rQistreams r% stream_datazObject.stream_datas2 )-&&t{33GW%%% r&)r(r)rQrr(r)&rI __module__ __qualname____doc__ NULL_HEX_SHAr0dbtyp str_blob_type str_tree_typestr_commit_type str_tag_typeTYPES __slots__rr r__annotations__bytesr! classmethodr+rr-r5r8r boolr>r@intrDrGrJpropertyrFrPrT __classcell__r$s@r%rr(s4JJLL      E +I(,D%$ %,,,  V  U        'v '5k)9#: 'z ' ' '[ '  e    [ 22222222+C+D++++ +C+D++++ !#!!!!H#HHHH7777X7 111X1 r&rc eZdZdZdZdZ ddddededefdede fd df fd Z d efd Z d e d dffd Z ed e fdZed e fdZxZS)rzeBase for all objects that can be part of the index file , namely Tree, Blob and SubModule objects)pathmoderiNrrrrjr(ctt||||||_| ||_dSdS)aJInitialize a newly instanced IndexObject :param repo: is the Repo we are located in :param binsha: 20 byte sha1 :param mode: is the stat compatible file mode as int, use the stat module to evaluate the information :param path: is the path to the file in the file system, relative to the git repository root, i.e. file.ext or folder/other.ext :note: Path may not be set of the index object has been created directly as it cannot be retrieved without knowing the parent tree.N)r rr!rjri)r#rrrjrir$s r%r!zIndexObject.__init__sK( k4  ))$777  DI  DIII  r&c*t|jS)z :return: Hash of our path as index items are uniquely identifiable by path, not by their data !)rBrirCs r%rDzIndexObject.__hash__s DIr&r6c|tjvr(td|dt|jdt t||dS)Nz Attribute 'z<' unset: path and mode attributes must have been set during z object creation)rr_AttributeErrorrrIr r8)r#r6r$s r%r8zIndexObject._set_cache_sh ;( ( ( .44d,,,.  +t $ $ 0 0 6 6 6 6 6r&c4tj|jS)zA:return: Name portion of the path, effectively being the basename)ospbasenamerirCs r%namezIndexObject.names|DI&&&r&cv|jjt|jj|jSt d)a  :return: Absolute path to this index object in the file system ( as opposed to the .path field which is a path relative to the git repository ). The returned path will be native to the system and contains '' on windows.Nz"Working_tree_dir was None or empty)rworking_tree_dirrrirrCs r%abspathzIndexObject.abspaths5 9 % 1#DI$> JJ J/0TUU Ur&)NN)rIrUrVrWr__id_attribute_rar rdr r!rDr+r8rerrrurfrgs@r%rrsB!IN "&&* D#I  D(N#   4#77777777'c'''X' V V V VX V V V V Vr&r)(git.excrgit.utilrrrr gitdb.typtyprYos.pathrirputilr typingr r r git.typesr rrgit.repor gitdb.basertreerblobrsubmodule.basergit.refs.referencer IndexObjUnion_assertion_msg_format__all__rrr&r%rs211111IIIIIIIIIIII)))))) -,,,,,,,,,::::::::::-"""""")))))),,,,,,12 n #oooooYooodFVFVFVFVFV&FVFVFVFVFVr&