Edit File: fun.cpython-311.pyc
� ����r�d�Z����������������������������d�Z�ddlZddlmZ�ej��������ZddlZddlmZ�ddlm Z �ddl mZmZ�ddl mZ�ddlmZmZmZmZ�dd lmZ�d ZdZeefZddd ededededdedediZed edededdedeiZdej��������z��ZdZd��Zd��Zd��Z d��Z!�G�d��d������������Z"d��Z#d��Z$d��Z%�G�d��d e&������������Z'�G�d!��d"e'������������Z(d#��Z)d$��Z*d%��Z+d&��Z,d/d'�Z-d(��Z.efd)�Z/d*��Z0d+��Z1d,��Z2d-��Z3 �dd.l4m1Z1�dS�#�e5$�r�Y�dS�w�xY�w)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.2/venv/lib/python3.11/site-packages/gitdb/fun.py�_set_delta_rboundr+���?���s������ ��A�D�� �Hr���c�����������������������|dk����rdS�|�xj���������|z ��c_���������|�xj��������|z ��c_��������|�xj��������|z��c_��������|�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: dr���N)�to�sor'����data)r(����bytess��� r*����_move_delta_lboundr1���K���s_������ � ��z�z����D�D�E�M�D�D��D�D�E�M�D�D��D�D�E�M�D�D��v����������� �Hr���c������������������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�7r���c�����������������������|�j����������'�|||�j��������|�j��������|�j��������z��������������������������dS�|�j��������t����������|�j���������������������k�����r�||�j���������d|�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<���a���s�������� �w�� ��d�2�5������&�'�(�(�(�(�(� ��5�3�r�w�<�<����E�"�'�&�2�5�&�/�"�"�"�"�"��E�"�'�N�N�N�N�Nr���c��������������������.�����e�Zd�ZdZdZd��Zd��Zd��Zd��ZdS�)r4���zhRepresents a piece of a delta, it can either add new data, or copy existing one from a source buffer�r-���r'���r.���r/���c������������������>�����||�_���������||�_��������||�_��������||�_��������d�S�r3���r>���)�selfr-���r'���r.���r/���s��� r*����__init__zDeltaChunk.__init__����s"����������������� � � r���c������������������@�����d|�j���������|�j��������|�j��������|�j��������pdfz��S�)NzDeltaChunk(%i, %i, %s, %s)��r>����r@���s��� r*����__repr__zDeltaChunk.__repr__����s#������+�t�w�����$�)�/�WY�.Z�Z�Zr���c������������������ �����|�j���������|�j��������z���S�r3���)r-���r'���rD���s��� r*����rboundzDeltaChunk.rbound����s�������w��� � r���c�����������������������|�j���������duS�)zB:return: True if the instance has data to add to the target streamN)r/���rD���s��� r*����has_datazDeltaChunk.has_data����s�������y��$�$r���N) �__name__� __module__�__qualname__�__doc__� __slots__rA���rE���rG���rI�����r���r*���r4���r4���t���sd�������������� �� ��I������[��[��[� !��!��!�%��%��%��%��%r���r4���c������������������������d}t����������|�������������}||k�����rN||z���dz��}|�|���������}|j��������|k����r|}n*|�����������������������������������|k����s|j��������|k����r|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 DeltaChunkListr���r���r���)r8���r-���rG���)�dcl�absofs�lo�hi�midr9���s��� 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�<�r���c������������������2�����|�D�]}t����������|||��������������dS�)aU��Apply 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<���)rQ���r:���r;���r9���s��� r*����delta_list_applyrX�������s2���������+��+���"�d�E�*�*�*�*�+��+r���c����������������������t����������|�|������������}|�|���������}t����������|�������������}|j��������}|j��������|k����rrt ����������|j��������|j��������|j��������|j��������������������}t����������|||j��������z ���������������t����������|j��������|������������|_���������||�������������||j��������z��}|dz ��}||k�����r�|r�|�|���������}|j��������|k����r:�|t ����������|j��������|j��������|j��������|j���������������������������������||j��������z��}nDt ����������|j��������|j��������|j��������|j��������������������}||_���������||�������������||j��������z��}dS�|dz ��}||k�����r|��dS�dS�dS�dS�)zx:return: Subsection of this list at the given absolute offset, with the given size in bytes. :return: Noner���N) rV���r8����appendr-���r4���r'���r.���r/���r1����min) rQ���rR���r)����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������*�*��*�*�*�*�*�*�*�*�*r���c��������������������L�����e�Zd�ZdZ�e��������������Zd��Zd��Zd��Zd��Z d��Z d d�Zd S�)r#���aZ��List 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����������|�������������dk����rdS�|�d��������������������������������������������S�)z,:return: rightmost extend in bytes, absoluter������)r8���rG���rD���s��� r*���rG���zDeltaChunkList.rbound����s*�������t�9�9��>�>��1��B�x��� � � r���c������������������F�����t����������|�������������dk����rdS�|�d���������j��������S�)z5:return: leftmost byte at which this chunklist startsr���)r8���r-���rD���s��� r*����lboundzDeltaChunkList.lbound����s"�������t�9�9��>�>��1��A�w�z�r���c������������������T�����|�������������������������������������|������������������������������������z ��S�)z6:return: size of bytes as measured by our delta chunks)rG���rg���rD���s��� r*���r)���zDeltaChunkList.size����s�������{�{�}�}�t�{�{�}�}�,�,r���c������������������$�����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�2r���c����������� �������2����t����������|�������������}|dk�����r|�S�d}d}||k�����r�|�|���������}|dz ��}|j����������|��|dz ��|z ��dk����r�t������������������������}|�|���������j��������}t ����������||dz ��������������D�]1}|�|���������}|���������������������|j��������d|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: selfr���r���Nr���) r8���r/���r���r-����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�>��r���re���c������������������p����|dk����rB|�d���������������������������������������������|k����sJ��t����������d��d��|�D���������������d������������|k����sJ��t����������|�������������dk�����rdS�|�D�]B}|j��������dk����sJ��|�����������������������������������rt����������|j��������������������|j��������k����sJ���Ct ����������|�dt����������|�������������dz ��������������}t����������|�������������}|������������������������������������t����������||������������D�]>\��}}|������������������������������������|j ��������k����sJ��|j ��������|j��������z���|j ��������k����sJ���?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 matchre���c�����������������������|�|z���S�r3���rO���)rr����ys��� r*����<lambda>z0DeltaChunkList.check_integrity.<locals>.<lambda>*��s ������q�1�u��r���c��������������3����$���K����|�]}|j���������V����d�S�r3���r&���)�.0r(���s��� r*���� <genexpr>z1DeltaChunkList.check_integrity.<locals>.<genexpr>*��s$����������.B�.B��q�t�.B�.B�.B�.B�.B�.Br���r���r���Nr���)rG���r���r8���r'���rI���r/���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�,�,�,�,�,� -�� -r���N)re���)rJ���rK���rL���rM����tuplerN���rG���rg���r)���rj���ru���r����rO���r���r*���r#���r#�������s���������������.��.������I�!��!��!������-��-��-�3��3��3� )��)��)�V-��-��-��-��-��-r���r#���c��������������������,�����e�Zd�ZdZ�e��������������Zd��ZdS�)�TopdownDeltaChunkListzSRepresents a list which is generated by feeding its ancestor streams one by onec������������������2����d}d}t����������|�������������}t������������������������}||k�����r�|�|���������}|dz ��}|j���������|dz ��}� |dd�=�t����������||j��������|j��������|�������������|j��������|j��������z ��}|D�]}|xj��������|z ��c_���������t����������|������������dk����r|d���������|�|dz ��<���n`|�|d����������} |�|dz ��d�=�|����������������������|�������������|����������������������| �������������t����������|�������������}|t����������|������������dz ��z ��}||k�������||k����rdS�dS�)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 returnedr���r���NFT)r8����listr/���rb���r.���r'���r-����extend) r@����bdcl�nfc�dcir_����cclr9����ofs�cdc�post_dcis ��� r*����connect_with_next_basez,TopdownDeltaChunkList.connect_with_next_baseH��sN�����������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��tr���N)rJ���rK���rL���rM���r����rN���r����rO���r���r*���r����r����B��s8���������������������I�;��;��;��;��;r���r����c������������������p�����t����������t����������|�dd����������������������\��}}|dz��|z���}|dk����o|dz��dk����S�)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*���r���r������sB���������a����e�_�_�F�B���!�G�r�>�D� ��:�*�4�"�9��*�*r���c������������������������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*���r���r������sa������ ��O� �/�/� $� $�Q�� 8� 8�C��.�3�8�8�I�.�.�.�/�5�5�j�A�A�O�I�t��c�$�i�i��r���c�����������������������t����������|�d���������������������}d}|dz ��dz��}|dz��}d}|dz��r/t����������|�|���������������������}|dz ��}||dz��|z��z ��}|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 mapr���r���r���r���������������r���)r/����cro����type_idr)����ss��� r*���r���r������s�������� ��a����A� �A��A�v��l�G��r�6�D� �A� �d�(����T�!�W���� �Q�����T��a���� �Q��� ��d�(���� �T�1��r���c�����������������������d}t������������������������}|�dz��|dz��z��}|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 streamr���r���r����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��Jr���c�����������������������d}d}t����������|�������������}d}||k�����r,|�||z������������}||dz��|dz��z��z��}|dz ��}|dz��sd}n||k������,|st����������d�������������||z���|fS�) z� :return: tuple(read_bytes, size) read the msb size from the given random access data starting at the given byte offsetr���Fr����r���r���r����Tz2Could not find terminating MSB byte in data stream)r8����AssertionError)r/����offsetr)���ro����l�hit_msbr����s��� r*���r���r������s�������� �D� �A��D� � �A��G� �a�%�%���V������T��a�!�e�#�#�� �Q����4�x�� ��G�� ��a�%�%����S��Q�R�R�R��v�:�t��r���c������������������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*���r���r������s*������� ��D�)�)�4�0�0�8�8��A�A�Ar���c������������������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���)r���r���)r����r)����readr;���� chunk_size�tbws��� r*���r���r������sG��������C���5�5�$�T�4�0�0�1�1�1�C��;�t�U�D�*�5�5�5�C��Jr���c�����������������������d} �t����������|||z ��������������}�|�|������������}t����������|������������}||z ��}�||�������������||k�����s||k����rn�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*���r���r������sq��������C�� ��T�C�Z� (� (����t�B�x�x���t�9�9���x��� ��d�����b�=�=�C�4�K�K�����Jr���c�����������������������d}t������������������������x}}t����������|�������������D��]>\��}}|�����������������������������������}|j��������}t ����������|������������\��}}t ����������||������������\��}} d} ||k������r�t����������||���������������������}|dz ��}|dz���r=d\��}} |dz��rt����������||���������������������}|dz ��}|dz��r |t����������||���������������������dz��z��}|dz ��}|dz��r |t����������||���������������������d z��z��}|dz ��}|dz��r |t����������||���������������������d z��z��}|dz ��}|d z��rt����������||���������������������} |dz ��}|dz��r | t����������||���������������������dz��z��} |dz ��}|dz��r | t����������||���������������������d z��z��} |dz ��}| sd } || z���}|| k�����s||k����rn~|���������������������t����������| | |d�������������������������| | z ��} nL|r;|���������������������t����������| |d||||z��������������������������������������||z ��}| |z ��} nt����������d�������������||k��������|� �����������������������������������|dk����r|� ��������������������|������������s�nt������������������������}��@|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 applyNr���r���r�����r���r���r���r����r������������ ����@��������unexpected delta opcode 0)r����� enumerater����r)���r���r����rZ���r4���� ValueErrorru���r����r#���)�dstreams�tdclrQ����dsi�ds�db�delta_buf_sizero���� base_sizer����r����r�����cp_off�cp_sizerG���s��� 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�� �����������Kr���c������������������d����d}|}||k������r||���������}|dz ��}|dz��r�d\��}} |dz��r ||���������}|dz ��}|dz��r|||���������dz��z��}|dz ��}|dz��r|||���������dz��z��}|dz ��}|dz��r|||���������d z��z��}|dz ��}|dz��r ||���������} |dz ��}|d z��r| ||���������dz��z��} |dz ��}|dz��r| ||���������dz��z��} |dz ��}| sd} || z���} | | k�����s| |k����rnK�||�||| z��������������������������n-|r�|||||z��������������������������||z ��}nt����������d �������������||k�������||k����s J�d���������������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.cr���r���r����r����r���r����r���r����r����r����r����r����r����zdelta replay has gone wildN)r����)�src_buf�src_buf_size� delta_bufr����r;���ro���r����r����r����r����rG���s��� r*���r ���r ���m��s������� �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� ����� <�����r���c������������������������|�dz��}|d|����������|d|����������k����rdS�|�|z ��r@t����������|d���������������������t����������|t����������|������������dz �����������������������z��dz��rdS�dS�)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 shar���NFre���r��������T)r���r8���)�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.utilr���r�����mmap� itertoolsr���� functoolsr����gitdb.constr���r����gitdb.utils.encodingr ���� gitdb.typr ���r���r���r ����ior���r���r����delta_types�type_id_to_type_map�type_to_type_id_map�PAGESIZEr�����__all__r+���r1���r6���r<���r4���rV���rX���rb���r����r#���r����r���r���r���r$���r���r���r���r���r"���r ���r!����gitdb_speedups._perf�ImportErrorrO���r���r*����<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,