umsddlZddlmZddlmZddlmZmZddlm Z ddl m Z ddl m Z mZmZmZmZmZmZmZmZmZmZdd lmZmZer$dd lmZdd lmZdd lm Z dd l!m"Z"ddl#m$Z$ddl%m&Z&edZ'dZ(e)Z*ej+dZ,dede-fdZ.d"de-de/dee-fdZ0Gdde)Z1eddZ2Gdd ee2Z3Gd!de)Z4dS)#N)handle_process_output)defenc)finalize_process hex_to_bin)Blob)mode_str_to_int) AnyIteratorListMatchOptionalTupleTypeTypeVarUnion TYPE_CHECKINGcast)PathLikeLiteral)Tree)Commit)Repo) IndexObject)Popen)Git)ADCMRTU)Diffable DiffIndexDiff NULL_TREEs \\([0-9]{3})matchobjreturnc|d}t|d}tt|f}|S)Nr)groupintbytes bytearray)r(values /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/git/diff.py _octal_replr2;s< NN1  E qMME )UH%% & &E LTpath has_ab_prefixc|dkrdS|dro|drZ|ddddddd dd d }tt |}|r6|d s|d sJ|dd}|S)Ns /dev/null"rs\n s\t s\"s\\\sa/sb/) startswithendswithreplace_octal_byte_resubr2)r4r5s r1 decode_pathrBBs |t tvt!4!4vAbDz!!&%0088GGOOPVX\]]eefmotuu   k4 0 0Du%%?)?)????ABBx Kr3c eZdZdZdZGddeZdeee de defdeee de deffdZ ed d fd ee dd d d e efdee ee e e dfd fdededdf dZd S)r$zCommon interface for all object that can be diffed against another object of compatible type. :note: Subclasses require a repo member as it is the case for Object instances, for practical reasons we do not derive from Object.ceZdZdS)Diffable.IndexN)__name__ __module__ __qualname__rDr3r1IndexrF]s r3rJargsrFr)c|S)z :return: possibly altered version of the given args list. Method is called right before git command execution. Subclasses can use it to alter the behaviour of the superclassrD)selfrKs r1_process_diff_argszDiffable._process_diff_args`s  r3NFotherrrpaths. create_patchkwargsr%c g}|d|dtfddDs|d|r|dn*|d|d|d |t|ttfs|g}t |d r |j|_|jjj}||j ur| d d n|tur>| d d| d d|jjj }n?|=| d d| d ||jjj }| d ||r*|d| |dd<|||i}|r tjn tj}||j|} || S)aCreates diffs between two items being trees, trees and index or an index and the working tree. It will detect renames automatically. :param other: Is the item to compare us with. If None, we will be compared to the working tree. If Treeish, it will be compared against the respective tree If Index ( type ), it will be compared against the index. If git.NULL_TREE, it will compare against the empty tree. It defaults to Index to assure the method will not by-default fail on bare repositories. :param paths: is a list of paths or a single path to limit the diff to. It will only include at least one of the given path or paths. :param create_patch: If True, the returned Diff contains a detailed patch that if applied makes the self to other. Patches are somewhat costly as blobs have to be read and diffed. :param kwargs: Additional arguments passed to git-diff, such as R=True to swap both sides of the diff. :return: git.DiffIndex :note: On a bare repository, 'other' needs to be provided as Index or as as Tree/Commit, or a git command error will occurz --abbrev=40z --full-indexc3 K|]}|vV dSNrD).0xrRs r1 z Diffable.diff..s'LL11;LLLLLLr3) find_renames no_renamesr z-Mz-pz--rawz-zz --no-colorNHas_Reporz--cachedz-rz--rootz--T as_process)appendany isinstancetuplelisthasattrrepogitdiffrJinsertr' diff_treeextendrNr&_index_from_patch_format_index_from_raw_formatwait) rMrOrPrQrRrKdiff_cmdproc diff_methodindexs ` r1rez Diffable.diffjsPJQS M""" N###LLLL(KLLLLL  KK      KK     KK KK    L!!!  Zt}%E%E GE 4 $ $ * $ DI9=% DJ   KK: & & & & i   KK4 KK8 $ $ $y}.HH   KK4 KK5 ! ! !y}.H At   KK    KK    $|x0066A&AA7Cdd33Id  DIt,,  r3)rGrHrI__doc__ __slots__objectrJr rstrrrNrrboolr rerDr3r1r$r$Rs811 I        sJ5E0FNOP eCT*:%;VCD ELQMQ" XXT']FHdCGHXXtH~uXs]/CTIJX X  X  XXXXXXr3r$T_Diffr&)boundc2eZdZdZdZdedeefdZdS)r%zImplements an Index for diffs, allowing a list of Diffs to be queried by the diff properties. The class improves the diff handling convenience)rrrr!r r" change_typer)c#JK||jvrtd|z|D]}|j|kr|V|dkr |jr|V$|dkr |jr|V6|dkr |jr|VH|dkr |jr|VZ|dkr"|jr|jr|j|jkr|VdS)a :return: iterator yielding Diff instances that match the given change_type :param change_type: Member of DiffIndex.change_type, namely: * 'A' for added paths * 'D' for deleted paths * 'R' for renamed paths * 'M' for paths with modified data * 'T' for changed in the type paths zInvalid change type: %srrrr!r N)rx ValueErrornew_file deleted_file copied_filerenameda_blobb_blob)rMrxdiffidxs r1iter_change_typezDiffIndex.iter_change_types d. . .6DEE E  G"k11 ##(8# ##(<# ##(;# ### ###7>#gn`g`nNnNn   r3N) rGrHrIrprxLit_change_typer rurrDr3r1r%r%sL881KO@Pr3r%c eZdZdZejdejejzZdZ dZ dZ ddde e d e e d eee d fd eee d fd ee ed fdee ed fdededede e de e deee d fde ede edd f dZdedefdZdedefdZdefdZdefdZede efdZede efdZede efd Zede efd!Zedefd"Zedefd#Ze d$e d%e d&e de e fd'Z!e ddd(ed)de"fd*Z#e$d+e ddd,e"dd fd-Z%e d1d0Z&d S)2r&aA Diff contains diff information between two Trees. It contains two sides a and b of the diff, members are prefixed with "a" and "b" respectively to inidcate that. Diffs keep information about the changed blob objects, the file mode, renames, deletions and new files. There are a few cases where None has to be expected as member variable value: ``New File``:: a_mode is None a_blob is None a_path is None ``Deleted File``:: b_mode is None b_blob is None b_path is None ``Working Tree Blobs`` When comparing to working trees, the working tree blob will have a null hexsha as a corresponding object does not yet exist. The mode will be null as well. But the path will be available though. If it is listed in a diff the working tree version of the file must be different to the version in the index or tree, and hence has been modified.s ^diff[ ]--git [ ](?P"?[ab]/.+?"?)[ ](?P"?[ab]/.+?"?)\n (?:^old[ ]mode[ ](?P\d+)\n ^new[ ]mode[ ](?P\d+)(?:\n|$))? (?:^similarity[ ]index[ ]\d+%\n ^rename[ ]from[ ](?P.*)\n ^rename[ ]to[ ](?P.*)(?:\n|$))? (?:^new[ ]file[ ]mode[ ](?P.+)(?:\n|$))? (?:^deleted[ ]file[ ]mode[ ](?P.+)(?:\n|$))? (?:^similarity[ ]index[ ]\d+%\n ^copy[ ]from[ ].*\n ^copy[ ]to[ ](?P.*)(?:\n|$))? (?:^index[ ](?P[0-9A-Fa-f]+) \.\.(?P[0-9A-Fa-f]+)[ ]?(?P.+)?(?:\n|$))? (?:^---[ ](?P[^\t\n\r\f\v]*)[\t\r\f\v]*(?:\n|$))? (?:^\+\+\+[ ](?P[^\t\n\r\f\v]*)[\t\r\f\v]*(?:\n|$))? (0000000000000000000000000000000000000000s)rra_modeb_mode a_rawpath b_rawpathr{r|r}raw_rename_from raw_rename_torerxscorercrrr a_blob_idN b_blob_idrrr{r|r}rrrerxrr)c|t|tsJ|t|tsJ||_||_|rt |nd|_|rt |nd|_|rZ|rX|jD]P}|j| tdkr*| r| }nQ|| ||j krd|_n/t|t!||j|j|_|| ||j krd|_n/t|t!||j|j|_||_| |_| |_| t| tsJ| t| tsJ| pd|_| pd|_| |_||_||_dS)Nr?)moder4)r_r.rrr rr submodulesr4decoder module_existsmodule NULL_HEX_SHArrra_pathrb_pathr{r|r}rrrerxr)rMrcrrrrrrr{r|r}rrrerxr submodules r1__init__z Diff.__init__Cs& Jy%$@$@  @ Jy%$@$@  @""17Aof---T 17Aof---T   I !_   >Y%5%5fi%H%HHH ..002(//11EI /   T-> > >DKKtZ %:%:SWS^___DK /   T-> > >DKKtZ %:%:SWS^___DK& ".!,&*_e*L*L&&L$ =%(H(H$$H.6$*2d 9D r3rOcd|jD]'}t||t||krdS(dS)NFT)rqgetattr)rMrOnames r1__eq__z Diff.__eq__sEN  DtT""geT&:&:::uu;tr3c||k SrUrD)rMrOs r1__ne__z Diff.__ne__sEM""r3c^ttfdjDS)Nc38K|]}t|VdSrU)r)rVnrMs r1rXz Diff.__hash__..s-CCq'$**CCCCCCr3)hashr`rqrMs`r1__hash__z Diff.__hash__s0ECCCCDNCCCCCDDDr3cd}|jr||jjz}n|jr||jjz}d}d}d}t|j|jfdD]A\}}|rd||j|jfz}nd|z}t t||}||z }B|dd|zzz }|jr|d z }|j r|d z }|j r|d |j d |j z }|j r |d |j zz }|jr |d|jzz }|jrd|dz } |t!|jt"r|jt&n|jz }n#t($r|dz }YnwxYw|dz }||z}|S)Nz%sr)lhsrhsz %s: %o | %sz %s: None =z file deleted in rhsz file added in rhsz file z copied from z file renamed from %rz file renamed to %rz ---zOMITTED BINARY DATA)rr4rziprhexshamaxlenr|r{r}rr rename_from rename_torer_r.rrUnicodeDecodeError)rMhmsgline line_lengthbrress r1__str__z Diff.__str__s ; " ! !AA [ " ! !A dk2NCC  DAq (&!QVQX)>>#a'c$ii55K 4KCC TC+% %%   + * *C = ) ( (C   K CdkkJ JC   ? +d.>> >C > ; )DN: :C 9  7NC -:di3O3O^ty''///UYU^^% - - -,, - 7NC #g sAE EEcT|jr |jtdndSNr?)rrrrs r1rz Diff.a_path&;?>St~$$VY777tSr3cT|jr |jtdndSr)rrrrs r1rz Diff.b_pathrr3cT|jr |jtdndSr)rrrrs r1rzDiff.rename_froms)AEAU_t#**69===[__r3cT|jr |jtdndSr)rrrrs r1rzDiff.rename_tos)?C?Q[t!((;;;W[[r3c|jS)z:returns: True if the blob of our diff has been renamed :note: This property is deprecated, please use ``renamed_file`` instead. ) renamed_filers r1r~z Diff.renameds   r3c"|j|jkS)z7:returns: True if the blob of our diff has been renamed)rrrs r1rzDiff.renamed_files4>11r3 path_match rename_matchpath_fallback_matchcp|rt|S|rt|dS|rt|SdS)NF)r5)rB)clsrrrs r1_pick_best_pathzDiff._pick_best_pathsP  +z** *  B|5AAA A  4233 3tr3rm)rzGit.AutoInterruptcg}t||jdtdd|}t }d}d}d\}} d\} } |j|D]n} | \} }}}}}}}}}}} }} t|t|t|}}}| ||| }| | ||} |9|| | |d_ |p |p|o| p|p|} | p|p|p| o| } |t||| |o|t|o|t| o| t| o| t|||||ddd| }| }p|r)|r'|| d|d_ |S)aCreate a new DiffIndex from the given text which must be in patch format :param repo: is the repository we are operating on - it is required :param stream: result of 'git diff' as a stream (supporting file protocol) :return: git.DiffIndexNFdecode_streamsr3)NNr8)rr]rjoinr% re_headerfinditergroupsrtrendstartrer&rr)rrcrm text_listtextroprevious_headerheaderrrrr_headera_path_fallbackb_path_fallbackold_modenew_moderr new_file_modedeleted_file_modecopied_file_namerrr{r|r}s r1rizDiff._index_from_patch_formats^"$ dI$4d)>& J#**622#**622##)-FA)>)>& J#**622#**622)/Y ##D" LL    CA A r3rr%cdtt|fddtdS)zhCreate a new DiffIndex from the given stream which must be in raw format. :return: git.DiffIndexc2|SrU)r)bytrrorcs r1z-Diff._index_from_raw_format..s--c4??r3NFr)r%rr)rrcrmros`` @r1rjzDiff._index_from_raw_formatsL'[[  ? ? ? ? ? ?        r3)rcrrmrr)r%)'rGrHrIrprecompileVERBOSE MULTILINErr NULL_BIN_SHArqrr.rrsrtrr-rrrrrrrpropertyrrrrr~r classmethodrr%ri staticmethodrrjrDr3r1r&r&sZZ>  $ R\!'I,LLI"<<E?<E? < eT)* < eT)* <eS$&'<eS$&'<<<<"%< <C$%<o.< }!<" #<<<<|Ft#F#t####E#EEEE/////bT TTTXTT TTTXT`Xc]```X`\8C=\\\X\!!!!X! 2d222X2  e Z_ dlmrds   [ QFQ%@\:]QbkQQQ[QfGuGFG9GQUGGG\GR[r3)T)5rgit.cmdr git.compatrgit.utilrr objects.blobr objects.utilr typingr r r r rrrrrrr git.typesrr objects.treerobjectsr git.repo.basergit.objects.baser subprocessrrdrr__all__rrr'rr@r.r2rtrBr$rur%r&rDr3r1r s ))))))11111111))))))                          ('''''''"""""""""""",,,,,,      ;< 9 FHH -..%E  e D HUO     pppppvpppf  ( ( (,,,,,V ,,,`^^^^^6^^^^^r3