ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/gitdb/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/gitdb/__pycache__/fun.cpython-311.pyc

�

�܋f�Z����dZddlZddlmZejZddlZddlmZddlm	Z	ddl
mZmZddl
mZddlmZmZmZmZdd	lmZd
ZdZeefZddd
ededededdedediZed
edededdedeiZdejzZdZd�Zd�Zd�Z d�Z!Gd�d��Z"d�Z#d�Z$d�Z%Gd�d e&��Z'Gd!�d"e'��Z(d#�Z)d$�Z*d%�Z+d&�Z,d/d'�Z-d(�Z.efd)�Z/d*�Z0d+�Z1d,�Z2d-�Z3	dd.l4m1Z1dS#e5$rYdSwxYw)0z�Contains basic c-functions which usually contain performance critical code
Keeping this code separate from the beginning makes it easier to out-source
it into c later, if required�N��byte_ord)�islice)�reduce)�	NULL_BYTE�
BYTE_SPACE)�
force_text)�
str_blob_type�str_commit_type�
str_tree_type�str_tag_type)�StringIO���������	OFS_DELTA�	REF_DELTAi�)�is_loose_object�loose_object_header_info�msb_size�pack_object_header_info�write_object�loose_object_header�stream_copy�apply_delta_data�is_equal_canonical_sha�connect_deltas�DeltaChunkList�create_pack_object_headerc��||_|S)z�Truncate the given delta to the given size
    :param size: size relative to our target offset, may not be 0, must be smaller or equal
        to our size
    :return: d��ts)�d�sizes  �Z/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/gitdb/fun.py�_set_delta_rboundr+?s��
�A�D�
�Hrc��|dkrdS|xj|z
c_|xj|z
c_|xj|zc_|j�|j|d�|_|S)z�Move the delta by the given amount of bytes, reducing its size so that its
    right bound stays static
    :param bytes: amount of bytes to move, must be smaller than delta size
    :return: drN)�to�sor'�data)r(�bytess  r*�_move_delta_lboundr1Ks_��

��z�z����D�D�E�M�D�D��D�D�E�M�D�D��D�D�E�M�D�D��v����������
�Hrc�N�t|j|j|j|j��S�N)�
DeltaChunkr-r'r.r/)�srcs r*�delta_duplicater6]s���c�f�c�f�c�f�c�h�7�7�7rc��|j�'|||j|j|jz���dS|jt|j��kr||jd|j���dS||j��dS)z�Apply own data to the target buffer
    :param bbuf: buffer providing source bytes for copy operations
    :param write: write method to call with data to writeN)r/r.r'�len)�dc�bbuf�writes   r*�delta_chunk_applyr<as���
�w��
��d�2�5������&�'�(�(�(�(�(�
�5�3�r�w�<�<����E�"�'�&�2�5�&�/�"�"�"�"�"��E�"�'�N�N�N�N�Nrc�.�eZdZdZdZd�Zd�Zd�Zd�ZdS)r4zhRepresents a piece of a delta, it can either add new data, or copy existing
    one from a source buffer�r-r'r.r/c�>�||_||_||_||_dSr3r>)�selfr-r'r.r/s     r*�__init__zDeltaChunk.__init__�s"�������������	�	�	rc�@�d|j|j|j|jpdfzS)NzDeltaChunk(%i, %i, %s, %s)�r>�r@s r*�__repr__zDeltaChunk.__repr__�s#��+�t�w�����$�)�/�WY�.Z�Z�Zrc� �|j|jzSr3)r-r'rDs r*�rboundzDeltaChunk.rbound�s���w��� � rc��|jduS)zB:return: True if the instance has data to add to the target streamN)r/rDs r*�has_datazDeltaChunk.has_data�s���y��$�$rN)	�__name__�
__module__�__qualname__�__doc__�	__slots__rArErGrI�rr*r4r4tsd������ � ��I����[�[�[�
!�!�!�%�%�%�%�%rr4c���d}t|��}||krN||zdz}||}|j|kr|}n*|���|ks|j|kr|S|dz}||k�Nt|��dz
S)z�:return: index at which the given absofs should be inserted. The index points
    to the DeltaChunk with a target buffer absofs that equals or is greater than
    absofs.
    **Note:** global method for performance only, it belongs to DeltaChunkListrrr)r8r-rG)�dcl�absofs�lo�hi�midr9s      r*�_closest_indexrV�s���

�B�	�S���B�
�r�'�'��B�w�!�m��
��X��
�5�6�>�>��B�B�
�Y�Y�[�[�6�
!�
!�R�U�f�_�_��J��q��B�
�r�'�'��s�8�8�a�<�rc�2�|D]}t|||���dS)aUApply the chain's changes and write the final result using the passed
    write function.
    :param bbuf: base buffer containing the base of all deltas contained in this
        list. It will only be used if the chunk in question does not have a base
        chain.
    :param write: function taking a string of bytes to write to the outputN)r<)rQr:r;r9s    r*�delta_list_applyrX�s2���+�+���"�d�E�*�*�*�*�+�+rc��t||��}||}t|��}|j}|j|krrt	|j|j|j|j��}t|||jz
��t|j|��|_||��||jz}|dz
}||kr�|r�||}|j|kr:|t	|j|j|j|j����||jz}nDt	|j|j|j|j��}||_||��||jz}dS|dz
}||kr|��dSdSdSdS)zx:return: Subsection of this  list at the given absolute  offset, with the given
        size in bytes.
    :return: NonerN)
rVr8�appendr-r4r'r.r/r1�min)	rQrRr)�ndcl�cdi�cd�slen�lappend�tcds	         r*�delta_list_slicerb�s[����f�
%�
%�C�	�S��B��s�8�8�D��k�G�	�u���������r�u�b�g�6�6���3�����/�/�/��S�V�T�"�"���������������q�����*�*��*�
��X��
�5�D�=�=��G�J�r�u�b�e�R�U�B�G�<�<�=�=�=��B�E�M�D�D��R�U�B�E�2�5�"�'�:�:�C��C�F��G�C�L�L�L��C�F�N�D��E��q�����*�*��*�*�*�*�*�*�*�*�*rc�L�eZdZdZe��Zd�Zd�Zd�Zd�Z	d�Z
d
d�Zd	S)r#aZList with special functionality to deal with DeltaChunks.
    There are two types of lists we represent. The one was created bottom-up, working
    towards the latest delta, the other kind was created top-down, working from the
    latest delta down to the earliest ancestor. This attribute is queryable
    after all processing with is_reversed.c�`�t|��dkrdS|d���S)z,:return: rightmost extend in bytes, absoluter���)r8rGrDs r*rGzDeltaChunkList.rbound�s*���t�9�9��>�>��1��B�x��� � � rc�F�t|��dkrdS|djS)z5:return: leftmost byte at which this chunklist startsr)r8r-rDs r*�lboundzDeltaChunkList.lbound�s"���t�9�9��>�>��1��A�w�z�rc�T�|���|���z
S)z6:return: size of bytes as measured by our delta chunks)rGrgrDs r*r)zDeltaChunkList.size�s���{�{�}�}�t�{�{�}�}�,�,rc�$�t|||��S)z_Only used by public clients, internally we only use the global routines
        for performance)rX)r@r:r;s   r*�applyzDeltaChunkList.apply�s�� ��d�E�2�2�2rc	�2�t|��}|dkr|Sd}d}||kr�||}|dz
}|j��|��|dz
|z
dkr�t��}||j}t	||dz
��D]1}||}|�|jd|j����2|||dz
�=|���}	|�|t|t|	��d|	����t|��}|dz}d}��|�|dz
}||k��|S)zoAlter the list to reduce the amount of nodes. Currently we concatenate
        add-chunks
        :return: selfrrNr)
r8r/rr-�ranger;r'�getvalue�insertr4)
r@r_�i�first_data_indexr9�ndr.�x�xdc�bufs
          r*�compresszDeltaChunkList.compress�sR���4�y�y���!�8�8��K�
�����$�h�h��a��B�
��F�A��w��#�/�A��E�<L�4L�q�4P�4P�!���B��.�/�2�B�"�#3�Q��U�;�;�4�4��"�1�g�������'�3�6�'�!2�3�3�3�3��-�a�!�e�3�4��+�+�-�-�C��K�K� 0�*�R��S���1�c�2R�2R�S�S�S��t�9�9�D�(�1�,�A�$(� �� �'�#$�q�5� �5�$�h�h�>�rrec�p�|dkrB|d���|ksJ�td�d�|D��d��|ksJ�t|��dkrdS|D]B}|jdksJ�|���rt|j��|jksJ��Ct
|dt|��dz
��}t|��}|���t||��D]>\}}|���|j
ksJ�|j
|jz|j
ksJ��?dS)z�Verify the list has non-overlapping chunks only, and the total size matches
        target_size
        :param target_size: if not -1, the total size of the chain must be target_size
        :raise AssertionError: if the size doesn't matchrec��||zSr3rO)rr�ys  r*�<lambda>z0DeltaChunkList.check_integrity.<locals>.<lambda>*s
��q�1�u�rc3�$K�|]}|jV��dSr3r&)�.0r(s  r*�	<genexpr>z1DeltaChunkList.check_integrity.<locals>.<genexpr>*s$����.B�.B��q�t�.B�.B�.B�.B�.B�.BrrrNr)rGrr8r'rIr/r�iter�next�zipr-)r@�target_sizer9�left�right�lft�rgts       r*�check_integrityzDeltaChunkList.check_integrity#sW��
������8�?�?�$�$��3�3�3�3��,�,�.B�.B�T�.B�.B�.B�A�F�F�+�U�U�U�U��t�9�9�q�=�=��F��	-�	-�B��5�1�9�9�9�9��{�{�}�}�
-��2�7�|�|�r�u�,�,�,�,���d�A�s�4�y�y�1�}�-�-���T�
�
��
�
�
�����D�%�(�(�	-�	-�H�C���:�:�<�<�3�6�)�)�)�)��6�C�F�?�c�f�,�,�,�,�,�	-�	-rN)re)rJrKrLrM�tuplerNrGrgr)rjrur�rOrr*r#r#�s�������.�.�����I�!�!�!����-�-�-�3�3�3�
)�)�)�V-�-�-�-�-�-rr#c�,�eZdZdZe��Zd�ZdS)�TopdownDeltaChunkListzSRepresents a list which is generated by feeding its ancestor streams one by
    onec�2�d}d}t|��}t��}||kr�||}|dz
}|j�|dz
}� |dd�=t||j|j|��|j|jz
}|D]}|xj|z
c_�t|��dkr|d||dz
<n`||d�}	||dz
d�=|�|��|�|	��t|��}|t|��dz
z
}||k��||krdSdS)a=Connect this chain with the next level of our base delta chunklist.
        The goal in this game is to mark as many of our chunks rigid, hence they
        cannot be changed by any of the upcoming bases anymore. Once all our
        chunks are marked like that, we can stop all processing
        :param bdcl: data chunk list being one of our bases. They must be fed in
            consecutively and in order, towards the earliest ancestor delta
        :return: True if processing was done. Use it to abort processing of
            remaining streams if False is returnedrrNFT)r8�listr/rbr.r'r-�extend)
r@�bdcl�nfc�dcir_�cclr9�ofs�cdc�post_dcis
          r*�connect_with_next_basez,TopdownDeltaChunkList.connect_with_next_baseHsN�������4�y�y���f�f���D�j�j��c��B��1�H�C��w�"��q�����A�A�A���T�2�5�"�%��5�5�5��%�"�%�-�C��
�
�����#�
�����3�x�x�1�}�}� #�A���S�1�W�
�
� ����:����q����N����C� � � ����H�%�%�%��4�y�y���s�3�x�x�!�|�#��M�D�j�j�V�$�;�;��5��trN)rJrKrLrMr�rNr�rOrr*r�r�Bs8������������I�;�;�;�;�;rr�c�p�tt|dd���\}}|dz|z}|dko|dzdkS)z
    :return: True the file contained in memory map m appears to be a loose object.
        Only the first two bytes are neededNr��x�r)�map�ord)�m�b0�b1�words    r*rr�sB����a����e�_�_�F�B���!�G�r�>�D�
��:�*�4�"�9��*�*rc���d}t���||��}|d|�t����t
��\}}|t
|��fS)z�
    :return: tuple(type_string, uncompressed_size_in_bytes) the type string of the
        object as well as its uncompressed size in bytes.
    :param m: memory map from which to read the compressed object datai N)�
decompressobj�
decompress�findr�splitr�int)r��decompress_size�hdr�	type_namer)s     r*rr�sa��
�O�
�/�/�
$�
$�Q��
8�
8�C��.�3�8�8�I�.�.�.�/�5�5�j�A�A�O�I�t��c�$�i�i��rc��t|d��}d}|dz	dz}|dz}d}|dzr/t||��}|dz
}||dz|zz
}|dz
}|dz�/|||fS)a1
    :return: tuple(type_id, uncompressed_size_in_bytes, byte_offset)
        The type_id should be interpreted according to the ``type_id_to_type_map`` map
        The byte-offset specifies the start of the actual zlib compressed datastream
    :param m: random-access memory, like a string or memory maprrrr���r)r/�cro�type_idr)�ss      r*rr�s���	��a����A�	�A��A�v��l�G��r�6�D�	�A�
�d�(���T�!�W����	�Q�����T��a����	�Q���	�d�(��
�T�1��rc��d}t��}|dz|dzz}|dz}|r$|�|dz��|dz}|dz}|�$|�|��|S)z�
    :return: string defining the pack header comprised of the object type
        and its incompressed size in bytes

    :param obj_type: pack type_id of the object
    :param obj_size: uncompressed size in bytes of the following object streamrrr�r�r�r)�	bytearrayrZ)�obj_type�obj_sizer�r�s    r*r$r$�s}��	
�A�
�+�+�C�	�Q��8�c�>�*�A���N�H�
���
�
�1�t�8�����t�O���Q�����
�J�J�q�M�M�M��Jrc��d}d}t|��}d}||kr,|||z}||dz|dzzz}|dz
}|dzsd}n||k�,|std���||z|fS)	z�
    :return: tuple(read_bytes, size) read the msb size from the given random
        access data starting at the given byte offsetrFr�rrr�Tz2Could not find terminating MSB byte in data stream)r8�AssertionError)r/�offsetr)ro�l�hit_msbr�s       r*rr�s���
�D�	�A��D�	�	�A��G�
�a�%�%���V������T��a�!�e�#�#��	�Q����4�x�	��G��
�a�%�%��S��Q�R�R�R��v�:�t��rc�P�dt|��|fz�d��S)z�
    :return: bytes representing the loose object header, which is immediately
        followed by the content stream of size 'size'z%s %i�ascii)r	�encode)�typer)s  r*rr�s*��
��D�)�)�4�0�0�8�8��A�A�Arc�l�d}||t||����z
}|t||||��z
}|S)a0
    Write the object as identified by type, size and source_stream into the
    target_stream

    :param type: type string of the object
    :param size: amount of bytes to write from source_stream
    :param read: read method of a stream providing the content data
    :param write: write method of the output stream
    :param close_target_stream: if True, the target stream will be closed when
        the routine exits, even if an error is thrown
    :return: The actual amount of bytes written to stream, which includes the header and a trailing newliner)rr)r�r)�readr;�
chunk_size�tbws      r*rr�sG���C��5�5�$�T�4�0�0�1�1�1�C��;�t�U�D�*�5�5�5�C��Jrc��d}	t|||z
��}||��}t|��}||z
}||��||ks||krn�K|S)z�
    Copy a stream up to size bytes using the provided read and write methods,
    in chunks of chunk_size

    **Note:** its much like stream_copy utility, but operates just using methodsr)r[r8)r�r;r)r��dbw�csr/�data_lens        r*rr�sq���C��
��T�C�Z�
(�
(���t�B�x�x���t�9�9���x���
��d�����b�=�=�C�4�K�K����Jrc���d}t��x}}t|��D�]>\}}|���}|j}t	|��\}}t	||��\}}	d}
||k�r�t||��}|dz
}|dz�r=d\}}
|dzrt||��}|dz
}|dzr |t||��dzz}|dz
}|dzr |t||��d	zz}|dz
}|dzr |t||��d
zz}|dz
}|d	zrt||��}
|dz
}|dzr |
t||��dzz}
|dz
}|dzr |
t||��d	zz}
|dz
}|
sd
}
||
z}||
ks||krn~|�t|
|
|d����|
|
z
}
nL|r;|�t|
|d||||z�����||z
}|
|z
}
ntd���||k���|�	��|dkr|�
|��snt��}��@|S)aM
    Read the condensed delta chunk information from dstream and merge its information
        into a list of existing delta chunks

    :param dstreams: iterable of delta stream objects, the delta to be applied last
        comes first, then all its ancestors in order
    :return: DeltaChunkList, containing all operations to applyNrrr��rrrr�r��� �@��unexpected delta opcode 0)r��	enumerater�r)rr�rZr4�
ValueErrorrur�r#)�dstreams�tdclrQ�dsi�ds�db�delta_buf_sizero�	base_sizer�r�r��cp_off�cp_sizerGs               r*r"r"s����D�&�(�(�(�C�$��X�&�&�D�D���R�
�W�W�Y�Y����� ��|�|���9�!�"�a�����;����.� � ��B�q�E�
�
�A�
��F�A��4�x�)
>�"&������H�� ��A��Z�Z�F���F�A���H���s�2�a�5�z�z�Q��/�F���F�A���H���s�2�a�5�z�z�R�/�0�F���F�A���H���s�2�a�5�z�z�R�/�0�F���F�A���H��!�"�Q�%�j�j�G���F�A���H����B�q�E�
�
�a��0�G���F�A���H����B�q�E�
�
�b� 0�1�G���F�A��&�%�G��'�)���W�$�$���*�*���
�
�:�c�7�F�D�A�A�B�B�B��w�����
>��
�
�:�c�1�a��A�a�!�e�G��=�=�>�>�>��Q����q���� �!<�=�=�=�Y�.� � �`	��������7�7��.�.�s�3�3�
���������Krc�d�d}|}||k�r||}|dz
}|dzr�d\}}	|dzr
||}|dz
}|dzr|||dzz}|dz
}|dzr|||dzz}|dz
}|dzr|||d	zz}|dz
}|dzr
||}	|dz
}|d
zr|	||dzz}	|dz
}|dzr|	||dzz}	|dz
}|	sd}	||	z}
|
|	ks|
|krnK|||||	z���n-|r|||||z���||z
}ntd
���||k��||ks
Jd���dS)a�
    Apply data from a delta buffer using a source buffer to the target file

    :param src_buf: random access data from which the delta was created
    :param src_buf_size: size of the source buffer in bytes
    :param delta_buf_size: size for the delta buffer in bytes
    :param delta_buf: random access delta data
    :param write: write method taking a chunk of bytes

    **Note:** transcribed to python from the similar routine in patch-delta.crrr�r�rr�rr�r�r�r�r�r�zdelta replay has gone wildN)r�)�src_buf�src_buf_size�	delta_bufr�r;ror�r�r�r�rGs           r*r r ms��	
�A�	�B�
�n�
�
��q�E��	�Q����t�8�$	:�"�O�F�G��D��
��A����Q����D��
��2�a�5�A�:�&���Q����D��
��2�a�5�B�;�'���Q����D��
��2�a�5�B�;�'���Q����D��
��Q�%���Q����D��
��B�q�E�Q�J�'���Q����D��
��B�q�E�R�K�(���Q����
"�!���g�%�F��� � ��\�)�)���E�'�&��'�!1�1�2�3�3�3�3�
�	:��E�"�Q�q�1�u�W�+����
��F�A�A��8�9�9�9�O�n�
�
�X
����� <�����rc���|dz}|d|�|d|�krdS||z
r@t|d��t|t|��dz
��zdzrdSdS)a:
    :return: True if the given lhs and rhs 20 byte binary shas
        The comparison will take the canonical_length of the match sha into account,
        hence the comparison will only use the last 4 bytes for uneven canonical representations
    :param match: less than 20 byte sha
    :param sha1: 20 byte sharNFrer��T)rr8)�canonical_length�match�sha1�
binary_lengths    r*r!r!�s|��%��)�M��^�m�^���^�m�^� 4�4�4��u��-�'��
�e�B�i�
 �
 �8�D��U���a��,@�#A�#A�
A�T�I���u��4r)r")r)6rM�zlib�
gitdb.utilrr��mmap�	itertoolsr�	functoolsr�gitdb.constrr�gitdb.utils.encodingr	�	gitdb.typr
rrr
�iorrr�delta_types�type_id_to_type_map�type_to_type_id_map�PAGESIZEr��__all__r+r1r6r<r4rVrXrbr�r#r�rrrr$rrrrr"r r!�gitdb_speedups._perf�ImportErrorrOrr*�<module>r�sV��
 � ������������"�
�����������������-�-�-�-�-�-�-�-�+�+�+�+�+�+�������������������
�	�
�	��)�$���s����}��}��|��s�
�{�
�{�	���Q��1��1��!�����
���D�M�
!�
�f��	
�	
�	
�
�
�
�$8�8�8����&%�%�%�%�%�%�%�%�B���*+�+�+����Fe-�e-�e-�e-�e-�T�e-�e-�e-�RA�A�A�A�A�N�A�A�A�P+�+�+�	 �	 �	 ����*���,����.B�B�B�6@�����*���6R�R�R�j9=�9=�9=�x���(	�3�3�3�3�3�3�3�3���	�	�	��D�D�	���s�C#�#C,�+C,

Zerion Mini Shell 1.0