Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/gitdb/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/gitdb/__pycache__/pack.cpython-311.pyc

�

�܋fR����dZddlZddlmZmZmZmZddlmZm	Z	m
Z
mZmZddl
mZmZmZmZmZmZmZmZmZmZmZ	ddlmZn#e$rYnwxYwddlmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)dd	l*m+Z+dd
l,m-Z-ddl.m/Z/ddl0Z0ddl1Z1ddl2Z2ddl3Z3dZ4d
�Z5dd�Z6Gd�d��Z7Gd�de	��Z8Gd�de	��Z9Gd�de	��Z:dS)z3Contains PackIndexFile and PackFile implementations�N)�	BadObject�AmbiguousObjectName�UnsupportedOperation�
ParseError)�mman�	LazyMixin�unpack_from�
bin_to_hex�byte_ord)�create_pack_object_header�pack_object_header_info�is_equal_canonical_sha�type_id_to_type_map�write_object�stream_copy�
chunk_size�delta_types�	OFS_DELTA�	REF_DELTA�msb_size��PackIndexFile_sha_to_index)�OInfo�OStream�	OPackInfo�OPackStream�ODeltaStream�ODeltaPackInfo�ODeltaPackStream)�DecompressMemMapReader�DeltaApplyReader�
Sha1Writer�
NullStream�FlexibleSha1Writer)�pack)�crc32)�	NULL_BYTE)�
PackIndexFile�PackFile�
PackEntityc�j�|�|�����}t|��\}}}d}d}|tkrZ|}	t	||	��}
|	dz
}	|
dz}|
dzr/t	||	��}
|	dz
}	|dz
}|dz|
dzz}|
dz�/|}|	}n|t
kr|dz}|||�}n|}||z}|rDt
||d�d|��}
|�|t||||
��fS|t|||||
��fS|�|t|||��fS|t||||��fS)a&
    :return: Tuple(abs_data_offset, PackInfo|PackStream)
        an object of the correct type according to the type_id  of the object.
        If as_stream is True, the object will contain a stream, allowing  the
        data to be read decompressed.
    :param data: random accessible data containing all required information
    :parma offset: offset in to the data at which the object information is located
    :param as_stream: if True, a stream object will be returned that can read
        the data, otherwise you receive an info object onlyN�����F)�
use_region�bufferr
rrrr rrrr)�cursor�offset�	as_stream�data�type_id�uncomp_size�data_rela_offset�total_rela_offset�
delta_info�i�c�delta_offset�abs_data_offset�streams              �[/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/gitdb/pack.py�pack_object_atrBLs������V�$�$�+�+�-�-�D�-D�T�-J�-J�*�G�[�*����J��)������T�!�W����	�Q����4�x���$�h�	<���a��!�!�A�
��F�A��A��L�(�A�-�!�d�(�;�L�	�$�h�	<�"�
����	�I�	�	�,�r�1���*�+<�<�=�
�
�-���0�0�O��
]�'��->�-?�-?�(@�%��U�U����"�K����f�$U�$U�U�U�"�$4�V�W�k�S]�_e�$f�$f�f�f���"�I�f�g�{�$K�$K�K�K�"�N�6�7�K�Q[�$\�$\�\�\�c��d}d}|du}d}|r|}	|t��}|t|��z
}|�|��}	|t|	��z
}||	��|rt|	|��}t|��tkrn��|���}	|t|	��z
}||	��|rt|	|��}|||fS)a�Copy a stream as read from read function, zip it, and write the result.
    Count the number of written bytes and return it
    :param base_crc: if not None, the crc will be the base for all compressed data
        we consecutively write and generate a crc32 from. If None, no crc will be generated
    :return: tuple(no bytes read, no bytes written, crc32) crc might be 0 if base_crc
        was falserN)r�len�compressr&�flush)
�read�write�zstream�base_crc�br�bw�want_crc�crc�chunk�
compresseds
          rA�write_stream_to_packrR�s��
�B�	
�B��t�#�H�
�C��������Z� � ��
�c�%�j�j����%�%�e�,�,�
�
�c�*�o�o���
��j�����	)��
�C�(�(�C��u�:�:��#�#��������J��#�j�/�/��B�	�E�*�����%��J��$�$��
��C�=�rCc�(�eZdZdZdZd�Zd�Zd�ZdS)�IndexWriterz�Utility to cache index information, allowing to write all information later
    in one go to the given stream
    **Note:** currently only writes v2 indices�_objsc�,�t��|_dS�N)�listrU��selfs rA�__init__zIndexWriter.__init__�s���V�V��
�
�
rCc�@�|j�|||f��dS)z&Append one piece of object informationN)rU�append)rZ�binsharOr4s    rAr]zIndexWriter.append�s%���
���6�3��/�0�0�0�0�0rCc�p�|j�d����t|��}|j}|tj��|t
dtj����td��}|jD]+}|t|dd��xxdz
cc<�,td��D]6}||}|t
d|����||dzxx|z
cc<�7|t
d|d����|d�d	�|jD������|jD]$}|t
d|dd
z�����%t��}|jD]V}|d}	|	dkr*|�|	��d
t|��zdz
}	|t
d|	d
z�����W|D]}	|t
d|	�����t|��dksJ�||��|�d���}
||
��|
S)z�Write the index file using the given write method
        :param pack_sha: binary sha over the whole pack that we index
        :return: sha1 binary sha over all index file contentsc��|dS)Nr�)�os rA�<lambda>z#IndexWriter.write.<locals>.<lambda>�s
��a��d�rC)�key�>L(rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr,�rCc3�&K�|]}|dV��
dS)rNra)�.0�ts  rA�	<genexpr>z$IndexWriter.write.<locals>.<genexpr>�s&����4�4�A�1�Q�4�4�4�4�4�4�4rC����i�����>Qr0F��as_hex)rU�sortr$rIr(�index_v2_signaturer%�index_version_defaultrXr�range�joinr]rE�sha)rZ�pack_sharI�
sha_writer�	sha_write�tmplistrir<�v�ofsrvs           rArIzIndexWriter.write�s{��
	
�
���N�N��+�+�+�'��.�.�
��$�	��	�-�2�3�3�3��	�$�t�]�@�A�A�B�B�B��z�"�"����	,�	,�A��H�Q�q�T�!�W�%�%�&�&�&�!�+�&�&�&�&��s���	 �	 �A���
�A��I�d�4��m�m�$�$�$��A��E�N�N�N�a��N�N�N�N��	�$�t�W�S�\�*�*�+�+�+�	�	�#�(�(�4�4���4�4�4�4�4�5�5�5���	5�	5�A��I�d�4��1��
�!2�3�3�4�4�4�4��&�&����	4�	4�A��A�$�C��Z������s�#�#�#� �3�w�<�<�/�!�3���I�d�4��z�!1�2�2�3�3�3�3��	'�	'�C��I�d�4��o�o�&�&�&�&��8�}�}��"�"�"�"��	�(�����n�n�E�n�*�*��
��c�
�
�
��
rCN)�__name__�
__module__�__qualname__�__doc__�	__slots__r[r]rIrarCrArTrT�sR������2�2��I����1�1�1�6�6�6�6�6rCrTc����eZdZdZdZdZdZ�fd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zde��vrd�Z�xZS�xZS)r(zmA pack index provides offsets into the corresponding pack, allowing to find
    locations for offsets faster.is�tOcrlc�V��t�����||_dSrW)�superr[�
_indexpath)rZ�	indexpath�	__class__s  �rAr[zPackIndexFile.__init__s$���
��������#����rCc�F�tj|j��d|_dSrW)r�force_map_handle_removal_winr��_cursorrYs rA�closezPackIndexFile.closes ���)�$�/�:�:�:�����rCc��|dkr(|j���dd�|_dS|dkr(|j���dd�|_dS|dkr�tj|j�����|_tj��dkrp|j���tj��krDtd|j|j���tj��fz���dSdS|j���}|dd�|j
krdpd	|_|jdkr/td
|d��d}||jks
Jd|z���dD]+}t||t|d
||jfz�����,|���dS)N�_packfile_checksum�������r�rzsThe index file at %s is too large to fit into a mapped window (%i > %i). This is a limitation of the implementation�rlr,rezUnsupported index version: %i)�entryr4rvrOz_%s_v%i)r��mapr�r�make_cursorr�r1�window_size�	file_size�AssertionErrorrr�_versionr	�setattr�getattr�_initialize)rZ�attr�mmap�
version_id�fnames     rA�_set_cache_zPackIndexFile._set_cache_s����'�'�'�&*�l�&6�&6�&8�&8��S��&A�D�#�#�#�
�)�
)�
)�&*�l�&6�&6�&8�&8����&>�D�#�#�#�
�Y�
�
� �+�D�O�<�<�G�G�I�I�D�L���!�!�A�%�%�$�,�*@�*@�*B�*B�T�EU�EW�EW�*W�*W�$�&[��O�T�\�%;�%;�%=�%=�t�?O�?Q�?Q�^S�&S�T�T�T�&�%�*W�*W��<�#�#�%�%�D�!�"�1�"�X��)@�@�F�Q�L�1�D�M��}��!�!�(��t�Q�7�7��:�
�!�T�]�2�2�2�4S�V`�4`�2�2�2�
;�
X�
X����e�W�T�9��t�}�?U�3U�%V�%V�W�W�W�W�

�������rCc�d�td|j���d|dzz��dzS)z!:return: tuple(offset, binsha, 0)z>L20s���r�r	r�r��rZr<s  rA�	_entry_v1zPackIndexFile._entry_v13s/���7�D�L�$4�$4�$6�$6��q�2�v�
�F�F��N�NrCc�j�td|j���d|dzz��dS)zsee ``_offset_v2``rer�r�rr�r�s  rA�
_offset_v1zPackIndexFile._offset_v17s/���4���!1�!1�!3�!3�T�A��F�]�C�C�A�F�FrCc�`�d|dzzdz}|j���||dz�S)zsee ``_sha_v2``r�r�r�r0�r�r��rZr<�bases   rA�_sha_v1zPackIndexFile._sha_v1;s5���q�2�v���"���|���!�!�$�t�b�y�.�1�1rCc��dS)�unsupportedrrar�s  rA�_crc_v1zPackIndexFile._crc_v1@s���qrCc�~�|�|��|�|��|�|��fS)z#:return: tuple(offset, binsha, crc))�
_offset_v2�_sha_v2�_crc_v2r�s  rA�	_entry_v2zPackIndexFile._entry_v2Gs/������"�"�D�L�L��O�O�T�\�\�!�_�_�E�ErCc��td|j���|j|dzz��d}|dzr<td|j���|j|dzdzz��d}|S)z�:return: 32 or 64 byte offset into pack files. 64 byte offsets will only
            be returned if the pack is larger than 4 GiB, or 2^32rer�rrmrnl�����)r	r�r��_pack_offset�_pack_64_offset)rZr<r4s   rAr�zPackIndexFile._offset_v2Ks����T�4�<�#3�#3�#5�#5�t�7H�1�q�5�7P�Q�Q�RS�T��
�J��	q� ��t�|�'7�'7�'9�'9�4�;O�SY�\g�Sg�kl�Rl�;l�m�m�no�p�F��
rCc�d�|j|dzz}|j���||dz�S)z;:return: sha at the given index of this file index instancer0)�_sha_list_offsetr�r�r�s   rAr�zPackIndexFile._sha_v2Ys4���$�q�2�v�-���|���!�!�$�t�b�y�.�1�1rCc�t�td|j���|j|dzz��dS)z.:return: 4 bytes crc for the object at index irer�r)r	r�r��_crc_list_offsetr�s  rAr�zPackIndexFile._crc_v2^s5���4���!1�!1�!3�!3�T�5J�Q�QR�U�5R�S�S�TU�V�VrCc�D�|�|jdkdz��|_|jdkrn|j|���dzz|_|j|���dzz|_|j|���dzz|_dSdS)zinitialize base datarlr�r0r�N)�_read_fanoutr��
_fanout_tabler��sizer�r�r�rYs rAr�zPackIndexFile._initializefs���!�.�.��
��0B�a�/G�H�H����=�A���$(�$9�D�I�I�K�K�"�<L�$L�D�!� $� 5��	�	���a�� G�D��#'�#4�t�y�y�{�{�Q��#F�D� � � ��rCc
���|j���}t��}|j}t	d��D](}|td|||dzz��d���)|S)z%Generate a fanout table from our data�rer�r)r�r�rXr]rtr	)rZ�byte_offset�d�outr]r<s      rAr�zPackIndexFile._read_fanoutpsn���L�������f�f������s���	A�	A�A��F�;�t�Q��a�!�e�(;�<�<�Q�?�@�@�@�@��
rCc��|jSrW�r�rYs rA�versionzPackIndexFile.version}s
���}�rCc��|jdS)z4:return: amount of objects referred to by this indexrf)r�rYs rAr�zPackIndexFile.size�s���!�#�&�&rCc��|jS)z":return: path to the packindexfile)r�rYs rA�pathzPackIndexFile.path�s
����rCc�D�|j���dd�S)z@:return: 20 byte sha representing the sha1 hash of the pack filer�r�r�rYs rA�packfile_checksumzPackIndexFile.packfile_checksum�s���|���!�!�#�c�'�*�*rCc�D�|j���dd�S)zB:return: 20 byte sha representing the sha1 hash of this index filer�Nr�rYs rA�indexfile_checksumz PackIndexFile.indexfile_checksum�s���|���!�!�#�$�$�'�'rCc�~���jdkrxtjd��}|��j����j�j���tjdkr|�	��|St�fd�t������D����S)z�:return: sequence of all offsets in the order in which they were written

        **Note:** return value can be random accessed, but may be immmutablerl�I�littlec3�B�K�|]}��|��V��dSrW)r4)rh�indexrZs  �rArjz(PackIndexFile.offsets.<locals>.<genexpr>�s/�����L�L�����U�+�+�L�L�L�L�L�LrC)
r��array�	frombytesr�r�r�r��sys�	byteorder�byteswap�tuplertr�)rZ�as` rA�offsetszPackIndexFile.offsets�s�����=�A�����C� � �A�
�K�K���(�(�*�*�4�+<�T�=Q�+Q�R�S�S�S��}��(�(��
�
�����H��L�L�L�L��t�y�y�{�{�9K�9K�L�L�L�L�L�LrCc���t|d��}|j}d}|dkr|j|dz
}|j|}||kr/||zdz}||��}||kr|}n
||kr|S|dz}||k�/dS)z�
        :return: index usable with the ``offset`` or ``entry`` method, or None
            if the sha was not found in this pack index
        :param sha: 20 byte sha to lookuprr,rlN)rrvr�)rZrv�
first_byte�get_sha�lo�hi�mid�mid_shas        rA�sha_to_indexzPackIndexFile.sha_to_index�s���
�c�!�f�%�%�
��(��
����?�?��#�J��N�3�B�
�
�
�
+���2�g�g���7�q�.�C��g�c�l�l�G��W�}�}���������
��1�W���2�g�g��trCc��t|��dkrtd���t|t��s
Jd���t	|d��}|j}d}|dkr|j|dz
}|j|}|tdt|��z
zz}||kr0||zdz}||��}	||	kr|}n||	kr|}n|dz}||k�0||���kr`||��}
t|||
��rDd}|dz|���kr||dz��}|r||
krt|���|SdS)af
        :return: index as in `sha_to_index` or None if the sha was not found in this
            index file
        :param partial_bin_sha: an at least two bytes of a partial binary sha as bytes
        :param canonical_length: length of the original hexadecimal representation of the
            given partial binary sha
        :raise AmbiguousObjectName:rlz'Require at least 2 bytes of partial shazpartial_bin_sha must be bytesrr,r0N)rE�
ValueError�
isinstance�bytesrrvr�r'r�rr)rZ�partial_bin_sha�canonical_lengthr�r�r�r��
filled_shar�r��cur_sha�next_shas            rA�partial_sha_to_indexz"PackIndexFile.partial_sha_to_index�s�������!�#�#��F�G�G�G��/�5�1�1�R�R�3R�R�R�1��o�a�0�1�1�
��(��
����?�?��#�J��N�3�B�
�
�
�
+��%�y�B��_�9M�9M�4M�'N�N�
��2�g�g���7�q�.�C��g�c�l�l�G��G�#�#�����w�&�&�����1�W���2�g�g���	�	������g�b�k�k�G�%�&6���Q�Q�
�����6�D�I�I�K�K�'�'�&�w�r�A�v���H��?��G� 3� 3�-�o�>�>�>��	��trCrc�"�t||��SrWr�rZrvs  rAr�zPackIndexFile.sha_to_index�s��-�d�C�8�8�8rC)r}r~rr�r�rrrsr[r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��globals�
__classcell__)r�s@rAr(r(�s��������%�%� ��#����$�$�$�$�$����#�#�#�PO�O�O�G�G�G�2�2�2�
���F�F�F����2�2�2�
W�W�W�G�G�G�������'�'�'����+�+�+�(�(�(�M�M�M�"���41�1�1�f$�w�w�y�y�0�0�	9�	9�	9�	9�	9�	9�	9�1�0�0�0rCr(c�x�eZdZdZdZdZdZdZdZd�Z	d�Z
d	�Zdd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�ZdS)r)a�A pack is a file written according to the Version 2 for git packs

    As we currently use memory maps, it could be assumed that the maximum size of
    packs therefore is 32 bit on 32 bit systems. On 64 bit systems, this should be
    fine though.

    **Note:** at some point, this might be implemented using streams as well, or
    streams are an alternate path in the case memory maps cannot be created
    for some reason - one clearly doesn't want to read 10GB at once in that
    case)�	_packpathr��_sizer�iKCAPrl�r0c��||_dSrW�r�)rZ�packpaths  rAr[zPackFile.__init__
s
��!����rCc�F�tj|j��d|_dSrW)rr�r�r�rYs rAr�zPackFile.closes ���)�$�.�9�9�9�����rCc��tj|j�����|_td|j���d��\}|_|_||j	krtd|z���dS)N�>LLLrzInvalid pack signature: %i)rr�r�r1r�r	r�r�r��pack_signaturer)rZr�r7s   rAr�zPackFile._set_cache_s{���'���7�7�B�B�D�D���.9����AQ�AQ�AS�AS�UV�-W�-W�*�����
��d�)�)�)��9�G�C�D�D�D�*�)rCTc#��K�|j}|���|jz
}|p|j}t	��}||kr�t||d��\}}t
|j|j|j	t��|jj|j	ksJ�|||j
z
|j���zz
}|r|j�d��|V�||k��dSdS)z7Handle the actual iteration of objects within this packTrN)r�r��footer_size�first_object_offsetr#rBrrHrIr�rr@�_br�pack_offset�compressed_bytes_read�seek)	rZ�start_offsetr5r=�content_size�
cur_offset�null�data_offset�ostreams	         rA�
_iter_objectszPackFile._iter_objects s������L���{�{�}�}�t�'7�7��!�=�T�%=�
��|�|���<�'�'�#1�!�Z��#F�#F� �K��
���d�j�'�,�
�K�K�K��>�%���5�5�5�5��;��)<�<���@d�@d�@f�@f�f�f�J�
�
'���#�#�A�&�&�&��M�M�M��<�'�'�'�'�'�'rCc��|jS)z2:return: The amount of objects stored in this pack)r�rYs rAr�z
PackFile.size:�
���z�rCc��|jS)z!:return: the version of this packr�rYs rAr�zPackFile.version>s
���}�rCc�X�|j������S)z�
        :return: read-only data of this pack. It provides random access and usually
            is a memory map.
        :note: This method is unsafe as it returns a window into a file which might be larger than than the actual window size)r�r1r�rYs rAr6z
PackFile.dataBs$���|�&�&�(�(�,�,�.�.�.rCc��|j�|j���dz
�����dd�S)zE:return: 20 byte sha1 hash on all object sha's contained in this filer0N)r�r1r�r2rYs rA�checksumzPackFile.checksumJs@���|�&�&�t�|�'=�'=�'?�'?�"�'D�E�E�L�L�N�N�q�q�q�Q�QrCc��|jS)z:return: path to the packfiler�rYs rAr�z
PackFile.pathNs
���~�rCc���t��}|j}	t||d��d}|�|��|jt
kr|j|jz
}nn�N|S)a
        :return: list of pack streams which are required to build the object
            at the given offset. The first entry of the list is the object at offset,
            the last one is either a full object, or a REF_Delta stream. The latter
            type needs its reference object to be locked up in an ODB to form a valid
            delta chain.
            If the object at offset is no delta, the size of the list is 1.
        :param offset: specifies the first byte of the object within this packTr,)rXr�rBr]r7rrr;)rZr4r�r=rs     rA�collect_streamszPackFile.collect_streamsUsq���f�f���L��		�$�Q���5�5�a�8�G��J�J�w������)�+�+� �,�w�/A�A���
�		��
rCc�H�t|j|p|jd��dS)z�Retrieve information about the object at the given file-absolute offset

        :param offset: byte offset
        :return: OPackInfo instance, the actual type differs depending on the type_id attributeFr,�rBr�r�rZr4s  rA�infoz
PackFile.infors'��
�d�l�F�,N�d�6N�PU�V�V�WX�Y�YrCc�H�t|j|p|jd��dS)z�Retrieve an object at the given file-relative offset as stream along with its information

        :param offset: byte offset
        :return: OPackStream instance, the actual type differs depending on the type_id attributeTr,rrs  rAr@zPackFile.streamys'��
�d�l�F�,N�d�6N�PT�U�U�VW�X�XrCrc�0�|�|d���S)a�
        :return: iterator yielding OPackStream compatible instances, allowing
            to access the data in the pack directly.
        :param start_offset: offset to the first object to iterate. If 0, iteration
            starts at the very first object in the pack.

        **Note:** Iterating a pack directly is costly as the datastream has to be decompressed
        to determine the bounds between the objectsT�r5�r)rZrs  rA�stream_iterzPackFile.stream_iter�s���!�!�,�$�!�?�?�?rCN)Tr�)r}r~rr�r�r��pack_version_defaultrrr[r�r�rr�r�r6rr�rrr@rrarCrAr)r)�s������	�	�>�I��N��� ���K�"�"�"����
E�
E�
E�����4������/�/�/�R�R�R�������:Z�Z�Z�Y�Y�Y�	@�	@�	@�	@�	@�	@rCr)c���eZdZdZdZeZeZd�Z	d�Z
d�Zd�Zd�Z
dd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Zeddejfd���Zedejfd���ZdS)r*zqCombines the PackIndexFile and the PackFile into one, allowing the
    actual objects to be resolved and iterated)�_index�_pack�_offset_mapc��tj�|��\}}|�d|z��|_|�d|z��|_dS)zGInitialize ourselves with the path to the respective pack or index filez%s.idxz%s.packN)�osr��splitext�IndexFileClsr!�PackFileClsr")rZ�pack_or_index_path�basename�exts    rAr[zPackEntity.__init__�sT����(�(�);�<�<�
��#��'�'��8�(;�<�<����%�%�i�(�&:�;�;��
�
�
rCc�j�|j���|j���dSrW)r!r�r"rYs rAr�zPackEntity.close�s0����������
�������rCc���t|j�����}t|j�����|jjz
}|s
Jd���d}t|��dkr|d|i}nWt|��}t|��}t|��t||��}t|��}|||d<||_dS)NzCannot handle empty indicesr,r���)�sortedr!r�rEr"r6r�iter�next�zip�dictr#)rZr��offsets_sorted�last_offset�
offset_map�iter_offsets�iter_offsets_plus_one�consecutives        rAr�zPackEntity._set_cache_�s���
 ��� 3� 3� 5� 5�6�6���$�*�/�/�+�+�,�,�t�z�/E�E���<�<�<�<�<�~��
��~���!�#�#�(��+�[�9�J�J���/�/�L�$(��$8�$8�!��&�'�'�'��l�,A�B�B�K��k�*�*�J�.9�J�~�b�)�*�%����rCc�\�|j�|��}|�t|���|S)z*:return: index for the given sha, or raise)r!r�r)rZrvr�s   rA�
_sha_to_indexzPackEntity._sha_to_index�s-����(�(��-�-���=��C�.�.� ��rCc#�K�|jj}|j}t|j�����D]}|||��||��V��dS)zPIterate over all objects in our index and yield their OInfo or OStream instencesN)r!rv�_objectrtr�)rZr5�_shar=r�s     rArzPackEntity._iter_objects�sj�����{����,���4�;�+�+�-�-�.�.�	9�	9�E��'�$�$�u�+�+�y�%�8�8�8�8�8�8�	9�	9rCr.c��|dkr|�|��}|�|j�|��}|j�|��}t	|jj�|�������\}}}|r�|tvr;|j�
|��}t||j|j
|j
��S|�|��}	tj|	��}
t#||
jd|
��S|tvrt%|t&||��S|�|��}	|	d�d��}t+|��\}}t+||��\}}
|	djtvrt/|d���t%||	dj|
��S)z�:return: OInfo or OStream object providing information about the given sha
        :param index: if not -1, its assumed to be the sha's index in the IndexFilerNir.zCould not resolve delta object)r;r!rvr4r
r"r�r1r2rr@r�typer��collect_streams_at_offsetr!�newrrrrHrr7r)rZrvr5r�r4r7r8r9�
packstream�streams�dstream�buf�src_size�target_sizes              rAr=zPackEntity._object�s����1�9�9��&�&�s�+�+�E��;��+�/�/�%�(�(�C���#�#�E�*�*��1H���I[�If�If�gm�In�In�Iu�Iu�Iw�Iw�1x�1x�.���.��	=��k�)�)�!�Z�.�.�v�6�6�
��s�J�O�Z�_�j�FW�X�X�X��4�4�V�<�<�G�&�*�7�3�3�G���W�\�4��A�A�A��k�)�)��S�"5�g�">��L�L�L�
�4�4�V�<�<�G��!�*�/�/�#�&�&�C�'��}�}��F�H�"*�3��"7�"7��F�K��r�{�"�k�1�1���%E�F�F�F���g�b�k�.��<�<�<rCc�.�|�|d��S)z�Retrieve information about the object identified by the given sha

        :param sha: 20 byte sha1
        :raise BadObject:
        :return: OInfo instance, with 20 byte shaF�r=r�s  rArzPackEntity.info�s���|�|�C��'�'�'rCc�.�|�|d��S)z�Retrieve an object stream along with its information as identified by the given sha

        :param sha: 20 byte sha1
        :raise BadObject:
        :return: OStream instance, with 20 byte shaTrJr�s  rAr@zPackEntity.streams���|�|�C��&�&�&rCc�0�|�dd|��S)zMAs ``info``, but uses a PackIndexFile compatible index to refer to the objectNFrJ�rZr�s  rA�
info_at_indexzPackEntity.info_at_index	s���|�|�D�%��/�/�/rCc�0�|�dd|��S)zWAs ``stream``, but uses a PackIndexFile compatible index to refer to the
        objectNTrJrMs  rA�stream_at_indexzPackEntity.stream_at_index
s���|�|�D�$��.�.�.rCc��|jS)z*:return: the underlying pack file instance)r"rYs rAr%zPackEntity.packrrCc��|jS)z0:return: the underlying pack index file instance)r!rYs rAr�zPackEntity.indexs
���{�rCFc��|r�|j���dkrtd���|�|��}|j�|��}|j|}|j�|��}tj}|j	�
��}|}	d}
|	|kr?t|	tz|��}||	z
}|||	|	|z�|
��}
|	|z
}	|	|k�?|
dz|kSt��}
|�|d���}t|j|j|j|
j��|
�d���|ksJ�|
�d���|kS)	a�
        Verify that the stream at the given sha is valid.

        :param use_crc: if True, the index' crc is run over the compressed stream of
            the object, which is much faster than checking the sha1. It is also
            more prone to unnoticed corruption or manipulation.
        :param sha: 20 byte sha1 of the object whose stream to verify
            whether the compressed stream of the object is valid. If it is
            a delta, this only verifies that the delta's data is valid, not the
            data of the actual undeltified object, as it depends on more than
            just this stream.
            If False, the object will be decompressed and the sha generated. It must
            match the given sha

        :return: True if the stream is valid
        :raise UnsupportedOperation: If the index is version 1 only
        :raise BadObject: sha was not foundrlz=Version 1 indices do not contain crc's, verify by sha insteadrrkTrFro)r!r�rr;r4r#rO�zlibr&r"r6�minrr"r=rr@r�rHrIrv)rZrv�use_crcr�r4�next_offset�	crc_value�
crc_update�	pack_data�cur_pos�this_crc_value�rboundr��	shawriterr@s               rA�is_valid_streamzPackEntity.is_valid_streams���$�!	6��{�"�"�$�$�q�(�(�*�+j�k�k�k��&�&�s�+�+�E��[�'�'��.�.�F��*�6�2�K������.�.�I���J��
���)�)�I��G��N��K�'�'��W�z�1�;�?�?����'��!+��I�g�g��n�6L�,M�~�!^�!^���4���	�K�'�'�#�Z�/�I�=�=�"���I��\�\�#��\�6�6�F����f�k�6�;�	��P�P�P��=�=��=�.�.�#�5�5�5�5��=�=��=�.�.�#�5�5rCc�.�|�d���S)zi
        :return: Iterator over all objects in this pack. The iterator yields
            OInfo instancesFrrrYs rA�	info_iterzPackEntity.info_iterUs���!�!�E�!�2�2�2rCc�.�|�d���S)zk
        :return: iterator over all objects in this pack. The iterator yields
            OStream instancesTrrrYs rArzPackEntity.stream_iter[s���!�!�D�!�1�1�1rCc��|j�|��}|djtk�r |d}|jtv�r	|jtkr�t|jt��r2|j�	|j�
����}n|j�	|j��}|�n�|j�|j�|����}|�
|��n4|j�|j��}|�
|��|jtv��	|S)z�
        As the version in the PackFile, but can resolve REF deltas within this pack
        For more info, see ``collect_streams``

        :param offset: offset into the pack file at which the object can be foundr.)r"rr7rrr�r;�
memoryviewr!r��tobytesr@r4r])rZr4rDr@�sindexs     rArAz$PackEntity.collect_streams_at_offsetas(���*�,�,�V�4�4���2�;��)�+�+��R�[�F��.�K�/�/��>�Y�.�.�!�&�"3�Z�@�@�M�!%��!9�!9�&�:K�:S�:S�:U�:U�!V�!V���!%��!9�!9�&�:K�!L�!L���~��!�Z�.�.�t�{�/A�/A�&�/I�/I�J�J�F��N�N�6�*�*�*�*�
"�Z�.�.�v�/@�A�A�F��N�N�6�*�*�*�!�.�K�/�/�*�rCc��|�|j�|�|������S)ab
        As ``PackFile.collect_streams``, but takes a sha instead of an offset.
        Additionally, ref_delta streams will be resolved within this pack.
        If this is not possible, the stream will be left alone, hence it is adivsed
        to check for unresolved ref-deltas and resolve them before attempting to
        construct a delta stream.

        :param sha: 20 byte sha1 specifying the object whose related streams you want to collect
        :return: list of streams, first being the actual object delta, the last being
            a possibly unresolved base object.
        :raise BadObject:)rAr!r4r;r�s  rArzPackEntity.collect_streams�s7���-�-�d�k�.@�.@��AS�AS�TW�AX�AX�.Y�.Y�Z�Z�ZrCNc���|}|s:t|ttf��st|��}t|��}t	|��}|j}d}	d}
|du}|t
dtjtj	|����|	dz
}	|rt��}
d}|D]�}
|dz
}d}t|
j|
j
��}|rt|��}nd}||��tj|��}|
j}t%|j|||���\}}}||
j
ksJ�|r|
�|
j||	��|	t|��|zz
}	||krn��||krt-d||fz���|�d�	��}t|��d
ksJ�||��|	t|��z
}	d}|r|
�||��}||fS)a�
        Create a new pack by putting all objects obtained by the object_iterator
        into a pack which is written using the pack_write method.
        The respective index is produced as well if index_write is not Non.

        :param object_iter: iterator yielding odb output objects
        :param pack_write: function to receive strings to write into the pack stream
        :param indx_write: if not None, the function writes the index file corresponding
            to the pack.
        :param object_count: if you can provide the amount of objects in your iteration,
            this would be the place to put it. Otherwise we have to pre-iterate and store
            all items into a list to get the number, which uses more memory than necessary.
        :param zlib_compression: the zlib compression level to use
        :return: tuple(pack_sha, index_binsha) binary sha over all the contents of the pack
            and over all contents of the index. If index_write was None, index_binsha will be None

        **Note:** The destination of the write functions is up to the user. It could
        be a socket, or a file for instance

        **Note:** writes only undeltified objectsrNr�r�r,)rKzKExpected to write %i objects into pack, but received only %i from iteratorsFror0)r�r�rXrEr$rIr%r)r�rrTrr7r�r&rT�compressobjr@rRrHr]r^r�rv)�cls�object_iter�
pack_write�index_write�object_count�zlib_compression�objs�pack_writer�pwriter|r��wants_index�actual_count�objrO�hdrrJrrLrMrw�	index_shas                      rA�
write_packzPackEntity.write_pack�sI��.���	%��k�E�4�=�9�9�
)��K�(�(���t�9�9�L�)��4�4���"������!��-��	��t�F�H�3�X�5R�T`�a�a�b�b�b��r�	���	"��M�M�E����	�	�C��A��L��C�,�C�K���B�B�C��
��C�j�j������F�3�K�K�K��&�'7�8�8�G��j�G�.�w�|�V�W�WZ�[�[�[�K�B��C����>�>�>�>��
3����S�Z��c�2�2�2�
�3�s�8�8�b�=� �C��|�+�+���,�
�<�'�'��]�am�o{�`|�|�~�~�
~�
�?�?�%�?�0�0���8�}�}��"�"�"�"��
�8�����s�8�}�}����	��	;����H�k�:�:�I���"�"rCc�<���tjdd|��\�}tjdd|��\�}�fd�}�fd�}|�|||||��\}	}
tj���tj���d}tj�||t|	��dfz��}tj�||t|	��dfz��}
tj||��tj||
��||��S)a�Create a new on-disk entity comprised of a properly named pack file and a properly named
        and corresponding index file. The pack contains all OStream objects contained in object iter.
        :param base_dir: directory which is to contain the files
        :return: PackEntity instance initialized with the new pack

        **Note:** for more information on the other parameters see the write_pack method�r%r�c�.��tj�|��SrW�r%rI)r��pack_fds �rArcz#PackEntity.create.<locals>.<lambda>�s���r�x���3�3�rCc�.��tj�|��SrWr|)r��index_fds �rArcz#PackEntity.create.<locals>.<lambda>�s������1� 5� 5�rCz
pack-%s.%s�idx)	�tempfile�mkstemprxr%r�r�rur
�rename)rjrk�base_dirrnro�	pack_path�
index_pathrlrm�pack_binsha�index_binsha�fmt�
new_pack_path�new_index_pathrr}s              @@rA�createzPackEntity.create�s����&�-�b�&�(�C�C����'�/��G�X�F�F���*�3�3�3�3�
�5�5�5�5��$'�N�N�;�
�K�Ye�gw�$x�$x�!��\�
������
������������X�s�j��6M�6M�v�5V�/V�W�W�
�����h��z�+�7N�7N�PU�6V�0V�W�W��
�	�)�]�+�+�+�
�	�*�n�-�-�-��s�=�!�!�!rC)r.)F)r}r~rr�r�r(r'r)r(r[r�r�r;rr=rr@rNrPr%r�r_rarrAr�classmethodrT�Z_BEST_SPEEDrxr�rarCrAr*r*�s�������2�2��I�
!�L��K�<�<�<����&�&�&�2���9�9�9�'=�'=�'=�'=�X(�(�(�'�'�'�0�0�0�/�/�/�������5�5�5�5�n3�3�3�2�2�2�!�!�!�F[�[�[��=A� $�t�7H�Y#�Y#�Y#��[�Y#�v�8<�t�O`�"�"�"��[�"�"�"rCr*rW);r�rT�	gitdb.excrrrr�
gitdb.utilrrr	r
r�	gitdb.funrr
rrrrrrrrr�gitdb_speedups._perfr�ImportError�
gitdb.baserrrrrrr�gitdb.streamr r!r"r#r$�structr%�binasciir&�gitdb.constr'r�r�r%r��__all__rBrRrTr(r)r*rarCrA�<module>r�sZ��
:�9���������������������������������������������������������	�?�?�?�?�?�?�?���	�	�	��D�	������������������������������������������������!�!�!�!�!�!���������	�	�	�	�
�
�
�
�
5��
1]�1]�1]�l%�%�%�%�VD�D�D�D�D�D�D�D�N~9�~9�~9�~9�~9�I�~9�~9�~9�HQ@�Q@�Q@�Q@�Q@�y�Q@�Q@�Q@�lw"�w"�w"�w"�w"��w"�w"�w"�w"�w"s�A�A�
A

Hacked By AnonymousFox1.0, Coded By AnonymousFox