HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/git/__pycache__/diff.cpython-310.pyc
o

;j$j�@s�Ugd�ZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZmZmZmZmZmZmZmZmZmZmZdd	lmZmZerydd
lmZddlm Z ddl!m"Z"dd
l#m$Z$ddl%m&Z&ddl'm(Z(edZ)ej*Gdd�dej+��Z,e,j-Z-ee,j-e.d<	e,j/Z/ee,j/e.d<	e�0d�Z1dede2fdd�Z3d'de2de4dee2fdd�Z5Gdd �d �Z6ed!d"d#�Z7Gd$d%�d%ee7�Z8Gd&d"�d"�Z9dS)()�
DiffConstants�	NULL_TREE�INDEX�Diffable�	DiffIndex�Diff�N)�handle_process_output)�defenc)�Blob)�mode_str_to_int)�finalize_process�
hex_to_bin)�Any�Iterator�List�Match�Optional�Sequence�Tuple�
TYPE_CHECKING�TypeVar�Union�cast)�PathLike�Literal)�Popen)�Git)�IndexObject)�Commit)�Tree)�Repo)�A�D�C�M�R�T�Uc@s"eZdZdZe��Z	e��ZdS)raySpecial objects for :meth:`Diffable.diff`.

    See the :meth:`Diffable.diff` method's ``other`` parameter, which accepts various
    values including these.

    :note:
        These constants are also available as attributes of the :mod:`git.diff` module,
        the :class:`Diffable` class and its subclasses and instances, and the top-level
        :mod:`git` module.
    N)�__name__�
__module__�__qualname__�__doc__�enum�autorr�r.r.�</opt/saltstack/salt/lib/python3.10/site-packages/git/diff.pyr1srrrs\\([0-9]{3})�matchobj�returncCs&|�d�}t|d�}tt|f��}|S)N��)�group�int�bytes�	bytearray)r0�valuer.r.r/�_octal_replcs

r9T�path�
has_ab_prefixcCs�|dkrdS|�d�r&|�d�r&|dd��dd��dd��d	d��d
d�}t�t|�}|r@|�d�s:|�d
�s:J�|dd�}|S)Ns	/dev/null�"r2���s\n�
s\t�	s\"s\\�\sa/sb/�)�
startswith�endswith�replace�_octal_byte_re�subr9)r:r;r.r.r/�decode_pathjs,rGc@s�eZdZUdZdZded<	eZ	eZ	eZ	de	e
edfde	e
edffdd�Zed	d
fde
e
dd
ed	fde
ee	eeedfd	fdededdf
dd�Zd	S)raGCommon interface for all objects that can be diffed against another object of
    compatible type.

    :note:
        Subclasses require a :attr:`repo` member, as it is the case for
        :class:`~git.objects.base.Object` instances. For practical reasons we do not
        derive from :class:`~git.objects.base.Object`.
    r.r �repo�argsr1cCs|S)z�
        :return:
            Possibly altered version of the given args list.
            This method is called right before git command execution.
            Subclasses can use it to alter the behaviour of the superclass.
        r.)�selfrIr.r.r/�_process_diff_args�s
zDiffable._process_diff_argsNF�otherrr�paths.�create_patch�kwargs�DiffIndex[Diff]c
sjg}|�d�|�d�t�fdd�dD��s|�d�|r)|�d�|�d�n
|�d	�|�d
�|�d�|durFt|ttf�sF|g}|jjj}|turV|�	d
d�n+|t
url|�	d
d�|�	d
d�|jjj}n|dur�|�	d
d�|�	d
|�|jjj}|�	d
|�|r�|�d�|�|�d�d<||�
|�i���}|r�tjntj}||j|�}	|��|	S)aCCreate diffs between two items being trees, trees and index or an index and
        the working tree. Detects renames automatically.

        :param other:
            This the item to compare us with.

            * If ``None``, we will be compared to the working tree.

            * If a :class:`~git.types.Tree_ish` or string, it will be compared against
              the respective tree.

            * If :const:`INDEX`, it will be compared against the index.

            * If :const:`NULL_TREE`, it will compare against the empty tree.

            This parameter defaults to :const:`INDEX` (rather than ``None``) so that the
            method will not by default fail on bare repositories.

        :param paths:
            This 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 :class:`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 :manpage:`git-diff(1)`, such as ``R=True`` to
            swap both sides of the diff.

        :return:
            A :class:`DiffIndex` representing the computed diff.

        :note:
            On a bare repository, `other` needs to be provided as :const:`INDEX`, or as
            an instance of :class:`~git.objects.tree.Tree` or
            :class:`~git.objects.commit.Commit`, or a git command error will occur.
        z--abbrev=40z--full-indexc3s�|]}|�vVqdS�Nr.)�.0�x�rOr.r/�	<genexpr>�s�z Diffable.diff.<locals>.<genexpr>)Zfind_renamesZ
no_renamesr$z-Mz-pz
--no-ext-diffz--rawz-zz
--no-colorNrz--cachedz-rz--rootz--TZ
as_process)�append�any�
isinstance�tuple�listrH�git�diffr�insertrZ	diff_tree�extendrKr�_index_from_patch_format�_index_from_raw_format�wait)
rJrLrMrNrOrIZdiff_cmd�procZdiff_method�indexr.rTr/r\�sD.










z
Diffable.diff)r(r)r*r+�	__slots__�__annotations__rrZIndexrrrrKr�strr�boolrr\r.r.r.r/rzs<
		
�
�������r�T_Diffr)�boundc@s>eZdZUdZdZeeded<	dede	e
fdd�ZdS)rz�An index for diffs, allowing a list of :class:`Diff`\s to be queried by the diff
    properties.

    The class improves the diff handling convenience.
    )r!r#r"r%r$r&�change_typer1ccs��||jvrtd|��|D]J}|j|kr|Vq|dkr$|jr$|Vq|dkr/|jr/|Vq|dkr:|jr:|Vq|dkrE|jrE|Vq|dkrX|jrX|jrX|j|jkrX|VqdS)a�
        :return:
            Iterator yielding :class:`Diff` instances that match the given `change_type`

        :param change_type:
            Member of :attr:`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: %sr!r"r#r%r$N)rj�
ValueError�new_file�deleted_file�copied_file�renamed_file�a_blob�b_blob)rJrjZdiffidxr.r.r/�iter_change_type/s$�

 ��zDiffIndex.iter_change_typeN)r(r)r*r+rjrrre�Lit_change_typerrhrrr.r.r.r/rs

	rc @s�eZdZdZe�dejejB�ZdZ	dZ
dZdddee
d	ee
d
eee
dfdeee
dfd
ee
edfdee
edfdedededee
dee
deee
dfdeedeeddf dd�Zdedefdd�Zdedefdd�Zdefdd �Zdefd!d"�Zedeefd#d$��Zedeefd%d&��Zedeefd'd(��Zedeefd)d*��Zedefd+d,��Zedefd-d.��Ze d/e
d0e
d1e
dee
fd2d3��Z!e ddd4ed5de"dfd6d7��Z#e$d8e
ddd9e"dddfd:d;��Z%e d@d>d?��Z&dS)Ara�A 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 indicate 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. The
        path will be available, though.

        If it is listed in a diff, the working tree version of the file must differ from
        the version in the index or tree, and hence has been modified.
    s
                                ^diff[ ]--git
                                    [ ](?P<a_path_fallback>"?[ab]/.+?"?)[ ](?P<b_path_fallback>"?[ab]/.+?"?)\n
                                (?:^old[ ]mode[ ](?P<old_mode>\d+)\n
                                   ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))?
                                (?:^similarity[ ]index[ ]\d+%\n
                                   ^rename[ ]from[ ](?P<rename_from>.*)\n
                                   ^rename[ ]to[ ](?P<rename_to>.*)(?:\n|$))?
                                (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))?
                                (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))?
                                (?:^similarity[ ]index[ ]\d+%\n
                                   ^copy[ ]from[ ].*\n
                                   ^copy[ ]to[ ](?P<copied_file_name>.*)(?:\n|$))?
                                (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
                                    \.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
                                (?:^---[ ](?P<a_path>[^\t\n\r\f\v]*)[\t\r\f\v]*(?:\n|$))?
                                (?:^\+\+\+[ ](?P<b_path>[^\t\n\r\f\v]*)[\t\r\f\v]*(?:\n|$))?
                            Z(0000000000000000000000000000000000000000s)rprq�a_mode�b_mode�	a_rawpath�	b_rawpathrlrmrn�raw_rename_from�
raw_rename_tor\rj�scorerHr rvrw�	a_blob_idN�	b_blob_idrtrurlrmrnrxryr\rjrzr1cCsn|dust|t�sJ�|dust|t�sJ�||_||_|r"t|�nd|_|r+t|�nd|_|rK|rK|jD]}|j|�	t
d�krJ|��rH|��}nq5||dusV||j
krZd|_n
t|t|�|j|jd�|_||dusr||j
krvd|_n
t|t|�|j|jd�|_||_|	|_|
|_|dus�t|t�s�J�|dus�t|t�s�J�|p�d|_|p�d|_|
|_||_||_dS)NrD)�moder:)rXr6rvrwrrtruZ
submodulesr:�decoder	Z
module_exists�module�NULL_HEX_SHArpr
r
�a_pathrq�b_pathrlrmrnrxryr\rjrz)rJrHrvrwr{r|rtrurlrmrnrxryr\rjrzZ	submoduler.r.r/�__init__�s>
�


z
Diff.__init__rLcCs*|jD]}t||�t||�krdSqdS)NFT)rd�getattr)rJrL�namer.r.r/�__eq__�s

�zDiff.__eq__cCs
||kSrQr.)rJrLr.r.r/�__ne__�s
zDiff.__ne__cstt�fdd��jD���S)Nc3s�|]}t�|�VqdSrQ)r�)rR�n�rJr.r/rU�s�z Diff.__hash__.<locals>.<genexpr>)�hashrYrdr�r.r�r/�__hash__�sz
Diff.__hash__cCsVd}|jr||jj;}n	|jr||jj;}d}d}d}t|j|jfd�D]\}}|r4d||j|jf}nd|}tt|�|�}||7}q$|dd|7}|jrS|d	7}|j	rZ|d
7}|j
rg|d|j|jf7}|j
rq|d|j
7}|jr{|d
|j7}|jr�|d7}z|t|jt�r�|j�t�n|j7}Wn
ty�|d7}Ynw|d7}||S)Nz%s�r)ZlhsZrhsz
%s: %o | %sz	
%s: None�
�=z
file deleted in rhsz
file added in rhsz
file %r copied from %rz
file renamed from %rz
file renamed to %rz
---zOMITTED BINARY DATA)rpr:rq�zipr}Zhexsha�max�lenrmrlrnr�r��rename_from�	rename_tor\rXr6r~r	�UnicodeDecodeError)rJ�h�msg�lineZline_length�br�r.r.r/�__str__�sD
&�zDiff.__str__cC�|jr
|j�td�SdS�NrD)rvr~r	r�r.r.r/r��zDiff.a_pathcCr�r�)rwr~r	r�r.r.r/r�r�zDiff.b_pathcCr�r�)rxr~r	r�r.r.r/r�r�zDiff.rename_fromcCr�r�)ryr~r	r�r.r.r/r� r�zDiff.rename_tocCstjdtdd�|jS)aDeprecated, use :attr:`renamed_file` instead.

        :return:
            ``True`` if the blob of our diff has been renamed

        :note:
            This property is deprecated.
            Please use the :attr:`renamed_file` property instead.
        z9Diff.renamed is deprecated, use Diff.renamed_file insteadrA)�
stacklevel)�warnings�warn�DeprecationWarningror�r.r.r/�renamed$s�zDiff.renamedcCs|j|jkS)z::return: ``True`` if the blob of our diff has been renamed)r�r�r�r.r.r/ro6szDiff.renamed_file�
path_match�rename_match�path_fallback_matchcCs,|rt|�S|rt|dd�S|rt|�SdS)NF)r;)rG)�clsr�r�r�r.r.r/�_pick_best_path;szDiff._pick_best_pathrb)rzGit.AutoInterruptcCsxg}t||jdtdd�d�|�}t�}d}d}d\}}	d\}
}|j�|�D]�}|��\}
}}}}}}}}}}}}}	t|�t|�t|�}}}|�	|||
�}|�	|	||�}	|durg||�
�|���|d_|pr|pr|or|pr|pr|}
|p||p||p||	o||
}|�t
|||	|o�|�t�|o�|�t�|
o�|
�t�|o�|�t�|||||ddd��|}|}q&|r�|r�||�
�d�|d_|S)a�Create a new :class:`DiffIndex` from the given process output which must be
        in patch format.

        :param repo:
            The repository we are operating on.

        :param proc:
            :manpage:`git-diff(1)` process to read from
            (supports :class:`Git.AutoInterrupt <git.cmd.Git.AutoInterrupt>` wrapper).

        :return:
            :class:`DiffIndex`
        NF�Zdecode_streams�)NNr=)rrVr�joinr�	re_header�finditer�groupsrgr��end�startr\rr~r	)r�rHrbZ	text_list�textrcZprevious_header�headerr�r�rtruZ_headerZa_path_fallbackZb_path_fallback�old_mode�new_moder�r�Z
new_file_modeZdeleted_file_modeZcopied_file_namer{r|rlrmrnr.r.r/r_Hsv
�
���zDiff._index_from_patch_format�lines_bytesrccCs�|�t�}|�d�\}}}|�d�D]�}|sq|�d�\}}}|�d�}|�dd�\}}	}
}}tt|d�}
d�|dd��}|��rGt	|�nd}|�
d�}|�t�}|�t�}d	}d	}d	}d}d}|
d
krkd}d}nC|
dkrtd}
d}n:|
d
kr�d}|�dd�\}}|�t�}|�t�}n!|
dkr�|�dd�\}}|�t�}|�t�}||}}n|
dkr�	t||||
|||	|||||d|
|�}|�
|�qdS)N�:z:��rr�r2r�Fr"Tr!r#r%r&)r~r	�	partition�split�rstriprrsr��isdigitr5�strip�encoderrV)r�rHrc�lines�_r��metar:r�r�r{r|Z_change_typerjZ	score_strrzr�r�rmrlrnr�r�Z
a_path_strZ
b_path_strr\r.r.r/�_handle_diff_line�sp







��zDiff._handle_diff_linerrPcs(t��t|���fdd�dtdd��S)a!Create a new :class:`DiffIndex` from the given process output which must be
        in raw format.

        :param repo:
            The repository we are operating on.

        :param proc:
            Process to read output from.

        :return:
            :class:`DiffIndex`
        cs��|���SrQ)r�)Zbyt�r�rcrHr.r/�<lambda>sz-Diff._index_from_raw_format.<locals>.<lambda>NFr�)rrr)r�rHrbr.r�r/r`�s�zDiff._index_from_raw_format)rHr rbrr1rP)'r(r)r*r+�re�compile�VERBOSE�	MULTILINEr�r�ZNULL_BIN_SHArdrr6rrfrgrsr5r��objectr�r�r�r��propertyr�r�r�r�r�ro�classmethodr�rr_�staticmethodr�r`r.r.r.r/rPs�!
��������	�
���
����
�=-  \ H)T):�__all__r,r�r�Zgit.cmdrZ
git.compatr	Zgit.objects.blobr
Zgit.objects.utilrZgit.utilrr
�typingrrrrrrrrrrrZ	git.typesrr�
subprocessrrZgit.objects.baserZgit.objects.commitrZgit.objects.treerZ
git.repo.baser rs�unique�Enumrrrerr�rEr6r9rgrGrrhrrr.r.r.r/�<module>sB
4

"2