HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/mercurial/revlogutils/__pycache__/sidedata.cpython-310.pyc
o

�]Lb��@s�dZddlmZddlZddlZddlmZmZddl	m
Z
mZddlm
Z
dZdZd	Zd
ZdZdZd
ZdZdZdZdZdZe�d�Ze�d�Zdd�Zdd�Zd dd�Zdd�Z dd�Z!dS)!aacore code for "sidedata" support

The "sidedata" are stored alongside the revision without actually being part of
its content and not affecting its hash. It's main use cases is to cache
important information related to a changesets.

The current implementation is experimental and subject to changes. Do not rely
on it in production.

Sidedata are stored in the revlog itself, thanks to a new version of the
revlog. The following format is currently used::

    initial header:
        <number of sidedata; 2 bytes>
    sidedata (repeated N times):
        <sidedata-key; 2 bytes>
        <sidedata-entry-length: 4 bytes>
        <sidedata-content-sha1-digest: 20 bytes>
        <sidedata-content; X bytes>
    normal raw text:
        <all bytes remaining in the rawtext>

This is a simple and effective format. It should be enough to experiment with
the concept.
�)�absolute_importN�)�error�requirements)�	constants�flagutil)�hashutil��������	�
��z>Hz>HL20scCs~t|���}|��t�t|��g}|D]\}}t�|���}|�	t
�|t|�|��q|D]	\}}|�	|�q.d�|�}|S)N�)�list�items�sort�SIDEDATA_HEADER�pack�lenr�sha1�digest�append�SIDEDATA_ENTRY�join)�sidedata�buf�key�valuer�r$�@/usr/lib/python3/dist-packages/mercurial/revlogutils/sidedata.py�serialize_sidedata@s
r&c
Cs�i}d}t�|dtj��\}|tj7}tjtj|}t|�D]9}|tj}t�|||��\}}}	|}||}
t|||
��}t�|���}|	|krSt	�
||	|��|||<|
}q |S)Nr)r�unpack�sizer�range�bytesrrrr�SidedataHashError)
�blobr �offset�nbentry�
dataoffset�i�
nextoffsetr"r(�storeddigest�nextdataoffset�	entrytext�
readdigestr$r$r%�deserialize_sidedataMs"

r6FcCs�t�t�}t�t�}||j}|j|}|r||}}|j��D]#\}}|��D]\}	}
|	|vr7||�|
�|	|vrB||�|
�q(q |||f}|S)a
    Returns a dictionary mapping revlog types to tuples of
    `(repo, computers, removers)`:
        * `repo` is used as an argument for computers
        * `computers` is a list of `(category, (keys, computer, flags)` that
           compute the missing sidedata categories that were asked:
           * `category` is the sidedata category
           * `keys` are the sidedata keys to be affected
           * `flags` is a bitmask (an integer) of flags to remove when
              removing the category.
           * `computer` is the function `(repo, store, rev, sidedata)` that
             returns a tuple of
             `(new sidedata dict, (flags to add, flags to remove))`.
             For example, it will return `({}, (0, 1 << 15))` to return no
             sidedata, with no flags to add and one flag to remove.
        * `removers` will remove the keys corresponding to the categories
          that are present, but not needed.
        If both `computers` and `removers` are empty, sidedata will simply not
        be transformed.
    )�collections�defaultdictr�_wanted_sidedata�_sidedata_computersrr)�repo�remote_sd_categories�pull�sd_computers�sd_removers�to_generate�	to_remove�revlog_kind�	computers�category�computer�sidedata_helpersr$r$r%�get_sidedata_helpersbs 




��
rGcCs�|\}}}|j}d}d}	|�|g�D]\}
}}|||||�\}}
||
dO}|	|
dO}	q|�|g�D]\}}}
|D]}|�|d�q:|	|
O}	q3|||	ffS)aOReturns the sidedata for the given revision after running through
    the given helpers.
    - `store`: the revlog this applies to (changelog, manifest, or filelog
      instance)
    - `sidedata_helpers`: see `get_sidedata_helpers`
    - `sidedata`: previous sidedata at the given rev, if any
    - `rev`: affected rev of `store`
    rr	N)rB�get�pop)�storerFr �revr;r>r?�kind�flags_to_add�flags_to_remove�_keys�sd_computer�_flags�flags�keys�	_computerr"r$r$r%�run_sidedata_helpers�s
	
rUcCs@ddlm}tj|jvr|�t�|�tj	ttf|j
tj�dS)Nr)�metadata)
�rV�requirementsmod�COPIESSDC_REQUIREMENTr�register_wanted_sidedata�SD_FILES�register_sidedata_computerr�KIND_CHANGELOG�copies_sidedata_computerr�REVIDX_HASCOPIESINFO)r;rVr$r$r%�set_sidedata_spec_for_repo�s
�r`)F)"�__doc__�
__future__rr7�structrWrrrX�revlogutilsrr�utilsr�SD_TEST1�SD_TEST2�SD_TEST3�SD_TEST4�SD_TEST5�SD_TEST6�SD_TEST7�SD_P1COPIES�SD_P2COPIES�
SD_FILESADDED�SD_FILESREMOVEDr[�Structrrr&r6rGrUr`r$r$r$r%�<module>s4


)