File: //usr/lib/python3/dist-packages/mercurial/revlogutils/__pycache__/sidedata.cpython-310.pyc
o
�]Lb� � @ s� d Z ddlmZ ddlZddlZddlmZmZ ddl m
Z
mZ ddlm
Z
dZdZd Zd
ZdZdZd
ZdZdZdZdZdZe�d�Ze�d�Zdd� Zdd� Zd dd�Zdd� Z dd� Z!dS )!aa core 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>HL20sc C s~ 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&