403Webshell
Server IP : 217.160.0.212  /  Your IP : 216.73.216.6
Web Server : Apache
System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
User : u119869361 ( 9600978)
PHP Version : 8.4.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /kunden/lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /kunden/lib/python3/dist-packages/mercurial/__pycache__/bundle2.cpython-313.pyc
�

6�hVj��8�%SrSSKJr SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKJr SSK
JrJr SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJr SSKJ r J!r! SS	K"J#r# \
RH(a$SS
K
J%r%J&r&J'r'J(r(J)r)J*r* \%\+\*\'\+\)\+S444r,\RZr-\R\r.\R^r0\Rbr2Sr3Sr4S
r5Sr6Sr7Sr8Sr9\Rt"S5r;Sr<Sr=Sr>Sr?0r@S�SjrA"SS5rB"SS5rC"SS\D5rESrFS�SjrG"S S!5rHS�S"jrIS#rJS$rKS%rLS&rMS�S(jrNS)rOS*SS+S,S-S..rP/S/QrQ"S0S15rR"S2S35rSS�S4jrT"S5S6\S5rUS7\U0rV0rWS8rX\X"S95S:5rY"S;S<5rZS=r["S>S?\S5r\"S@SA5r]SBr^"SCSD\S5r_"SESF\_5r`SSSGSS\a"\b"\R�R�555SHSSISJSK.
reS'\fSL'S�S�SMjjrgS�SNjrhS�SOjriS�SPjrjSQrkSRrlSSrmSTrnSUroSVrpSWrqSXrrSYrsS�SZjrtS�S[jruS\rv\A"S]S^5S_5rw\a"/S`Q\R�R�5Vs/sHnSaU-PM
 sn-5rx\A"Sb\x5Sc5ry\A"SdSe5Sf5rz\A"Sg5Sh5r{\A"Si5Sj5r|\A"Sk5Sl5r}\A"Sm5Sn5r~\A"So5Sp5r\A"Sq5Sr5r�"SsSt\GR5r�\A"SuSv5Sw5r�\A"SxSy5Sz5r�\A"S{S|5S}5r�\A"S~S5S�5r�\A"S�S�5S�5r�\A"S�S�5S�5r�\A"S�5S�5r�\A"S�5S�5r�\A"S�Se5S�5r�\A"S�5S�5r�\A"S�S�5S�5r�\A"S�5S�5r�\GR"S�5r�\A"S�5S�5r�\A"S�5S�5r�\A"S�S�5S�5r�\A"S�S�5S�5r�S�r�gs snf)�a�Handling of the new bundle2 format

The goal of bundle2 is to act as an atomically packet to transmit a set of
payloads in an application agnostic way. It consist in a sequence of "parts"
that will be handed to and processed by the application layer.


General format architecture
===========================

The format is architectured as follow

 - magic string
 - stream level parameters
 - payload parts (any number)
 - end of stream marker.

the Binary format
============================

All numbers are unsigned and big-endian.

stream level parameters
------------------------

Binary format is as follow

:params size: int32

  The total number of Bytes used by the parameters

:params value: arbitrary number of Bytes

  A blob of `params size` containing the serialized version of all stream level
  parameters.

  The blob contains a space separated list of parameters. Parameters with value
  are stored in the form `<name>=<value>`. Both name and value are urlquoted.

  Empty name are obviously forbidden.

  Name MUST start with a letter. If this first letter is lower case, the
  parameter is advisory and can be safely ignored. However when the first
  letter is capital, the parameter is mandatory and the bundling process MUST
  stop if he is not able to proceed it.

  Stream parameters use a simple textual format for two main reasons:

  - Stream level parameters should remain simple and we want to discourage any
    crazy usage.
  - Textual data allow easy human inspection of a bundle2 header in case of
    troubles.

  Any Applicative level options MUST go into a bundle2 part instead.

Payload part
------------------------

Binary format is as follow

:header size: int32

  The total number of Bytes used by the part header. When the header is empty
  (size = 0) this is interpreted as the end of stream marker.

:header:

    The header defines how to interpret the part. It contains two piece of
    data: the part type, and the part parameters.

    The part type is used to route an application level handler, that can
    interpret payload.

    Part parameters are passed to the application level handler.  They are
    meant to convey information that will help the application level object to
    interpret the part payload.

    The binary format of the header is has follow

    :typesize: (one byte)

    :parttype: alphanumerical part name (restricted to [a-zA-Z0-9_:-]*)

    :partid: A 32bits integer (unique in the bundle) that can be used to refer
             to this part.

    :parameters:

        Part's parameter may have arbitrary content, the binary structure is::

            <mandatory-count><advisory-count><param-sizes><param-data>

        :mandatory-count: 1 byte, number of mandatory parameters

        :advisory-count:  1 byte, number of advisory parameters

        :param-sizes:

            N couple of bytes, where N is the total number of parameters. Each
            couple contains (<size-of-key>, <size-of-value) for one parameter.

        :param-data:

            A blob of bytes from which each parameter key and value can be
            retrieved using the list of size couples stored in the previous
            field.

            Mandatory parameters comes first, then the advisory ones.

            Each parameter's key MUST be unique within the part.

:payload:

    payload is a series of `<chunksize><chunkdata>`.

    `chunksize` is an int32, `chunkdata` are plain bytes (as much as
    `chunksize` says)` The payload part is concluded by a zero size chunk.

    The current implementation always produces either zero or one chunk.
    This is an implementation limitation that will ultimately be lifted.

    `chunksize` can be negative to trigger special case processing. No such
    processing is in place yet.

Bundle processing
============================

Each part is processed in order using a "part handler". Handler are registered
for a certain part type.

The matching of a part to its handler is case insensitive. The case of the
part type is used to know if a part is mandatory or advisory. If the Part type
contains any uppercase char it is considered mandatory. When no handler is
known for a Mandatory part, the process is aborted and an exception is raised.
If the part is advisory and no handler is known, the part is ignored. When the
process is aborted, the full bundle is still read from the stream to keep the
channel usable. But none of the part read from an abort are processed. In the
future, dropping the stream may become an option for channel we do not care to
preserve.
�)�annotationsN�)�_)�hex�short)�	bookmarks�changegroup�encoding�error�obsolete�phases�pushkey�pycompat�requirements�scmutil�streamclone�tags�url�util)�
stringutil�urlutil)�
repository)�Dict�Iterator�List�Optional�Tuple�Union.s>is>Bs>Is>BB��s[^a-zA-Z0-9_:-]c�\�URSS5(aURSU-5 gg)z(debug regarding output stream (bundling)�devel�
bundle2.debugsbundle2-output: %s
N��
configbool�debug��ui�messages  �3/usr/lib/python3/dist-packages/mercurial/bundle2.py�outdebugr*�s+��	�}�}�X�/�0�0�
���(�7�2�3�1�c�\�URSS5(aURSU-5 gg)z"debug on input stream (unbundling)r!r"sbundle2-input: %s
Nr#r&s  r)�indebugr-�s+��	�}�}�X�/�0�0�
���'�'�1�2�1r+c�N�[RU5(a[U5eg)z9raise ValueError if a parttype contains invalid characterN)�_parttypeforbidden�search�
ValueError��parttypes r)�validateparttyper4�s#��� � ��*�*���"�"�+r+c��SSU--$)z�return a struct format to read part parameter sizes

The number parameters is variable so we need to build that format
dynamically.
�>sBB�)�nbparamss r)�_makefpartparamsizesr9�s���5�8�#�$�$r+r7c�.^^�[T5 UU4SjnU$)z�decorator that register a function as a bundle2 part handler

eg::

    @parthandler('myparttype', ('mandatory', 'param', 'handled'))
    def myparttypehandler(...):
        '''process a part of type "my part".'''
        ...
c�r>�TR5nU[;deU[U'[T5UlU$�N)�lower�parthandlermapping�	frozenset�params)�func�	lparttyper@r3s  ��r)�
_decorator�parthandler.<locals>._decorators:����N�N�$�	�� 2�2�2�2�(,��9�%���'����r+)r4)r3r@rCs`` r)�parthandlerrE�s����X����r+c�J�\rSrSrSrSrSSjrSrSrSr	S	r
S
r\rSr
g)
�unbundlerecordsiaukeep record of what happens during and unbundle

New records are added using `records.add('cat', obj)`. Where 'cat' is a
category of record and obj is an arbitrary object.

`records['cat']` will return all entries of this category 'cat'.

Iterating on the object itself will yield `('category', obj)` tuples
for all entries.

All iterations happens in chronological order.
c�.�0Ul/Ul0Ulgr<)�_categories�
_sequences�_replies��selfs r)�__init__�unbundlerecords.__init__s����������
r+Nc���URRU/5RU5 URRX45 Ub!UR	U5RX5 gg)zpadd a new record of a given category.

The entry can then be retrieved in the list returned by
self['category'].N)rI�
setdefault�appendrJ�
getreplies�add)rM�category�entry�	inreplytos    r)rT�unbundlerecords.adds\��
	
���#�#�H�b�1�8�8��?�������0�1�� ��O�O�I�&�*�*�8�;�!r+c�J�URRU[55$)z3get the records that are replies to a specific part)rKrQrG)rM�partids  r)rS�unbundlerecords.getreplies)s���}�}�'�'���0A�B�Br+c�L�[URRUS55$)Nr7)�tuplerI�get)rM�cats  r)�__getitem__�unbundlerecords.__getitem__-s ���T�%�%�)�)�#�r�2�3�3r+c�,�[UR5$r<)�iterrJrLs r)�__iter__�unbundlerecords.__iter__0����D�O�O�$�$r+c�,�[UR5$r<)�lenrJrLs r)�__len__�unbundlerecords.__len__3s���4�?�?�#�#r+c�,�[UR5$r<)�boolrJrLs r)�__nonzero__�unbundlerecords.__nonzero__6rfr+)rIrKrJr<)�__name__�
__module__�__qualname__�__firstlineno__�__doc__rNrTrSr`rdrirm�__bool__�__static_attributes__r7r+r)rGrGs2����
<�C�4�%�$�%��Hr+rGc�4�\rSrSrSrSSjrSrSrSrg)	�bundleoperationi<a(an object that represents a single bundling process

Its purpose is to carry unbundle-related objects and states.

A new object should be created at the beginning of each bundle processing.
The object is to be returned by the processing function.

The object has very little content now it will ultimately contain:
* an access to the repo the bundle is applied to,
* a ui object,
* a way to retrieve a transaction to add changes to the repo,
* a way to record the result of processing each part,
* a way to construct a bundle response when applicable.
Nc��XlXPlURUl[5UlSUlX0l0UlX l0Ul	X@l
gr<)�repo�remoter'rG�records�reply�
captureoutput�hookargs�_gettransaction�modes�source)rMry�transactiongetterr}r�rzs      r)rN�bundleoperation.__init__LsI���	����'�'���&�(�����
�*����
�0����
��r+c���UR5nUR(a6URRUR5 URUlSUlU$r<)rr~�update)rM�transactions  r)�gettransaction�bundleoperation.gettransactionasL���*�*�,���=�=�
�M�M� � ��!5�!5�6�#'�=�=�K� ���
��r+c��URc[R"S5eURRU5 g)Ns@attempted to add hookargs to operation after transaction started)r~r�ProgrammingErrorr�)rMr~s  r)�addhookargs�bundleoperation.addhookargsps8���=�=� ��(�(�7��
�	
�
�
���X�&r+)
rr}r~r�r{rzr|ryr�r')Tr+N)	rorprqrrrsrNr�r�rur7r+r)rwrw<s!��
�&���
�*
�'r+rwc��\rSrSrSrg)�TransactionUnavailableiyr7N)rorprqrrrur7r+r)r�r�ys��r+r�c��[5e)z�default method to get a transaction while processing a bundle

Raise an exception to highlight the fact that no transaction was expected
to be created�r�r7r+r)�_notransactionr�}s
��
!�
"�"r+c�0^�[U[5(abSTRS'UbSTR;aUTRS'UbSTR;aUTRS'[XU4SjX5S9$[	UU4SjX5S9n[XqTX440UD6 U$)N�1�bundle2ssource�urlc�>�T$r<r7��trs�r)�<lambda>�applybundle.<locals>.<lambda>�s���Rr+�r�rzc�>�T$r<r7r�s�r)r�r��s���2r+)�
isinstance�
unbundle20r~�
processbundlerw�_processchangegroup)ry�	unbundlerr�r�rrz�kwargs�ops  `     r)�applybundler��s�����)�Z�(�(�"&����J����)�2�;�;�">�%+�B�K�K�	�"��?�v�R�[�[�8�"%�B�K�K�����Z��
�	
�
�T�:�f�
L���B�2�v�E�f�E��	r+c�&�\rSrSrSrSrSrSrg)�partiteratori�c�R�XlX lX0lSUlSUlSUlg)Nr)ryr�r��iterator�count�current)rMryr�r�s    r)rN�partiterator.__init__�s&���	���"����
���
���r+c�@^�U4SjnU"5TlTR$)Nc3�># �[TRR5S5nUH.upUTlUTlUv� UR5 STlM0 g7f)Nr)�	enumerater��	iterpartsr�r��consume)�itrr��prMs   �r)rA�$partiterator.__enter__.<locals>.func�sN�����D�N�N�4�4�6��:�C����"��
� ������	�	��#��� �s�AA)r�)rMrAs` r)�	__enter__�partiterator.__enter__�s���	$����
��}�}�r+c�r�UR(dg[U[5(a�SnUR(aURR	5 URHnUR	5 M SUl/nSnURRbDURRR5nURRRnXrl
XblU(aUeURRRSUR-5 g![a SnN�f=f)NFTs%bundle2-input-bundle: %i parts total
)r�r��	Exceptionr�r��duringunbundle2r�r|�
salvageoutput�capabilities�
_replycaps�_bundle2salvagedoutputryr'r%r�)rM�type�exc�tb�	seekerror�part�salvaged�	replycapss        r)�__exit__�partiterator.__exit__�s����}�}��
�c�9�%�%��I�	
!��<�<��L�L�(�(�*� �M�M�D��L�L�N�*�#'�C���H��I��w�w�}�}�(��7�7�=�=�6�6�8�� �G�G�M�M�6�6�	�&�N�)1�&���	��	�	�����5��
�
�B�	
��-�
!� �	�
!�s�AD'�'D6�5D6)r�r�r�r�ryr�N)rorprqrrrNr�r�rur7r+r)r�r��s����.
r+r�c��UcUc[n[UUUUS9nUR URR(a�S/nUR(a'URS[
UR5-5 URbUR[LaURS5 OURS5 URS5 URRSRU55 [XU5 U$)aThis function process a bundle, apply effect to/from a repo

It iterates over each part then searches for and uses the proper handling
code to process the part. Parts are processed in order.

Unknown Mandatory part will abort the process.

It is temporarily possible to provide a prebuilt bundleoperation to the
function. This is used to ensure output is properly propagated in case of
an error during the unbundling. This output capturing part will likely be
reworked and this ability will probably go away in the process.
r�sbundle2-input-bundle:s
 %i paramss no-transactions with-transaction�
r+)r�rwr@r'�	debugflagrRrhrr%�join�processparts)ryr�r�r�r�rz�msgs       r)r�r��s���(
�z��$� .��
�����	
������w�w���'�(������J�J�}�s�9�+;�+;�'<�<�=�
���%��);�);�~�)M��J�J�)�*��J�J�+�,��
�
�5�����
�
�c�h�h�s�m�$���9�%�
�Ir+c�x�[XU5nUHn[X5 M SSS5 g!,(df   g=fr<)r��_processpart)ryr�r��partsr�s     r)r�r�s,��	�d�	�	*�e��D���"��
+�	*�	*�s�+�
9c�2�URbLURRb5URRnUR5nURUS'UR"UR
X#U40UD6nURRSSU05 U$)N�delta_base_reuse_policy�changegroup�return)rz�path�copy�delta_reuse_policy�applyryr{rT)r��cgr�r�rr��remote_path�rets        r)r�r�s���	�y�y�������!;��i�i�n�n�������,7�,J�,J��(�)�
�(�(�2�7�7�B��
6�v�
6�C��J�J�N�N���s�	
���Jr+c�	�Sn[RUR5nUc Sn[R"URS9e[URSUR-5 URUR-
nU(aN[U5nUR5 SSRU5-n[R"URUS9eSnURR(GaS
UR-/nUR(dURS5 [UR5n[UR5U-
nU(dU(aXURS5 U(aURS
U-5 U(aURSU-5 URS5 URSU-5 URR!SRU55 U$![RGaUnUR(ae[URS	U-5 SnAURR(GaS
UR-/nUR(dURS5 [UR5n[UR5U-
nU(dU(aXURS5 U(aURS
U-5 U(aURSU-5 URS5 URSU-5 URR!SRU55 ggSnAff=f!URR(GaS
UR-/nUR(dURS5 [UR5n[UR5U-
nU(dU(aXURS5 U(aURS
U-5 U(aURSU-5 URS5 URSU-5 URR!SRU55 ff=f)Nsunknownsunsupported-typer2sfound a handler for part %ssunsupported-params (%s)s, )r3r@s	supporteds%ignoring unsupported advisory part %ssbundle2-input-part: "%s"� (advisory)�	 (params:�
 %i mandatory� %i advisory�)s %s
r+)r>r^r�r�BundleUnknownFeatureErrorr-r'�
mandatorykeysr@�list�sortr��	mandatoryr�rRrhr%)	r�r��status�handler�
unknownparamsr�r��nbmp�nbaps	         r)�_gethandlerr�$sP��
�F�#'�$�(�(����3���?�(�F��1�1�4�9�9�E�E�����5��	�	�A�B��*�*�W�^�^�;�
�� ��/�M���� �/�%�*�*�]�2K�K�F��1�1����=��
����5�5�?�?�?�.����:�;�C��>�>��
�
�>�*��t�)�)�*�D��t�{�{�#�d�*�D��t��
�
�<�(���J�J�/�$�6�7���J�J���5�6��
�
�4� ��J�J�x�&�(�)��E�E�K�K�����
�&��N��-�*�*���>�>������?�#�E�F��
�5�5�?�?�?�.����:�;�C��>�>��
�
�>�*��t�)�)�*�D��t�{�{�#�d�*�D��t��
�
�<�(���J�J�/�$�6�7���J�J���5�6��
�
�4� ��J�J�x�&�(�)��E�E�K�K�����
�&���
���5�5�?�?�?�.����:�;�C��>�>��
�
�>�*��t�)�)�*�D��t�{�{�#�d�*�D��t��
�
�<�(���J�J�/�$�6�7���J�J���5�6��
�
�4� ��J�J�x�&�(�)��E�E�K�K�����
�&��s+�CG;�;M%�+M �;M(� M%�%M(�(D"R
c�r�[X5nUcgSnUR(a)URbURR	SSS9 SnU"X5 UbURR5nU(aKURR
SUSS9nURS[R"UR5SS	9 gg!UbURR5nU(aKURR
SUSS9nURS[R"UR5SS	9 ff=f)
z�process a single part from a bundle

The part is guaranteed to have been fully consumed when the function exits
(even if an exception is raised).NT)r�subprocr+�outputF��datar��in-reply-to�r�)r�r}r|r'�
pushbuffer�	popbuffer�newpart�addparamr�bytestr�id)r�r�r��output�outparts     r)r�r�Ns ��
�"�#�G�����F�	���B�H�H�0�
�����t�T��2���	�������U�U�_�_�&�F���h�h�&�&�y�v��&�O�G������ 0� 0���� 9�U�
�
������U�U�_�_�&�F���h�h�&�&�y�v��&�O�G������ 0� 0���� 9�U�
�
��s
�
C�A1D6�Capabilitiesc�.�0nUR5HynU(dMSU;aUSpCO%URSS5up4URS5n[RU5nUVs/sHn[RU5PM nnXAU'M{ U$s snf)z�decode a bundle2 caps bytes blob into a dictionary

The blob is a list of capabilities (one per line)
Capabilities may have values using a line of the form::

    capability=value1,value2,value3

The values are always a list.�=r7r�,)�
splitlines�split�urlreq�unquote)�blob�caps�line�key�vals�vs      r)�
decodecapsrks����D����!�����t���b���
�
�4��+�I�C��:�:�d�#�D��n�n�S�!��+/�0�4�a����q�!�4��0��S�	�"��K��1s�'Bc�.�/n[U5HonXn[RU5nUVs/sHn[RU5PM nnU(aSUSRU54-nUR	U5 Mq SRU5$s snf)z2encode a bundle2 caps dictionary into a bytes blob�%s=%sr�r�)�sortedr�quoter�rR)r�chunks�carrs     r)�
encodecapsr�s���
�F��T�l���x��
�\�\�"�
��)-�.��A����Q����.���R����4��1�1�B��
�
�b��
��:�:�f����	/s�B)r+�UN)�HG10UNr)�HG10sBZ)�HG10GZsGZ)r+�HG20r�HG10BZr)rrrc�v�\rSrSrSrSrSSSjjrSSjr\S5r	SSjr
S	rS
rSSjr
SrS
rSrSrg)�bundle20i�z�represent an outgoing bundle2 container

Use the `addparam` method to add stream level parameter. and `newpart` to
populate it. Then call `getchunks` to retrieve all the binary chunks of
data that compose the bundle2 container.rNc��Uc0nXl/Ul/Ul[U5Ul[
RRS5UlSUl	SUl
g)NrT)r'�_params�_parts�dictr�r�compengines�
forbundletype�_compengine�	_compopts�prefercompressed)rMr'r�s   r)rN�bundle20.__init__�sW�����L���������*.�|�*<����+�+�9�9�%�@������!%��r+c���US;ag[SUR55(aeURSU5 [RRU5UlX lg)z$setup core part compression to <alg>)NrNc3�L# �UHupUR5S:Hv� M g7f)�compressionN)r=)�.0�nrs   r)�	<genexpr>�*bundle20.setcompression.<locals>.<genexpr>�s���L�|�t�q�q�w�w�y�N�2�|�s�"$sCompression)�anyrr�rrrrr)rM�alg�compoptss   r)�setcompression�bundle20.setcompression�sT���-����L�t�|�|�L�L�L�L�L��
�
�n�c�*��+�+�9�9�#�>���!�r+c�,�[UR5$)z*total number of parts added to the bundler)rhrrLs r)�nbparts�bundle20.nbparts�s���4�;�;��r+c��U(d[R"S5eUSS[R"[R
5;a[R"SU-5eURRX45 g)zadd a stream level parametersempty parameter namerrsnon letter first character: %sN)rr�rr��string�
ascii_lettersrrR)rM�name�values   r)r��bundle20.addparam�sn����(�(�)@�A�A���!�9�H�,�,�� � �
�
��(�(�1�D�8��
�	
�����T�M�*r+c��URbe[UR5UlURRU5 g)zWadd a new part to the bundle2 container

Parts contains the actual applicative payload.N)r�rhrrR�rMr�s  r)�addpart�bundle20.addpart�s4���w�w�����d�k�k�"��������4� r+c�F�[U/UQ70UD6nURU5 U$)aIcreate a new part and add it to the containers

As the part is directly added to the containers. For now, this means
that any failure to properly initialize the part after calling
``newpart`` should result in a failure of the whole bundling process.

You can still fall back to manually create and add if you need better
control.)�
bundlepartr9)rM�typeid�argsr�r�s     r)r��bundle20.newpart�s)���&�2�4�2�6�2�����T���r+c#��# �URR(a�SUR-/nUR(a'UR	S[UR5-5 UR	S[UR5-5 URRSRU55 [URSUR-5 URv� UR5n[URSU-5 [[[U55v� U(aUv� URRUR5UR 5Shv�N gN7f)Nsbundle2-output-bundle: "%s",s (%i params)s %i parts total
r+sstart emission of %s streamsbundle parameter: %s)r'r��_magicstringrrRrhrr%r�r*�_paramchunk�_pack�_fstreamparamsizer�compressstream�
_getcorechunkr)rMr��params   r)�	getchunks�bundle20.getchunks�s����7�7���2�T�5F�5F�F�G�C��|�|��
�
�?�S����->�>�?��J�J�+�c�$�+�+�.>�>�?��G�G�M�M�#�(�(�3�-�(�����8�4�;L�;L�L�M������ � �"������1�E�9�:��%�s�5�z�2�2���K��#�#�2�2���� �$�.�.�
�	
�	
�s�E,E6�.E4�/E6c���/nURHIup#[RU5nUb[RU5nSX#4-nURU5 MK SR	U5$)z1return a encoded version of all stream parametersr
� )rrrrRr�)rM�blocks�parr5s    r)rB�bundle20._paramchunk�sb�����,�,�J�C��,�,�s�#�C�� ����U�+���#��-���M�M�#��'��y�y�� � r+c#�:# �[URS5 URHGn[URSUR-5 UR	URS9Shv�N MI [URS5 [[S5v� gN17f)zMyield chunk for the core part of the bundle

(all but headers and parameters)sstart of partssbundle part: "%s"�r'Ns
end of bundler)r*r'rr�rHrC�_fpartheadersizer8s  r)rF�bundle20._getcorechunksx���	����+�,��K�K�D��T�W�W�2�T�Y�Y�>�?��~�~����~�1�1�1� �	����*�+��$�a�(�(�
2�s�A%B�'B�(2Bc��/nURHDnURRS5(dM%URUR	55 MF U$)z�return a list with a copy of all output parts in the bundle

This is meant to be used during error handling to make sure we preserve
server outputr�)rr��
startswithrRr�)rMr�r�s   r)r��bundle20.salvageoutputsE��
���K�K�D��y�y�#�#�I�.�.�����	�	��,� ��r+)rrrrr�r r'r<)r�zOptional[Capabilities])�returnzIterator[bytes])rorprqrrrsrArNr,�propertyr/r�r9r�rHrBrFr�rur7r+r)rr�sO��0��L�
%�"�� �� �

+�!��
�$	!�	)�	r+rc�*�\rSrSrSrSrSrSrSrg)�
unpackermixiniz6A mixin to extract bytes and struct data from a streamc��Xlgr<��_fp)rM�fps  r)rN�unpackermixin.__init__s���r+c�b�UR[R"U55n[X5$)z�unpack this struct format from the stream

This method is meant for internal usage by the bundle2 protocol only.
They directly manipulate the low level stream including bundle2 level
instruction.

Do not use it to implement higher-level logic or methods.)�
_readexact�struct�calcsize�_unpack�rM�formatr�s   r)rc�unpackermixin._unpack!s&�����v���v�6�7���v�$�$r+c�D�[R"URU5$)z�read exactly <size> bytes from the stream

This method is meant for internal usage by the bundle2 protocol only.
They directly manipulate the low level stream including bundle2 level
instruction.

Do not use it to implement higher-level logic or methods.)r	�readexactlyr\)rM�sizes  r)r`�unpackermixin._readexact,s���&�&�t�x�x��6�6r+r[N)	rorprqrrrsrNrcr`rur7r+r)rYrYs��@��	%�7r+rYc�b�Uc[R"US5nUSSUSSpCUS:wa4URSX44-5 [R"[S55e[RU5nUc"[R"[S5U-5eU"X5n[USU-5 U$)	z7return a valid unbundler object for a given magicstring�r�sHGs6error: invalid magic: %r (version %r), should be 'HG'
snot a Mercurial bundlesunknown bundle version %ssstart processing of %s stream)	r	rhr%r�Abortr�	formatmapr^r-)r'r]�magicstring�magic�version�unbundlerclassr�s       r)�getunbundlerrt7s�����!�-�-�b�!�4�� ��1�%�{�1�Q�'7�7���~�
���F���
�	
��k�k�!�5�6�7�7��]�]�7�+�N����k�k�!�8�9�G�C�D�D��r�&�I��B�0�;�>�?��r+c�^�\rSrSrSrSrU4Sjr\RS5r	Sr
SrSrSS	jr
S
rSrSrS
rU=r$)r�iJztinterpret a bundle2 stream

This class is fed with a binary stream and yields parts through its
`iterparts` methods.rc�>�Xl[RRS5UlSUl[TU]U5 g)z<If header is specified, we do not read it out of the stream.rN)r'rrrr�_compressed�superrN�rMr'r]�	__class__s   �r)rN�unbundle20.__init__Rs6������+�+�9�9�%�@������
����r+c��[URS5 0nUR[5SnUS:a[R
"SU-5eU(a"UR
U5nURU5nU$)z%dictionary of stream level parameterss!reading bundle2 stream parametersr�negative bundle param size: %i)r-r'rcrDr�BundleValueErrorr`�_processallparams)rMr@�
paramssizes   r)r@�unbundle20.paramsYsv��	����=�>����\�\�"3�4�Q�7�
���>��(�(�1�J�>��
���_�_�Z�0�F��+�+�F�3�F��
r+c�J�[R"5nURS5HsnURSS5nUVs/sHn[R	U5PM nn[U5S:aUR
S5 UR"U6 USX#S'Mu U$s snf)�rKr�rrmNr)r�sortdictr�rrrhrR�
_processparam)rM�paramsblockr@r��is     r)r�unbundle20._processallparamshs���������"�"�4�(�A�����a� �A�,-�.�A�q�����"�A�A�.��1�v��z����������"��Q�4�F�Q�4�L�
)��
��/s�B c��U(d[S5eUSS[R"[R5;a[SU-5e[
UR
5nU"XU5 g![aI USSR5(a[URSU-5 g[R"U4S9ef=f)a_process a parameter, applying its effect if needed

Parameter starting with a lower case letter are advisory and will be
ignored when unknown.  Those starting with an upper case letter are
mandatory and will this function will raise a KeyError when unknown.

Note: no option are currently supported. Any input will be either
      ignored or failing.
zempty parameter namerrznon letter first character: %ssignoring unknown parameter %s)r@N)
r1rr�r2r3�b2streamparamsmapr=�KeyError�islowerr-r'rr�)rMr4r5r�s    r)r��unbundle20._processparamts�����3�4�4���!�9�H�,�,�� � �
�
��=��D�E�E�	'�'��
�
��5�G�
�D��&��
�	F��A�a�y� � �"�"�����!A�D�!H�I��5�5�d�W�E�E�		F�s�
A.�.;C�+Cc#�# �URv� S[U5;deUR[5SnUS:a[R
"SU-5eU(a�UR
U5nURU5 /nURS5H>nURSS5upVUR5S:wdM-URU5 M@ SRU5n[[[U55v� Uv� O[[U5v� URRUR 5UlSnUS:a�["[$:XdeUR["5Sn[["U5v� U(aSnOUS-
nMQU[&:XaM]US:a[R
"S	5eUR
U5v� US:aM�g
g
7f)a0utility to transfer a bundle2 as binary

This is made necessary by the fact the 'getbundle' command over 'ssh'
have no way to know when the reply ends, relying on the bundle to be
interpreted to know its end. This is terrible and we are sorry, but we
needed to move forward to get general delta enabled.
r@rr}rKr�rr$rmsnegative chunk size: %iN)rA�varsrcrDrr~r`rr�r=rRr�rCrhr�decompressorreaderr\rQ�
_fpayloadsize�
flaginterrupt)	rMr�r@�	outparamsr��kr�
emptycountris	         r)�_forwardchunks�unbundle20._forwardchunks�s���������t�D�z�)�)�)��\�\�"3�4�Q�7�
���>��(�(�1�J�>��
���_�_�Z�0�F��"�"�6�*��I��\�\�$�'���w�w�t�Q�'����7�7�9��.��$�$�Q�'�(��	�	�)�,�I��)�3�y�>�:�:��O��)�:�6�6��#�#�6�6�t�x�x�@����
��1�n�#�}�4�4�4��<�<� 0�1�!�4�D��(�$�/�/���
��a��
���}�$������,�,�-G�H�H��/�/�$�'�'��1�n�s�B<G�DG�Gc#�# �U(a[O[nUR URR	UR
5Ul[
URS5 UR5nUbFU"URX0R
5nUv� UR5 UR5nUbMF[
URS5 g7f)z'yield all parts contained in the streams!start extraction of bundle2 partsNsend of bundle2 stream)
�seekableunbundlepart�unbundlepartr@rr�r\r-r'�_readpartheaderr�)rM�seekable�cls�headerblockr�s     r)r��unbundle20.iterparts�s����&.�"�L������#�#�6�6�t�x�x�@�������=�>��*�*�,���%��t�w�w��X�X�6�D��J�
�L�L�N��.�.�0�K��%�	����1�2�s�B7C�;Cc���UR[5SnUS:a[R"SU-5e[	UR
SU-5 U(aUR
U5$g)�Ireads a part header size and return the bytes blob

returns None if emptyr�negative part header size: %ispart header size: %iN�rcrQrr~r-r'r`�rM�
headersizes  r)r��unbundle20._readpartheader�se���\�\�"2�3�A�6�
���>��(�(�0�:�=��
�	����0�:�=�>���?�?�:�.�.�r+c�2�UR UR$r<)r@rwrLs r)�
compressed�unbundle20.compressed�s��������r+c�n�[URS5(aURR5$g)zclose underlying file�closeN)�hasattrr\r�rLs r)r��unbundle20.close�s)���4�8�8�W�%�%��8�8�>�>�#�#�&r+)rrwr\r')F)rorprqrrrsrArNr�
propertycacher@rr�r�r�r�r�r�ru�
__classcell__�rzs@r)r�r�JsW����
�L��
������
�'�48(�t3�&� �$�$r+r�s20c�^�U4SjnU$)z/register a handler for a stream level parameterc�2>�T[;deU[T'U$r<)ror�)rAr4s �r)�	decorator�'b2streamparamhandler.<locals>.decorator�s!����9�$�$�$�"&��$���r+r7)r4r�s` r)�b2streamparamhandlerr��s����
�r+r$c���U[RR;a[R"U4U4S9e[RRU5UlUbSUlgg)z<read compression parameter and install payload decompression)r@�valuesNT)rr�supportedbundletypesrr�rrrw)r�rGr5s   r)�processcompressionr�s[��
�D�$�$�9�9�9��-�-�e�X�u�h�O�O� �,�,�:�:�5�A�I���� $�	��r+c��\rSrSrSrSSjrSrSr\S5r	\	RS5r	\S5r\S	5rSS
jr
SrSrS
rg)r<i
a�A bundle2 part contains application level payload

The part `type` is used to route the part to the application level
handler.

The part payload is contained in ``part.data``. It could be raw bytes or a
generator of byte chunks.

You can add parameters to the part using the ``addparam`` method.
Parameters can be either mandatory (default) or advisory. Remote side
should be able to safely ignore the advisory ones.

Both data and parameters cannot be modified after the generation has begun.
c��[U5 SUlXlX@l[	U5Ul[	U5Ul[5UlUR
UR-HHupgX`R;a[R"SU-5eURRU5 MJ SUlXPl
g)N�duplicated params: %s)r4r�r��_datar��_mandatoryparams�_advisoryparams�set�_seenparamsrr�rT�
_generatedr�)rMr3�mandatoryparams�advisoryparamsr�r��pname�__s        r)rN�bundlepart.__init__s���	��"�����	��
� $�_� 5���#�N�3����5����.�.��1E�1E�E�I�E��(�(�(��,�,�-E��-M�N�N���� � ��'�F����"�r+c���URR<SURR<3nSU[U5URURUR
4-$)N�.z2<%s object at %x; id: %s; type: %s; mandatory: %s>)rzrpror�r�r�)rMr�s  r)�__repr__�bundlepart.__repr__8sR�����2�2�D�N�N�4K�4K�L��C���t�H��G�G��I�I��N�N�G
�
�	
r+c���[URS5(aeURURURUR
URUR5$)z�return a copy of the part

The new part have the very same content but no partid assigned yet.
Parts with generated data cannot be copied.�next)r�r�rzr�r�r�r�r�rLs r)r��bundlepart.copyBsS��
�4�9�9�f�-�-�-�-��~�~��I�I��!�!�� � ��J�J��N�N�
�	
r+c��UR$r<)r�rLs r)r��bundlepart.dataQs���z�z�r+c�V�URb[R"S5eXlg)N�part is being generated)r�r�ReadOnlyPartErrorr�)rMr�s  r)r�r�Us#���?�?�&��)�)�*D�E�E��
r+c�,�[UR5$r<)r]r�rLs r)r��bundlepart.mandatoryparams[s���T�*�*�+�+r+c�,�[UR5$r<)r]r�rLs r)r��bundlepart.advisoryparams`s���T�)�)�*�*r+c��URb[R"S5eXR;a[	SU-5eURRU5 URnU(aURnURX45 g)z�add a parameter to the part

If 'mandatory' is set to True, the remote handler must claim support
for this parameter or the unbundling will be aborted.

The 'name' and 'value' cannot exceed 255 bytes each.
Nr�r�)	r�rr�r�r1rTr�r�rR)rMr4r5r�r@s     r)r��bundlepart.addparamesx���?�?�&��)�)�*D�E�E��#�#�#��5��<�=�=������T�"��%�%����*�*�F��
�
�t�m�$r+c	#�# �URb[R"S5eSUlUR(Ga�SUR-/nUR
(dUR
S5 [UR5n[UR5nU(dU(aXUR
S5 U(aUR
SU-5 U(aUR
SU-5 UR
S5 UR(dUR
S	5 Oo[URS
5(d[URS5(aUR
S5 O'UR
S
[UR5-5 UR
S5 URSRU55 UR
(aURR5nOURR5n[!US["R$"UR&5U4-5 [)[*[U55U[)[,UR&5/nURnURnUR
[)[.[U5[U555 /n	UH9up�U	R
[U
55 U	R
[U55 M; UH9up�U	R
[U
55 U	R
[U55 M; [)[1[U	5S-5/U	Q76nUR
U5 UH'up�UR
U
5 UR
U5 M) UH'up�UR
U
5 UR
U5 M) SRU5n
[!US[U
5-5 [)[4[U
55v� U
v� UR75H:n[!US[U5-5 [)[8[U55v� Uv� M< [!US5 [)[8S5v� SUlg![2a [3SU-5ef=f![:a URS5 e[<a�n[>R@"U5nURSU-5 [BRD"5SnSU-n[GSSU4/SS9nSUl[)[8S5v� URIUS9HnUv� M	 [!US5 [)[8S5v� ["RJ"UU5 SnAGN*SnAff=f7f) Nspart can only be consumed onceFsbundle2-output-part: "%s"r�r�r�r�r�s empty payloadr��__next__s streamed payloads %i bytes payloadr�r+s
part %s: "%s"rmz8Found a non-bytes trying to build bundle part header: %rsheader chunk size: %i�payload chunk size: %isbundle2-generatorexit
s5bundle2-input-stream-interrupt: encoding exception %ssunexpected error: %s�error:abort�messager�r���rPsclosing payload chunkT)&r�rr�r�r�r�rRrhr�r�r�r�r%r��upperr=r*rr�r�rC�_fparttypesize�_fpartid�_fpartparamcountr9�	TypeErrorrQ�_payloadchunksr��
GeneratorExit�
BaseExceptionr�forcebytestr�sys�exc_infor<rH�raisewithtb)rMr'r�r�r�r3�header�manpar�advpar�parsizesrr5�
paramsizes�headerchunk�chunkr��bexcr��	interparts                   r)rH�bundlepart.getchunksxsj����?�?�&��(�(�)J�K�K����
�<�<�<�/�$�)�)�;�<�C��>�>��
�
�>�*��t�+�+�,�D��t�*�*�+�D��t��
�
�<�(���J�J�/�$�6�7���J�J���5�6��
�
�4� ��9�9��
�
�,�-�����F�+�+�w�t�y�y�*�/M�/M��
�
�/�0��
�
�/�#�d�i�i�.�@�A��J�J�u���H�H�S�X�X�c�]�#��>�>��y�y���(�H��y�y���(�H���%��)9�)9�$�'�'�)B�H�(M�M�N�
�.�#�h�-�0���(�D�G�G�$�
���%�%���$�$���
�
�e�,�c�&�k�3�v�;�G�H��� �J�C��O�O�C��H�%��O�O�C��J�'�!�!�J�C��O�O�C��H�%��O�O�C��J�'�!��/��H�
��0B�C�O�h�O�
��
�
�j�!� �J�C��M�M�#���M�M�%� �!�!�J�C��M�M�#���M�M�%� �!�	��(�(�6�*�K�	��-��K�0@�@�A��$�c�+�&6�7�7���	*��,�,�.����6��U��C�D��M�3�u�:�6�6���/�<	��-�.��M�1�%�%�����U�	��/�17�8��
�	���	�
�H�H�/�0���	*��*�*�3�/�D��H�H�H�4�O�
������"�B�)�D�0�C�"��*�c�!2� 3�u��I��I�L��
�r�*�*�"�,�,��,�3����4��R�1�2��
�q�)�)�� � ��b�)�)��%	*�sJ�OV
�R�7V
�
AR�&V
�R�V
�%V
�B=V�?V
�V
�
V
c#�# �[URS5(d[URS5(a`[R"UR5nUR	[
5nU(a#Uv� UR	[
5nU(aM"gg[
UR5(aURv� gg7f)zeyield chunks of a the part payload

Exists to handle the different methods to provide data to a part.r�r�N)r�r�r�chunkbuffer�read�preferedchunksizerh)rM�buffr�s   r)r��bundlepart._payloadchunks�s�����4�9�9�f�%�%�����J�)G�)G��#�#�D�I�I�.�D��I�I�/�0�E�����	�	�"3�4���%�����^�^��)�)�O��s�BC�,C)r�r�r�r�r�r�r�r�N)r7r7r+T)r+T)rorprqrrrsrNr�r�rWr��setterr�r�r�rHr�rur7r+r)r<r<
s���
�$��
��
#�6
�
�����
�[�[����
�,��,��+��+�%�&j�X
r+r<r�c�8^�\rSrSrSrU4SjrSrSrSrU=r	$)�interrupthandleri�z�read one part and process it with restricted capability

This allows to transmit exception raised on the producer size during part
iteration while the consumer is reading a part.

Part processed in this manner only have access to a ui object,c�0>�[TU]U5 Xlgr<)rxrNr'rys   �r)rN�interrupthandler.__init__�s���
������r+c���UR[5SnUS:a[R"SU-5e[	UR
SU-5 U(aUR
U5$g)r�rr�spart header size: %i
Nr�r�s  r)r�� interrupthandler._readpartheaderse���\�\�"2�3�A�6�
���>��(�(�0�:�=��
�	����2�Z�?�@���?�?�:�.�.�r+c��URRS5 [URS5 UR5nUc[URS5 g[	URXR
5n[
UR5nSn[X25 U(dUR5 URRS5 g![[4a Snef=f!U(dUR5 ff=f)Ns<bundle2-input-stream-interrupt: opening out of band context
s0bundle2 stream interruption, looking for a part.s"no part found during interruption.FTs<bundle2-input-stream-interrupt: closing out of band context
)r'r%r-r�r�r\�interruptoperationr��
SystemExit�KeyboardInterruptr�)rMr�r�r��	hardaborts     r)�__call__�interrupthandler.__call__s������
�
�L�	
�	����L�M��*�*�,�����D�G�G�B�C���D�G�G�[�(�(�;��
����
(���	�	���"�
��������
�
�L�	
��
�-�.�	��I��	��������s�C�C'�'C*�*DrP)
rorprqrrrsrNr�rrur�r�s@r)r�r��s���F���
�
r+r�c�4�\rSrSrSrSr\S5rSrSr	g)ri*zhA limited operation to be use by part handler during interruption

It only have access to an ui object.
c�,�XlSUlSUlg)NF)r'r|r})rMr's  r)rN�interruptoperation.__init__0s������
�"��r+c�.�[R"S5e�Ns'no repo access from stream interruption)rr�rLs r)ry�interruptoperation.repo5s���$�$�%O�P�Pr+c��[S5err�rLs r)r��!interruptoperation.gettransaction9s��$�%O�P�Pr+)r}r|r'N)
rorprqrrrsrNrWryr�rur7r+r)rr*s(���
#�
�Q��Q�Qr+rc#�# �URSS5nURn[R"[5nUR
nURn[RnURnU"U"X55Sn	[USU	-5 U	(a�U	S:�aIU"U	5n
[U
5U	:a-[R"[S5[U
5U	4-5eU
v� O4U	[:Xa[!X5"5 O[R""SU	-5eU"U5n
[U
5U:a-[R"[S5[U
5U	4-5eU"U
5Sn	U(aU"SU	-5 U	(aM�gg7f)	z�Reads bundle2 part payload data into chunks.

Part payload data consists of framed chunks. This function takes
a file handle and emits those chunks.
r!r"rr�s6stream ended unexpectedly  (got %d bytes, expected %d)snegative payload chunk size: %ss&bundle2-input: payload chunk size: %i
N)r$r%ra�Structr�ri�unpackr	rhr�r-rhrrnrr�r�r~)r'�fh�dologr%�headerstructr�rrhr��	chunksize�ss           r)�decodepayloadchunksr=ss���
�M�M�(�$4�5�E��H�H�E��=�=��/�L��"�"�J�
�
 �
 �F��)�)�K�
�7�7�D��{�2�2�3�A�6�I��B�)�I�5�6����>��Y��A��1�v�	�!��k�k��8���1�v�y�)�	*����G�
�-�
'�
�R�$�&��(�(�2�Y�>��
�
�����q�6�J���+�+��K�L��q�6�9�%�&��
�
�1�I�a�L�	���<�y�H�I�C�)�s�E?F�Fc�j^�\rSrSrSrU4SjrSrSrSrSr	Sr
S	rS
rSSjr
SSjrS
rU=r$)r�iuz a bundle part read from a bundlec�>>�[TU]U5 [US5=(a [US5UlXlX lSUlSUlSUlSUl	SUl
SUlSUlSUl
SUlUR5 SUlSUlg)N�seek�tellrFr7)rxrNr��	_seekabler'�_headerdata�
_headeroffset�_initialized�consumedr�r�r�r�r@r��_readheader�
_mandatory�_pos�rMr'r�r]rzs    �r)rN�unbundlepart.__init__xs����
����� ��V�,�D���V�1D�����!�����!�����
������	�#���"������������������	r+c�R�URnURX"U-nX!-UlU$)z+return the next <size> byte from the header)r!r )rMri�offsetr�s    r)�_fromheader�unbundlepart._fromheader�s0���#�#������4�-�9��#�]����r+c�b�UR[R"U55n[X5$)zYread given format from header

This automatically compute the size of the format to read.)r+rarbrcrds   r)�
_unpackheader�unbundlepart._unpackheader�s(��������� 7�8���v�$�$r+c��[U5Ul[U5Ul[R"UR5UlUR
R
UR5 [SU55Ulg)z7internal function to setup all logic related parametersc3�*# �UH	oSv� M g7f)rNr7)r%r�s  r)r'�+unbundlepart._initparams.<locals>.<genexpr>�s���&E�_���t�_�s�N)	r]r�r�rr�r@r�r?r�)rMr�r�s   r)�_initparams�unbundlepart._initparams�s_�� %�_�5���#�N�3����m�m�D�$8�$8�9��������4�.�.�/�&�&E�_�&E�E��r+c	�R�UR[5SnURU5Ul[	UR
SUR-5 UR[5SUl[	UR
S[R"UR5-5 URURR5:gUlURR5UlUR[5up#[	UR
SX#--5 [X#-5nURU5n[[USSS2USSS255nUSUnXRSn/nUH6up�UR!URU	5URU
545 M8 /nUH6up�UR!URU	5URU
545 M8 UR#X�5 [$R&"UR)55UlSUlg)	z$read the header and setup the objectrspart type: "%s"s
part id: "%s"spart parameters: %iNrmrT)r.r�r+r�r-r'r�r�rr�r=r�r�r9r��ziprRr3rr�r��_payloadstreamr")rM�typesize�mancount�advcount�fparamsizesr��mansizes�advsizes�	manparamsrr5�	advparamss            r)r$�unbundlepart._readheader�s����%�%�n�5�a�8���$�$�X�.��	�����+�d�i�i�7�8��$�$�X�.�q�1�������)�H�,<�,<�T�W�W�,E�E�F����d�i�i�o�o�&7�7����I�I�O�O�%��	�"�/�/�0@�A�������/�8�3F�G�H�*�8�+>�?���'�'��4�
��#�j��1��o�z�!�$�Q�$�/?�@�A�
��i�x�(���i�(���	�"�J�C����d�.�.�s�3�T�5E�5E�e�5L�M�N�#��	�"�J�C����d�.�.�s�3�T�5E�5E�e�5L�M�N�#�����.�"�.�.�t�/B�/B�/D�E��� ��r+c#�v# �URH%nU=R[U5-
slUv� M' g7fr<)r7r&rh�rMr�s  r)rd�unbundlepart.__iter__�s,����(�(�E��I�I��U��#�I��K�)�s�79c�B�[URUR5$)z+Generator of decoded chunks in the payload.)rr'r\rLs r)r��unbundlepart._payloadchunks�s��"�4�7�7�D�H�H�5�5r+c���UR(agURS5nU(a9U=R[U5-
slURS5nU(aM8gg)z�Read the part payload until completion.

By consuming the part data, the underlying stream read offset will
be advanced to the next part (or end of stream).
Nr)r#r�r&rhrBs  r)r��unbundlepart.consume�sF���=�=���	�	�%� ����I�I��U��#�I��I�I�e�$�E��er+c��UR(dUR5 UcURR5nOURRU5nU=R[U5-
slUb[U5U:aQUR(d9UR(a(URRSUR-5 SUlU$)zread payload datas*bundle2-input-part: total payload size %i
T)	r"r$r7r�r&rhr#r'r%)rMrir�s   r)r��unbundlepart.read�s���� � ������<��&�&�+�+�-�D��&�&�+�+�D�1�D��	�	�S��Y��	��<�3�t�9�t�+��=�=�T�Y�Y����
�
�B�T�Y�Y�N��!�D�M��r+c�6�URR5$)z*the amount of byte read so far in the part)r7rrLs r)r�unbundlepart.tell�s���"�"�'�'�)�)r+)r r!r"r%r7r&rr�r#r�r�r�r�r@r�r'r<)rV�int)rorprqrrrsrNr+r.r3r$rdr�r�r�rrur�r�s@r)r�r�us?���*��(�%�F�!!�F�
6�%��"*�*r+r�c�r^�\rSrSrSrU4SjrSSjrSrSr\	R4SjrSSjrS	r
S
rU=r$)r�i�a�A bundle2 part in a bundle that is seekable.

Regular ``unbundlepart`` instances can only be read once. This class
extends ``unbundlepart`` to enable bi-directional seeking within the
part.

Bundle2 part data consists of framed chunks. Offsets when seeking
refer to the decoded data, not the offsets in the underlying bundle2
stream.

To facilitate quickly seeking within the decoded data, instances of this
class maintain a mapping between offsets in the underlying stream and
the decoded payload. This mapping will consume memory in proportion
to the number of chunks within the payload (which almost certainly
increases in proportion with the size of the part).
c�4>�/Ul[TU]	XU5 gr<)�_chunkindexrxrNr's    �r)rN�seekableunbundlepart.__init__s������
����R�(r+c#�^# �[UR5S:Xa9US:XdS5eURRSUR545 ODU[UR5:d
SU-5eUR	URUS5 URUSn[URUR5H]nUS-
nU[U5-
nU[UR5:Xa*URRX R545 Uv� M_ g7f)z/seek to specified chunk and start yielding datarsMust start with chunk 0sUnknown chunk %drN)rhrOrR�_tellfp�_seekfprr'r\)rM�chunknum�posr�s    r)r��#seekableunbundlepart._payloadchunkss	����t��� �A�%��q�=�<�"<�<�=����#�#�Q�����$7�8��c�$�"2�"2�3�3�
�#�h�.�
�3�
�L�L��)�)�(�3�A�6�7����x�(��+��(����$�(�(�;�E���M�H��3�u�:��C��3�t�/�/�0�0�� � �'�'��l�l�n�(=�>��K�
<�s�D+D-c��[UR5H6unup4X1:XaUS4s $X1:�dMUS-
XRUS-
S-
4s $ [S5e)z>for a given payload position, return a chunk number and offsetrrs
Unknown chunk)r�rOr1)rMrUr��ppos�fposs     r)�
_findchunk�seekableunbundlepart._findchunk!se��#,�T�-=�-=�#>��E�<�D��{��a�x�����q�y�#�(8�(8����(C�A�(F�"F�F�F�	$?�
�)�*�*r+c��UR$r<)r&rLs r)r�seekableunbundlepart.tell*s���y�y�r+c��U[R:XaUnO�U[R:XaURU-nO|U[R:XaYUR
(d2UR
S5nU(aUR
S5nU(aMURSSU-
nO[SU4-5eX0RSS:�aCUR
(d2UR
S5nU(aUR
S5nU(aMSUs=::aURSS::d
O [S5eURU:wa�URU5upE[R"URU55Ul
UR
U5n[U5U:wa[R "[#S55eX0lgg)Nrr�rsUnknown whence value: %ri�sOffset out of rangesSeek failed
)�os�SEEK_SET�SEEK_CURr&�SEEK_ENDr#r�rOr1rZrr�r�r7rhrrnr)rMr*�whence�newposr��internaloffset�adjusts       r)r�seekableunbundlepart.seek-st���R�[�[� ��F�
�r�{�{�
"��Y�Y��'�F�
�r�{�{�
"��=�=��	�	�%�(��� �I�I�e�,�E��e��%�%�b�)�!�,�v�5�F��8�F�9�D�E�E��$�$�R�(��+�+�D�M�M��I�I�e�$�E���	�	�%�(���%��F�5�d�.�.�r�2�1�5�5��3�4�4��9�9���$(�O�O�F�$;�!�E�"&�"2�"2�4�3F�3F�u�3M�"N�D���Y�Y�~�.�F��6�{�n�,��k�k�!�$4�"5�6�6��I�
r+c��UR(aURRX5$[[	S55e)z�move the underlying file pointer

This method is meant for internal usage by the bundle2 protocol only.
They directly manipulate the low level stream including bundle2 level
instruction.

Do not use it to implement higher-level logic or methods.sFile pointer is not seekable)rr\r�NotImplementedErrorr)rMr*rcs   r)rS�seekableunbundlepart._seekfpMs/���>�>��8�8�=�=��0�0�%�a�(G�&H�I�Ir+c���UR(aURR5$g![a0nUR[R
:XaSUlSnAgeSnAff=f)areturn the file offset, or None if file is not seekable

This method is meant for internal usage by the bundle2 protocol only.
They directly manipulate the low level stream including bundle2 level
instruction.

Do not use it to implement higher-level logic or methods.FN)rr\r�OSError�errno�ESPIPE)rM�es  r)rR�seekableunbundlepart._tellfpZsZ���>�>�
��x�x�}�}��&����
��7�7�e�l�l�*�%*�D�N�N����	
�s�.�
A(�%A#�"A#�#A()rOr7r&r)r)rorprqrrrsrNr�rZrr_r`rrSrRrur�r�s@r)r�r��s;����")��*+��#%�+�+��@J��r+r�)sabortsunsupportedcontents	pushraced�pushkey)shttpshttps)sheads)�v2)
r�	bookmarksserror�listkeysrq�digests�remote-changegroup�hgtagsfnodes�phases�streamr�c�@�US;a[R"S5e[R5n[	[[R"U555US'[R"U[R5(a$[	S[R55nXCS'U(aSUS'URRSS	5nUS
:XaSUS'S
URRSS5;aURS
5 US:XaVURR!SSSS9nURR!SS5nU(aU(dURS5 URR!SS5(aSU;a
US==S-
ss'U$)aKreturn the bundle2 capabilities for a given repo

Exists to allow extensions (like evolution) to mutate the capabilities.

The returned value is used for servers advertising their capabilities as
well as clients advertising their capabilities to servers as part of
bundle2 requests. The ``role`` argument specifies which is which.
)�client�servers&role argument must be client or serverr�c3�,# �UH
nSU-v� M g7f)sV%iNr7)r%rs  r)r'�getrepocaps.<locals>.<genexpr>�s���E�4D�q���
�4D�s��
obsmarkersr7spushbackr|sconcurrent-push-modes
check-related)srelateds
checkheadsrxr!slegacy.exchangesuncompressedT)�	untrustedsbundle2.streamry�experimentals	stream-v3)�v3-exp)rr�r�r�r]rr	�supportedincomingversionsr�	isenabled�exchangeopt�formatsr'�config�
configlist�popr$)ry�
allowpushback�roler�supportedformat�cpmode�streamsupported�featuresupporteds        r)�getrepocapsr�~so���)�)��$�$�%N�O�O�����D� ��{�4�4�T�:�;��D������$�� 4� 4�5�5��E�H�4D�4D�E�E��-�]�����[��
�W�W�^�^�I�'>�
?�F�
�!�!�+��]���D�G�G�&�&�x�1C�D�D�������y���'�'�,�,���$�-�
�� �7�7�-�-�i�9J�K���&6��H�H�Y���w�w���/�<�8�8������O�|�+�O�
�Kr+c��URS5nU(dUS:wa0$[RURS55n[U5$)z0return the bundle capabilities of a peer as dictr�r+)�capablerrr)rz�raw�capsblobs   r)�bundle2capsr��s@��
�.�.��
$�C��3�#�:��	��~�~�f�n�n�Z�8�9�H��h��r+c��URSS5nUVs/sH(o"RS5(dM[USS5PM* sn$s snf)zIextract the list of supported obsmarkers versions from a bundle2caps dictrr7�VrN)r^rTrL)r�obscaps�cs   r)�obsmarkersversionr��s?���h�h�}�b�)�G� '�>��1�<�<��+=�J�C��!�"��J��>�>��>s
�A	�A	c
���URS5(a'[R"XSU5n[UUUUUUU	S9$URS5(d[R
"SU-5eUR
SUR5nU(aHU
(dA[UR
SUR55n
SnX�-n[R
"U5e0nURSS	5(aS
US'URSS
5nUS:XaS/US'OUS:XaS/US'[X5nURX�5 [XUX%U5 UR5n[R"UUX7S9$)Nr�01)�vfs�compressionr+rsunknown bundle type: %ss%ln and _internal()z3backup bundle would contains %d internal changesets�obsolescenceF)sV1rryr+rrr��r�)rTr	�makechangegroup�writebundlerr��revs�ancestorsofrh�missingr^rr,�_addpartsfromoptsrH�writechunks)r'ryr��filename�
bundletype�outgoing�optsr�r�r+�allow_internalr��bundled_internalr�r�r�stream_version�bundle�	chunkiters                   r)�writenewbundler��sl�����W�%�%�
�
(�
(����
G��������#��
�	
��
"�
"�7�
+�
+��$�$�%?�*�%L�M�M��y�y�!7��9M�9M�N�����D�I�I�4�h�6F�6F�G�H��C������$�$�S�)�)��D��x�x���'�'�&��]���X�X�i��-�N���� �'��Y��	�9�	$�$�+��Y��
�b�
�F�
���+�0��b���$�?�� � �"�I��"�"�2�y�(�D�Dr+c�X�URSS5(Ga)URS5nUc[R"U5n[R"XXc5nUR	SUR5S9nUR
SUR5 SUR;a!UR
SSURS-S	S
9 URS5(ag[Rn	URHn
[X�U
R55n	M! U	[R:�aUR
SSU	-S	S
9 [RUR ;aWR
S
S5 URSS5S:Xa
[#X!SS9 URSS5S:Xa
[#X!SS9 URSS5(a[%XU5 URSS5(a['XU5 URSS	5(a>UR(R+UR,S9n[/UUURSS5S
9 URSS	5(aG[R0"XR,5n[R2"U5n
UR	SU
S9 gg)Nr�Ts
cg.version�r��version�clcount�	nbchanges�%dFr�rx�targetphase�exp-sidedatar�ryr+rr)�streamr�stagsfnodescachesrevbranchcacher�)�nodessobsolescence-mandatory�phase-heads)r^r	�safeversionr�r�rHr�rr�extrasr
�draftr��max�phaser�REPO_FEATURE_SIDE_DATA�features�addpartbundlestream2�addparttagsfnodescache�addpartrevbranchcache�obsstore�relevantmarkersr��buildobsmarkerspart�subsetphaseheads�binaryencode)r'ry�bundlerr�r�r��	cgversionr�r��target_phase�head�
obsmarkers�headsbyphase�	phasedatas              r)r�r��s@���x�x���%�%��H�H�]�+�	���#�/�/��5�I�
�
(�
(���
K�����~�B�L�L�N��C���
�
�j�"�*�*�-�����"��M�M��e�b�i�i�
�&;�;�u�
�
��8�8�I���!�<�<�L� �,�,��"�<�d��1A�1A�1C�D��-��f�l�l�*��
�
�"��L�(�#���
�(�(�D�M�M�9��
�
�o�t�,��x�x�	�3��5�(��W�4�8��x�x�	�3��9�,��W�4�8��x�x�"�D�)�)��t�h�7��x�x�!�4�(�(��d�X�6��x�x���'�'��]�]�2�2��9I�9I�2�J�
�����h�h�8�$�?�	
��x�x�	�5�!�!��.�.�t�5E�5E�F���'�'��5�	�����Y��7�"r+c��[R"UR55n/nURH.nUR	USS9nU(dMURXV/5 M0 U(a!UR
SSSRU5S9 gg)NF)�computemissingrwr+)r�r�)r�hgtagsfnodescache�
unfilteredr��getfnode�extendr�r�)ryr�r��cacher
�node�fnodes       r)r�r�-s���
�"�"�4�?�?�#4�5�E�
�F��$�$�����t�E��:���5��M�M�4�-�(�	%����������&�!�	�	
�r+c�X^	�UR5nUR5Rn[R"S5m	UR
H<nUR
URU55upgT	UURU5 M> U	4SjnURSU"5SS9 g)Nc�*�[5[54$r<)r�r7r+r)r��'addpartrevbranchcache.<locals>.<lambda>Os��C�E�3�5�>r+c3�H># �[TR55H|unup[R"U5n[R[
U5[
U5[
U55v� Uv� [U5Shv�N [U5Shv�N M~ gNN7fr<)r�itemsr
�	fromlocal�	rbcstruct�packrh)�branchr��closed�
utf8branch�branchesdatas    �r)�generate�'addpartrevbranchcache.<locals>.generateTs}����'-�l�.@�.@�.B�'C�#�F�O�U�!�+�+�F�3�J��.�.��Z��#�e�*�c�&�k�J�J����e�}�$�$��f�~�%�%�(D�
%�%�s$�A>B"�B�B"�B �
B"� B"�cache:rev-branch-cacheFr�)
�revbranchcacher��	changelog�collections�defaultdictr��
branchinfo�revrTr�)
ryr�r�r��clr�r�r�r�r�s
         @r)r�r�Js����
���!�E�	
���	�	$�	$�B��*�*�+A�B�L�� � ���(�(������6�
���V��U�#�'�'��-�!�&��O�O�-�H�J�%�O�Pr+c��UVs/sHoS:wdM
UPM nn[RSR[U555$s snf)Nssharedr�)rrr�r)r�reqs  r)�_formatrequirementsspecr�_s>��#/�D�<�C�)�3C�C�<�L�D��<�<��	�	�&��"6�7�8�8��Es
�	A�Ac�P�[U5nS[RS5U4-nU$)Ns%s%ss
requirements=)r�rr)rr@s  r)�_formatrequirementsparamsr�ds*��*�<�8�L�
����%5�6��E�
E�F��Mr+c��SnUR(a+SRS[UR555nU$)zXFormats a repo's wanted sidedata categories into a bytestring for
capabilities exchange.r+r�c3�N# �UHn[R"U5v� M g7fr<)rr�)r%r�s  r)r'�0format_remote_wanted_sidedata.<locals>.<genexpr>os"���
�)F�A�H���Q���)F�s�#%)�_wanted_sidedatar�r)ry�wanteds  r)�format_remote_wanted_sidedatar�js?���F�������
�)/��0E�0E�)F�
�
���Mr+c�:�URS5n[U5$)N�exp-wanted-sidedata)r��read_wanted_sidedata)rz�sidedata_categoriess  r)�read_remote_wanted_sidedatarus�� �.�.�)?�@��� 3�4�4r+c�X�U(a[URS55$[5$)Nr�)r�r�)�	formatteds r)r�r�zs ����9�?�?�4�(�)�)��5�Lr+c�(�URSS5(dg[R"U5(d*[S5n[S5n[R
"X4S9eSUR;a*[S5n[S5n[R
"X4S9e[URS5n[[USS	9RS/55nXV-nU(d[[S
5nSR[U55nSR[U55n	X8U	4-n[R
"U5e[U5n
SUlURS5nURS
5nURRSS5n
U(dU(a&U
(d[R
"[S55eSnUR(aW[!UR5nU(d[R
"[S55eURR"U;aSnU
S:Xa�[R$"XX�5unnn[R&"U5n[)U5nUR+SUS9nUR-SSU-SS9 UR-SSU-SS9 UR-SUSS9 gU
S:XaZ[R."XX�5n[R&"U5n[)U5nUR+SUS9nUR-SUSS9 gg)Nr�Fs<stream data requested but server does not allow this featuresthe client seems buggy��hintrysOstream data requested but supported streaming clone versions were not specifiedr{)r�s3no common supported version with the client: %s; %sr��includepats�excludepatsr�sserver.stream-narrow-cloness,server does not support narrow stream clonessPserver has obsolescence markers, but client cannot receive them via stream cloneTrr�stream2r��	bytecountr�r��	filecount�requirementsr��stream3-exp)r^r�allowservergenerationrrrnr�r�r�r�rr�r r'r$r�r��_version�
generatev2�streamed_requirementsr�r�r��
generatev3)r�ryr�r�r�client_supported�server_supported�common_supported�
str_server�
str_clientrrrr�narrowstream�includeobsmarkers�remoteversions�	filecount�	bytecount�itrr�s                     r)r�r��s����:�:�h��&�&���,�,�T�2�2��O�P���*�+���k�k�#�)�)���-�-�-��^�
���*�+���k�k�#�)�)��7�/�/�	�:�;���;�t�)�<�@�@��B�O�P��'�:����F�G���Y�Y�v�&6�7�8�
��Y�Y�v�&6�7�8�
��J�'�'���k�k�#����"�#�G�
 %�G���*�*�]�+�K��*�*�]�+�K��7�7�%�%��7��L�	�{�L��k�k�!�K�L�M�M����}�}�*�7�+?�+?�@����+�+��<���
��]�]�
#�
#�~�
5� $���%��#.�#9�#9��{�$
� �	�9�b�#�8�8��>��.�|�<�����z���3���
�
�l�E�I�$5��
�F��
�
�l�E�I�$5��
�F��
�
�o�|�t�
�D�	�I�	�
�
#�
#��{�
��#�8�8��>��.�|�<�����~�B��7���
�
�o�|�t�
�D�
r+c���U(dg[UR5n[R"U5nUc[	S5e[R
"USUS9nUR
SXRS9$)z�add an obsmarker part to the bundler with <markers>

No part is created if markers is empty.
Raises ValueError if the bundler doesn't support any known obsmarker format.
Ns0bundler does not support common obsmarker formatT)rrrr�)r�r�r�
commonversionr1�
encodemarkersr�)r��markersr�rrrr�s      r)r�r��sb����&�w�';�';�<�N��$�$�^�4�G����L�M�M�
�
#�
#�G�T�7�
C�F��?�?�=�v�?�K�Kr+c��^^^^�US:Xa�[U5nURUT5 URSTR5S9nUR	STR
5 STR;a!UR	SSTRS-SS	9 UR5n	O�UbeTR
S
:wa[R"[S55e[Uumn
U
[RR;a"[R"[S5U
-5e[RRU
5mUUUU4S
jn	U	"5n	[R "X	X$S9$)z�Write a bundle file and return its filename.

Existing files will not be overwritten.
If no filename is specified, a temporary file is created.
bz2 compression can be turned off.
The bundle file will be deleted in case of errors.
rr�r�r�r�r�r�Fr�r�s.old bundle types only supports v1 changegroupss#unknown stream compression type: %sc3�j># �Tv� TRTR5T5Shv�N gN7fr<)rErH)r��
compenginer+r�s����r)r��writebundle.<locals>.chunkiters'�����L�!�0�0������J�J�J�s�(3�1�3r�)rr,r�rHr�rrr�rrnr�bundletypesrrr�rr	r�)
r'r�r�r�r�r�r+r�r�r��compr$r�s
 `    `    @@r)r�r��sF����W���"������k�8�4��~�~�n�2�<�<�>�~�B���
�
�j�"�*�*�-�����"��M�M��e�b�i�i�
�&;�;�u�
�
��$�$�&�	��"�"�"�
�:�:����+�+��C�D��
�#�:�.�����t�'�'�<�<�<��+�+�a� F�G�$�N�O�O��%�%�3�3�D�9�
�	K�	K��K�	��"�"�2�(�D�Dr+c��URSVs/sHoRSS5PM nnSnSnUH+nUS:XaSn O"US:a	X5S--
nMUS:�dM$X5S-
-
nM- US:�aSU-nU$US:aSU-nU$s snf)z:logic to combine 0 or more addchangegroup results into oner�r�rrr�)r{r^)r��r�results�changedheads�resultr�s      r)�combinechangegroupresultsr-s���,.�J�J�~�,F�G�,F�q�u�u�Y��"�,F�G�G��L�
�F����!�8��F����8��!�G�#�L�
�1�W��!�G�#�L���a���\�!���M�
��	��l�"���M��!Hs�A>r�)r�r�r�r��treemanifestr�c�P�SSKJn UR5nURR	SS5n[
R"XAS5nSnSUR;a$[URR	S55nSUR;Ga"[R"UR5(d�[URR5S:wa[R"[S	55eURR R#[ R$5 UR'URR(URR URR*5URR,l[R0"UR5 0nURR	S
5nUb[U5US'URR	S5n	[3U	5US
'[5UUUUR6S4SU0UD6n
UR8b]UR8R;SSS9nUR=S[>R@"URB5SS9 UR=SSU
-SS9 URE5(aeg)z$apply a changegroup part on the repor)�	localrepor�r�Nr�r.rs[bundle contains tree manifests, but local repo is non-empty and does not use tree manifestsr��targetphaser�rr��
expectedtotal�reply:changegroupFr�r�r��%i)#r�r0r�r@r^r	rtrLr�istreemanifestryrhr�rrnrrrT�TREEMANIFEST_REQUIREMENT�resolvestorevfsoptionsr'r��svfs�options�writereporequirementsr�r�r�r|r�r�rr�r�r�)r��inpartr0r��unpackerversionr��nbchangesets�extrakwargsr1�remote_sidedatar�r�s            r)�handlechangegroupr@!s/���	�	�	�	�B��m�m�'�'�
�E�:�O�	�	!�	!�/�4�	@�B��L��v�}�}�$��6�=�=�,�,�\�:�;���&�-�-�'��0F�0F�r�w�w�0O�0O��r�w�w� � �!�Q�&��+�+��A���
�	����� � ��!F�!F�G�(�?�?��G�G�J�J����,�,�b�g�g�.>�.>� 
�������	�%�%�b�g�g�.��K��-�-�#�#�N�3�K���%(��%5��M�"��m�m�'�'�(>�?�O�)=�o�)N�K�%�&�
�
�
�
�
�	�	���#�
���C�
�x�x���x�x��� 4���F���
�
��H�,�,�V�Y�Y�7�5�	�	
�	
�
�
�i�����
�>��{�{�}�}���}r+)r��sizeru�	digest:%srvc��URSn[
R"U5nUR[S;a,[R"[	S5UR-5e[URS5n0nURRSS5R5HnS	U-nURUnX�U'M [R"[R"UR U5XE5n	UR#5n
S
SKJn UR)UR*R X�5n[-U[.R05(d6[R"[	S5[
R2"U5-5e[5XX�R6S
5n
UR8b^UR8R;S5nUR=S[>R@"URB5SS9 UR=SSU
-SS9 U	RE5 URI5(aeg![a# [R"[	S5S-5ef=f![a# [R"[	S5S-5e[a# [R"[	S5S-5ef=f![a# [R"[	S5U-5ef=f![RaGn[R"[	S5[
R2"U5URF4-5eSnAff=f)a�apply a bundle10 on the repo, given an url and validation information

All the information about the remote bundle to import are given as
parameters. The parameters include:
  - url: the url to the bundle10.
  - size: the bundle10 file size. It is used to validate what was
    retrieved by the client matches the server knowledge about the bundle.
  - digests: a space separated list of the digest types provided as
    parameters.
  - digest:<digest-type>: the hexadecimal representation of the digest with
    that name. Like the size, it is used to validate what was retrieved by
    the client matches what the server knows about the bundle.

When multiple digest types are given, all of them are checked.
r�s&remote-changegroup: missing "%s" paramrvs+remote-changegroup does not support %s urlsrAs0remote-changegroup: invalid value for param "%s"rur+rBr)�exchanges%s: not a bundle version 1.0r�Nr3r�Fr�r�r4sbundle at %s is corrupted:
%s)%r@r�rrnrrr�schemer�rLr1r^r�r�
digestchecker�openr'r�r�rD�
readbundleryr�r	�cg1unpacker�hidepasswordr�r�r|r�r�rr�r��validater(r�)r�r;�raw_url�
parsed_urlri�digests�typrGr5�	real_partr�rDr�r�r�ros                r)�handleremotechangegrouprQis���"Q��-�-��'�����W�%�J�����-B� C�C��k�k�
�<�=����
 �
�	
�
	
��6�=�=��)�*���G��}�}� � ��S�1�7�7�9���s�"��	��M�M�%�(�E�
���:��"�"�3�8�8�B�E�E�7�#;�T�K�I�	�	�	�	�B��	�	�	�R�W�W�Z�Z��	<�B��b�+�1�1�2�2��k�k�
�-�.��1E�1E�g�1N�N�
�	
��b�b�)�)�Z�
@�C�	�x�x���x�x��� 4�5���
�
��H�,�,�V�Y�Y�7�5�	�	
�	
�
�
�i�����
�>�
������{�{�}�}���}��s�Q��k�k�!�E�F��O�P�P�Q���
��k�k�
�A�B�W�L�
�	
��
��k�k�
�7�8�7�B�
�	
�
���	��+�+��;�<�u�D��
�	��6�;�;�
��k�k�
�/�0��#�#�G�,�a�i�i�8�
9�
�	
��
�s=�I�+I1�8K�K<�-I.�1AK	�-K9�<M�AM�Mr3)r�r�c��[URS5n[URS5nURRSSU0U5 g)Nr�r�r��rLr@r{rT)r�r;r��replytos    r)�handlereplychangegrouprU�sA��

�f�m�m�I�&�
'�C��&�-�-��/�0�G��J�J�N�N�>�I�s�#3�W�=r+scheck:bookmarksc�h�[R"URU5nSnSnSnUH�upgURRR	U5nX�:wdM1UcXV[U54-n	O-UcXF[U54-n	OUU[U5[U54-n	[R"U	5e g)z�check location of bookmarks

This part is to be used to detect push race regarding bookmark, it
contains binary encoded (bookmark, node) tuple. If the local state does
not marks the one in the part, a PushRaced exception is raised
s]remote repository changed while pushing - please try again (bookmark "%s" move from %s to %s)sbremote repository changed while pushing - please try again (bookmark "%s" is missing, expected %s)sfremote repository changed while pushing - please try again (bookmark "%s" set on %s, expected missing)N)r�binarydecodery�
_bookmarksr^rr�	PushRaced)
r�r;�bookdata�msgstandard�
msgmissing�msgexist�bookr��currentnode�finalmsgs
          r)�handlecheckbookmarksra�s����%�%�b�g�g�v�6�H�	.��
	3��
	7�
��
���g�g�(�(�,�,�T�2�����|�#�U�;�-?�&@�@���$�%�u�T�{�(;�;��&���$�K��+�&�*���
�/�/�(�+�+�r+scheck:headsc��URS5n/n[U5S:Xa3URU5 URS5n[U5S:XaM3U(aeURR	SS5(aUR5 [
U5[
URR55:wa[R"S5eg)z�check that head of the repo did not change

This is used to detect a push race when using unbundle.
This replaces the "heads" argument of unbundle.�r��bundle2lazylocking�:remote repository changed while pushing - please try againN)r�rhrRr'r$r�rry�headsrrY)r�r;�hrfs    r)�handlecheckheadsrh�s���	���B��A��E�

�a�&�B�,�
���Q���K�K��O���a�&�B�,��L�5�	�u�u����)>�?�?�
����
�e�}��r�w�w�}�}��/�/��o�o�I�
�	
�0r+scheck:updated-headsc��URS5n/n[U5S:Xa3URU5 URS5n[U5S:XaM3U(aeURR	SS5(aUR5 [
5nURR5R5HnURU5 M UHnX$;dM
[R"S5e g)a:check for race on the heads touched by a push

This is similar to 'check:heads' but focus on the heads actually updated
during the push. If other activities happen on unrelated heads, it is
ignored.

This allow server with high traffic to avoid push contention as long as
unrelated parts of the graph are involved.rcr�rdreN)
r�rhrRr'r$r�r�ry�	branchmap�	iterheadsr�rrY)r�r;rgrf�currentheads�lss      r)�handlecheckupdatedheadsrn�s���	���B��A��E�

�a�&�B�,�
���Q���K�K��O���a�&�B�,��L�5�	�u�u����)>�?�?�
�����5�L��g�g���!�+�+�-�����B��.���� ��/�/�$��
�r+scheck:phasesc��[R"U5nURR5nURnUR
nSnUR
5H|upxUHqn	URX4RU	55n
X�:wdM*U[U	5[RU
[RU4-n[R"U5e M~ g)zbcheck that phase boundaries of the repository did not change

This is used to detect a push race.
sQremote repository changed while pushing - please try again (%s is %s expected %s)N)
r
rWryr�r��_phasecacher�r�r�r�
phasenamesrrY)r�r;�phasetonodes�unfir��
phasecacher��
expectedphaser�r&�actualphaser`s            r)�handlecheckphasesrw	s����&�&�v�.�L�
�7�7����D�	
���B��!�!�J�	"��!-� 2� 2� 4��
��A�$�*�*�4�����;�K��+���!�H��%�%�k�2��%�%�m�4�"���
�o�o�h�/�/��!5r+r�c��UR5R5H*nURR[	S5U-5 M, g)z3forward output captured on the server to the clientsremote: %s
N)r�r�r'r�r)r�r;rs   r)�handleoutputry4	s7�����
�(�(�*��
�����Q��'�$�.�/�+r+s	replycapsc��[UR55nURc[URU5Ulgg)zmNotify that a reply bundle should be created

The payload contains the capabilities information for the replyN)rr�r|rr')r�r;rs   r)�handlereplycapsr{;	s5��
�f�k�k�m�$�D�	�x�x���B�E�E�4�(���r+c��\rSrSrSrSrg)�
AbortFromPartiE	z=Sub-class of Abort that denotes an error from a bundle2 part.r7N)rorprqrrrsrur7r+r)r}r}E	s��Gr+r}r�)r��hintc�b�[URSURRS5S9e)z*Used to transmit abort error over the wirer�r~r)r}r@r^�r�r;s  r)�handleerrorabortr�I	s.����
�
�j�!��
�
�(9�(9�'�(B��r+s
error:pushkey)�	namespace�key�new�old�retr�c���0nSH'nURRU5nUcM#XBU'M) [R"URS40[R
"U5D6e)z=Used to transmit failure of a mandatory pushkey over the wire�r�r�r�r�r�r�)r@r^r�
PushkeyFailedr�	strkwargs)r�r;r�r4r5s     r)�handleerrorpushkeyr�Q	sh���F�>���
�
�!�!�$�'���� �4�L�?��
�
��
�
�n�%��)1�);�);�F�)C��r+serror:unsupportedcontent)�parttype�paramsc��0nURRS5nUbX2S'URRS5nUbURS5US'[R"S0[
R"U5D6e)z4Used to transmit unknown content error over the wirer�r��r7)r@r^r�rr�rr�)r�r;r�r3r@s     r)�handleerrorunsupportedcontentr�a	sw���F��}�}� � ��-�H���&�{��
�]�]�
�
�y�
)�F�
��"�L�L��/��y��
�
)�
)�
G�H�,>�,>�v�,F�
G�Gr+serror:pushraced)r�c�\�[R"[S5URS5e)z.Used to transmit push race error over the wirespush failed:r�)r�
ResponseErrorrr@r�s  r)�handleerrorpushracedr�o	s%���
�
�a��0�&�-�-�
�2K�
L�Lr+rt)r�c��URSn[R"UR55nURRSX#45 g)z6retrieve pushkey namespace content stored in a bundle2r�rtN)r@r�
decodekeysr�r{rT)r�r;�	namespacer)s    r)�handlelistkeysr�u	s<���
�
�l�+�I����6�;�;�=�)�A��J�J�N�N�;���/r+rq�r�r�r�r�c�|�[RnU"URS5nU"URS5nU"URS5nU"URS5nURR	SS5(aUR5 URRX4XV5nX4XVS.nURRSU5 URb^URRS
5n	U	RS[R"UR5SS
9 U	RSSU-SS
9 UR(anU(df0n
SH%nXAR;dMURUX�'M' [ R""SSSUR-0[R$"U
5D6eg	g	)zprocess a pushkey requestr�r�r�r�r�rdr�rqN�
reply:pushkeyr�Fr�r�r4r�rZr�r7)r�decoder@r'r$r�ryr{rTr|r�r�rr�r�r�rr�r�)r�r;�decr�r�old�newr��record�rpartr�s           r)�
handlepushkeyr�}	s����.�.�C��F�M�M�,�/�0�I�

�f�m�m�F�#�
$�C�

�f�m�m�F�#�
$�C�

�f�m�m�F�#�
$�C�
�u�u����)>�?�?�
����
�'�'�/�/�)�#�
3�C�%�C�
M�F��J�J�N�N�:�v�&�	�x�x����� � �!1�2��
����H�,�,�V�Y�Y�7�5�	�	
�	���y�%�#�+���?�
������A�C��m�m�#�$�m�m�C�0���B��!�!�
��6�9�9�$�
�(0�(:�(:�6�(B�
�	
�!$�r+rsc�p^^
�[R"TRU5nTRRR	SS5nTR
R
SS5nUS:XGa�TR5nTRRnU(a�/m
UHoupxURR5n	SU	S'SU	S'XyS'[UR
US	55U	S
'[UbUOS	5U	S'T
RU	5 Mq T
H6n	TRR"SS
S0[R"U	5D6 M8 UHDupx[R "U5(dM"[#S5U-n
[$R&"U
5e UR)TRTR5U5 U(a#U
U4SjnTRR+U5 ggUS:Xa,UH%upxXxS.nTR,R/SU5 M' g[$R0"SU-5e)a<transmit bookmark information

The part contains binary encoded bookmark information.

The exact behavior of this part can be controlled by the 'bookmarks' mode
on the bundle operation.

When mode is 'apply' (the default) the bookmark information is applied as
is to the unbundling repository. Make sure a 'check:bookmarks' part is
issued earlier to check for push races in such update. This behavior is
suitable for pushing.

When mode is 'records', the information is recorded into the 'bookmarks'
records of the bundle operation. This behavior is suitable for pulling.
r|sbookmarks-pushkey-compatrssapplyr�s
pushkeycompatr�r�r+r�Nr��throwTs$cannot accept divergent bookmark %s!c�x>�TH3nTRR"S0[R"U5D6 M5 g)N)rq)ry�hookrr�)�unused_successr~�allhooksr�s  ��r)�runhook�handlebookmark.<locals>.runhook�	s+��� (�H��G�G�L�L�L�x�/A�/A�(�/K�L�!)r+srecords)sbookmarksnodesunknown bookmark mode: %s)s
prepushkey)rrWryr'r$r�r^r�rXr~r�rrRr�rr��isdivergentrrrn�applychanges�
_afterlockr{rTr�)r�r;�changes�
pushkeycompat�
bookmarksmoder��	bookstorer^r�r~r�r�r�r�s`            @r)�handlebookmarkr��	s����"�$�$�R�W�W�f�5�G��G�G�J�J�)�)��.��M��H�H�L�L��x�8�M��� �
�
�
�
 ���G�G�&�&�	���H�%�
���;�;�+�+�-��-1��)�*�)5���&�#'�� �#&�y�}�}�T�3�'?�#@��� �#&�t�/?�t�S�#I��� �����)�&�%�������!��)-��19�1C�1C�H�1M��%�
"�J�D��$�$�T�*�*��?�@�4�G���k�k�#�&�&�"�
	���r�w�w��(9�(9�(;�W�E��
M�
�G�G���w�'�
�
�*�	$�!�J�D�#'�7�F��J�J�N�N�<��0�"��$�$�(�=�8�
�	
r+r�c��[R"U5n[R"URR	5UR
U5 g)z%apply phases from bundle part to repoN)r
rW�updatephasesryr�r�)r�r;r�s   r)�handlephasesr��	s9���&�&�v�.�L�
������*�*�,�b�.?�.?��Nr+r�c��[URS5n[URS5nURRSSU0U5 g)�(retrieve the result of a pushkey requestr�r�rqNrS�r�r;r�rZs    r)�handlepushkeyreplyr��	sC���f�m�m�I�&�
'�C�
����~�.�
/�F��J�J�N�N�:�	�3�/��8r+rc��UR5nUR5nURRSS5(a'URR	S[U5-5 UR(dKURRR(a&URRRS5 gURRRX#5nURR5 URRSSU05 URb_URR!S5nUR#S	[$R&"UR(5S
S9 UR#SSU-S
S9 gg)
z&add a stream of obsmarkers to the repor�sobsmarkers-exchange-debugs&obsmarker-exchange: %i bytes received
s3ignoring obsolescence markers, feature not enabled
Nrr��reply:obsmarkersr�Fr�r4)r�r�r'r��writenoi18nrhr�ryr��readonlyr%�mergemarkers�invalidatevolatilesetsr{rTr|r�r�rr�r�)r�r;r��
markerdatar�r�s      r)�handleobsmarkerr��	s/��
�	�	�	�B�����J�	�u�u�|�|�O�%A�B�B�
�����6��Z��H�	
�
������ 0� 0� 9� 9�
���
�
���C�	
�	�
�'�'�
�
�
'�
'��
7�C��G�G�"�"�$��J�J�N�N�=�6�3�-�0�	�x�x����� � �!4�5��
����H�,�,�V�Y�Y�7�5�	�	
�	���v�u�s�{�e��<�r+r�)r�r�c��[URS5n[URS5nURRSSU0U5 g)r�r�r�rNrSr�s    r)�handleobsmarkerreplyr�

sB���f�m�m�F�#�
$�C�
����~�.�
/�F��J�J�N�N�=�6�3�-��8r+rwc��URRSS5(aUR5 [R"UR
R
55nSnURS5nURS5n[U5S:d[U5S:aURRS5 OURXE5 US-
nMtUR5 URRSU-5 g)	ztApplies .hgtags fnodes cache entries to the local repo.

Payload is pairs of 20 byte changeset nodes and filenodes.
r�rdrrcs1ignoring incomplete received .hgtags fnodes data
rs'applied %i hgtags fnodes cache entries
N)r'r$r�rr�ryr�r�rhr%�setfnode�write)r�r;r�r�r�r�s      r)�handlehgtagsfnodesr�
s���
�u�u����)>�?�?�
�����"�"�2�7�7�#5�#5�#7�8�E�
�E�
��{�{�2������B����t�9�r�>�S��Z�"�_��E�E�K�K�M�N��
���t�#�
��
���
�K�K�M��E�E�K�K�;�e�C�Dr+s>IIIr�c��g)z�Legacy part, ignored for compatibility with bundles from or
for Mercurial before 5.7. Newer Mercurial computes the cache
efficiently enough during unbundling that the additional transfer
is unnecessary.Nr7r�s  r)�	handlerbcr�.
s�r+spushvarsc���URRSS5(aB0nURHup4UR5nSU-nXBU'M  UR	U5 gg)z5unbundle a bundle2 containing shellvars on the serverspushspushvars.serversUSERVAR_N)r'r$r�r�r�)r�r�r~rr5s     r)�bundle2getvarsr�6
sd��
�u�u����!3�4�4����-�-�J�C��)�)�+�C���#�C�!�S�M�.�	���x� �5r+r	)rrr
c��[RURS5nU(aUR"S5O/n[	URS5n[	URS5nUR
n[
U5(a![S5n[R"U5eURRS5 [R"XQX4U5 g)Nrr�rr
�1cannot apply stream clone to non empty repository�applying stream bundle
)rrr@r�rLryrhrrrnr'r%r�
applybundlev2)r�r�rrrryr�s       r)�handlestreamv2bundler�E
s����>�>�$�+�+�o�">�?�L�/;�<�%�%�d�+��L��D�K�K��-�.�I��D�K�K��-�.�I�
�7�7�D�
�4�y�y��D�E���k�k�#����G�G�M�M�-�.����d�)��Mr+r
)rc�\�[RURS5nU(aUR"S5O/nURn[U5(a![
S5n[R"U5eURRS5 [R"X1U5 g)Nrr�r�r�)
rrr@r�ryrhrrrnr'r%r�
applybundlev3)r�r�rryr�s     r)�handlestreamv3bundler�U
sz���>�>�$�+�+�o�">�?�L�/;�<�%�%�d�+��L�
�7�7�D�
�4�y�y��D�E���k�k�#����G�G�M�M�-�.����d�,�7r+c�h�[5nURn	URSU5H#n
URU	R	U
55 M% U(a�[
R"UUUUUS9nURUR1[U5SSSS9nURSUS9n
U
RSU5 [R"U5(aU
RS	S
5 [RUR ;a/W
RSS
5 [#U5nU
RSU5 U$)
a#generates bundle2 for widening a narrow clone

bundler is the bundle to which data should be added
repo is the localrepository instance
oldmatcher matches what the client already has
newmatcher matches what the client needs (including what it already has)
common is set of common heads between server and client
known is a set of revs known on the client side (used in ellipses)
cgversion is the changegroup version to send
ellipses is boolean value telling whether to send ellipses data or not

returns bundle2 of the data required for extending
s::%ln)�
oldmatcher�matcher�	fullnodesFsnarrow_widen)r�r�r�r�r.r�r�r�)r�r�r�rTr�r	�
getbundlerr��nullidr�r�r�rr5rr�r�r�)r�ryr��
newmatcher�common�knownr��ellipses�commonnodesr�r)�packer�cgdatar�r�s               r)�widen_bundler�c
s
�� �%�K�	
���B�
�Y�Y�x��
(���������
�#�)���'�'���!��!�
�����
�[�[�M�������!�
�����~�F��;���
�
�j�)�,��!�!�$�'�'��M�M�/�4�0��(�(�D�M�M�9��
�
�o�t�,�.�t�4���
�
�,�f�5��Nr+)r7)NN)NNr+N)r�bytesrVr�r<)FN)r�rlrVr�)rVr�)rr�)NNNF)T)NNN)�rs�
__future__rr�rmr_�rer2rar��typing�i18nrr�rrr�rr	r
rrr
rrrrrrrr�utilsrr�
interfacesr�
TYPE_CHECKINGrrrrrrr�r��urlerrrr�rCrrcrDrQr�r�r�r�r��compiler/r*r-r4r9r>rErGrw�RuntimeErrorr�r�r�r�r�r�r�r�r�rrr&�bundlepriorityrrYrtr�ror�r�r�r<r�r�rrr�r�r]r�DIGESTS�keysr��__annotations__r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r-r@�_remotechangegroupparamsrQrUrarhrnrwryr{rnr}r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�r�)r�s0r)�<module>r�s��K�Z#���	�	�
�
�
�
������� �#�	�������u�T�%�[�%��s�
�2C�%C�D�D�E�L�	
����	
��������
�-�-�����������
������Z�Z� 2�3��4�3�#�%����,-�-�`:'�:'�z	�\�	�#��$D
�D
�T����
.�b#��'�T�:�0
�
��!��!���3��z�z�z7�7�8�&f$��f$�R�J��	�����n�%�%�&�%�d�d�N�
�0
�}�0
�fQ�Q�&5J�p|*�=�|*�~v�<�v�x��I����f�T�\�\�.�.�0�1�2�.������l��.�b �?�	
��
��0E�f98�x
�:Q�*9�
��5�
�GE�TL�$HL�.E�b�*
���
�4�
�4�n!�!�!%���!2�!2�!4�5�!4�A�|�a��!4�5�6���
�
"�$<�=�K�>�K�\
�
!�#>�?�>�@�>�
�
� �",�!�",�J
�^��
��
�(
�
#�$��%��>
�_��0��0�2
�Y��0��0�
�\��)��)�H�E�K�K�H�
�^�2�3��4��
��B��	�	�	�
�
(�*B�C�
H�D�
H�
�
��/�M�0�M�

�[�/�*�0�+�0�
�Z�?�@�
�A�
�<
�\��@
��@
�F
�^��O��O�
�
�:�;�9�<�9�
�]��=��=�4
�
 �":�;�9�<�9�
�_��E��E�0
�M�M�'�"�	�
�
&�'��(��
�[��!��!�
�Z�F�G�N�H�N�
�^�/�0�
8�1�
8�-��}6s�6P

Youez - 2016 - github.com/yon3zu
LinuXploit