ROOTPLOIT
Server: Apache
System: Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
User: ws67150586 (67150586)
PHP: 8.3.36
Disabled: NONE
Upload Files
File: //kunden/kunden/kunden/lib/python3/dist-packages/mercurial/__pycache__/streamclone.cpython-313.pyc
�

6�h���R�SSKJr SSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	J
r
JrJrJ
r
JrJr SSKJr SSKJr SSKJrJrJrJrJrJrJrJrJrJ r J!r!J"r" SSK#J$r$ \RJS\RLS	\RNS
0r(\RJS\RLS\RNS
0r)SFSjr*SGSjr+SHSISjjr,SJSjr-SKSjr.SLSMSjjr/SNSjr0SOSjr1SPSjr2SQSRSjjr3SSSjr4STSjr5SJSjr6"SS5r7Sr8Sr9Sr:Sr;SUSjr<S r="S!S"5r>S#r?S$r@SVS%jrAS&rBS'rCS(rD"S)S*\ R�5rF"S+S,\ R�5rHSWS-jrISWS.jrJSXS/jrK\R�S05rM"S1S25rNSYS3jrO\\PrQ\\P\\R\Q4rS"S4S55rT"S6S75rU"S8S95rV"S:S;5rW"S<S=\W5rXSZS>jrY\WS4S[S?jjrZS\S@jr[SJSAjr\S]SBjr]S^SCjr^SKSDjr_SJSEjr`g)_�)�annotationsN)�Callable�Iterable�Iterator�Optional�Set�Tuple�Type�)�_)�
repository)�	bookmarks�bundle2�	cacheutil�error�
narrowspec�phases�pycompat�requirements�scmutil�store�transaction�util)�nodemap��i i@lc�d�[U5nU[R- URU5 U$)z�determine the final set of requirement for a new stream clone

this method combine the "default" requirements that a new repository would
use with the constaint we get from the stream clone content. We keep local
configuration choice when possible.
)�set�requirementsmod�STREAM_IGNORABLE_REQUIREMENTS�update)�default_requirements�streamed_requirementsrs   �7/usr/lib/python3/dist-packages/mercurial/streamclone.py�new_stream_clone_requirementsr%Cs2���+�,�L��?�@�@�@����-�.���c�@�UR[R-
nU$)z�the set of requirement the new clone will have to support

This is used for advertising the stream options and to generate the actual
stream content.)rrr )�repo�requiredformatss  r$r#r#Ss%��	
���O�I�I�I���r&c�\�URnURnURnUcURS5nU(dg[	U5(agUR
(agSnUR(ab[R"USS9n[URS/55n[URRS/55n[Xx-5nU(aU(dgU(aU(dg[5n	URS5(a#U	R[R5 S
U	4$URS5n
U
(d/URR R#[%S55 g[U
R'S	55n
X�R(-
nU(axURR R#[%S
5SR+[-U55-5 URR R#[%S55 gU
n	S
U	4$)a�Whether it is possible to perform a streaming clone as part of pull.

``bundle2`` will cause the function to consider stream clone through
bundle2 and only through bundle2.

Returns a tuple of (supported, requirements). ``supported`` is True if
streaming clone is supported and False otherwise. ``requirements`` is
a set of repo requirements from the remote, or ``None`` if stream clone
isn't supported.
sstream-preferred)FNFsclient)�rolesstreams
streamreqss=warning: stream clone requested but server has them disabled
�,sGwarning: stream clone requested but client is missing requirements: %s
�, sQ(see https://www.mercurial-scm.org/wiki/MissingRequirement for more information)
T)r(�remote�streamclonerequested�capable�len�heads�
canusebundle2�
bundle2mod�getrepocapsr�get�remotebundle2caps�bool�addr�REVLOGV1_REQUIREMENT�ui�warnr�split�	supported�join�sorted)�pulloprr(r.�streamrequested�bundle2supported�
local_caps�local_supported�remote_supportedr�
streamreqs�missingreqss            r$�canperformstreamclonerI^s����;�;�D�
�]�]�F��1�1�O��� �.�.�)<�=�����4�y�y���|�|����
����+�+�D�y�A�
��j�n�n�Y��;�<���v�7�7�;�;�I�r�J�K���� B�C�����	�)���5�L�
�~�~�i� � �����=�=�>�B����?�^�^�M�2�
���K�K�N�N����"��
����)�)�$�/�0�
� �>�>�1����K�K�N�N����*���*�*�V�K�0�1�	2�
�
�K�K�N�N����/��
��!�����r&c�,�SSKJn [U5up#U(dgURnURnSnURS5(a9UR
5nURS05R5nSSS5 URR[S55 UR
5nURS05R5nSSS5 WR5n	[U	5n
U
S:Xa[R""[S55eU
S	:Xa[R""[S
55eU
S:wa[R""[S55eUR5n	[%[U	R'S
S55up�UR+5 [-XHX�5 [/UR0U5UlUR3URUR0UR45UR6l[:R<"U5 [>R@"U5 U(aURBREXF5 URG5 SSS5 g!,(df   GN	=f!,(df   GN�=f![a! [R "[S5U	5ef=f![[(4a! [R "[S5U	5ef=f!,(df   g=f)z�Possibly perform a legacy stream clone operation.

Legacy stream clones are performed as part of pull but before all other
operations.

A legacy stream clone will not be performed if a bundle2 stream clone is
supported.
r��	localrepoNs	branchmapsstreaming all changes
s
stream_out�'unexpected response from remote server:soperation forbidden by server�s$locking the remote repository failedrs%the server sent an unknown error code� )$�rLrIr(r.r0�commandexecutor�callcommand�resultr;�statusr�readline�int�
ValueErrorr�
ResponseError�Abort�mapr=�	TypeError�lock�	consumev1r%r�resolvestorevfsoptions�features�svfs�optionsr�writereporequirementsr�post_stream_cleanup�
_branchcaches�replace�
invalidate)
rArLr>rr(r.�
rbranchmap�e�fp�l�resp�	filecount�	bytecounts
             r$�maybeperformlegacystreamclonern�sk���3�F�;��I����;�;�D�
�]�]�F��J�
�~�~�l�#�#�
�
#�
#�
%�����|�R�8�?�?�A�J�&�	�G�G�N�N�1�/�0�1�	�	�	�	!�Q�
�]�]�=�"�
-�
4�
4�
6��
"�	���
�A�
��1�v��
�q�y��k�k�!�<�=�>�>�	
����k�k�!�C�D�E�E�	
����k�k�!�D�E�F�F�
���
�A�
�"�3�����a�(8�9��	�
�����$�I�1�9�����
���&�<�<��G�G�T�&�&��
�
�
��	�	��	�%�%�d�+��#�#�D�)�����&�&�t�8�����
��E&�
%��

"�	!���
��!�!�
�8�9�1�
�	
�
��
�	�"�
��!�!�
�8�9�1�
�	
�
��

��s=�!I?�9!J�3J#�>"K�0CL�?
J�
J �#+K�1L�
Lc��[RUR;agURR	SSSS9(dg[
R"U5nU(aURR	SS5$g)z5Whether streaming clones are allowed from the server.FsserversuncompressedT)�	untrustedsuncompressedallowsecret)r
�REPO_FEATURE_STREAM_CLONEr_r;�
configboolr�	hassecret)r(�secrets  r$�allowservergenerationrusc���+�+�4�=�=�@���7�7���i��D��I���
�
�d�
#�F�
��w�w�!�!�)�-G�H�H�r&c�6�URRXUS9$)N��phase�obsolescence)r�walk)r(�matcherrxrys    r$�_walkstreamfilesr|s���:�:�?�?�7�l�?�K�Kr&c��[R"5U-
nUS::aSn[S5nUU[R"U5U[R"X4-54-nURRU5 g)z@common utility to report time it took to apply the stream bundlerg����MbP?s5stream-cloned %d files / %s in %.1f seconds (%s/sec)
N)r�timerrrmr;rT)r(�
start_time�
file_count�
byte_count�elapsed�ms      r$�_report_transferredr�sm���j�j�l�Z�'�G��!�|���	�
C�D�A������z�"�����z�+�,�	
��A�	�G�G�N�N�1�r&c�^^^^�/mSnTR5 TRRS5 [T5 [	T5HinUR5HRnUR
TRR5nU(dM1TRURU45 X-
nMT Mk [T5 SSS5 [T5 TRRS[T5U4-5 TRmTRRmSUUUU4Sjjn[T5X"54$!,(df   N�=f)a�Emit content for version 1 of a streaming clone.

This returns a 3-tuple of (file count, byte size, data iterator).

The data iterator consists of N entries for each file being transferred.
Each file entry starts as a line with the file name and integer size
delimited by a null byte.

The raw file data follows. Following the raw file data is the next file
entry, or EOF.

When used on the wire protocol, an additional line indicating protocol
success will be prepended to the stream. This function is not responsible
for adding it.

This function will obtain a repository lock to ensure a consistent view of
the store is captured. It therefore may raise LockError.
r�	scanning
Ns%d files, %d bytes to transfer
c3�`># �TH�upT(aTRRSX4-5 S[R"U5U4-v� T"USSS9nUS::aUR	U5v� O[
R"X!S9Shv�N SSS5 M� gN!,(df   M�=f7f)Nssending %s (%d bytes)
s%s%d
srbF)�	auditpathi��limit)r;�debugr�	encodedir�readr�
filechunkiter)�name�sizeri�	debugflag�entriesr(r`s   ����r$�emitrevlogdata�"generatev1.<locals>.emitrevlogdataYs�����!�J�D�����
�
�8�D�<�G�H������!6�� =�=�=��d�E�U�3�r��5�=��'�'�$�-�'�#�1�1�"�A�A�A�	4�3�"�B�	4�3�s0�AB.�2B�B�	B�

B.�B�
B+	�&B.��returnzIterator[bytes])r\r;r��_test_sync_point_walk_1_2r|�files�	file_sizer�vfs�append�unencoded_path�_test_sync_point_walk_3�_test_sync_point_walk_4r1r`r�)	r(�total_bytes�entry�fr�r�r�r�r`s	`     @@@r$�
generatev1r�0s���&�G��K�	
�������
�
�m�$�!�$�'�%�d�+�E��[�[�]���K�K��
�
���7�	��9��N�N�A�$4�$4�i�#@�A��,�K�	#�,�	 ��%�
��D�!��G�G�M�M�+�s�7�|�[�.I�I���9�9�D����!�!�I�B�B��w�<��n�&6�6�6�C
��s�A2D>�4D>�>
Ec#�# �[U5(dSv� g[U5upnSv� SX4-v� UShv�N g![Ra Sv� gf=fN#7f)a�Emit content for version 1 of streaming clone suitable for the wire.

This is the data output from ``generatev1()`` with 2 header lines. The
first line indicates overall success. The 2nd contains the file count and
byte size of payload.

The success line contains "0" for success, "1" for stream generation not
allowed, and "2" for error locking the repository (possibly indicating
a permissions error for the server process).
s1
Ns2
s0
s%d %d
)rur�r�	LockError)r(rlrm�its    r$�generatev1wireprotor�jsl���!��&�&�����#-�d�#3� �	�b��L�
�	�-�
-�-��M�M���?�?��������s/�A�>�A�A�A�A�A�A�Ac�^^^�TS:wa[S5e[T5nSR[U55mSUUU4SjjnX#"54$)aEmit content for version 1 of a stream clone bundle.

The first 4 bytes of the output ("HGS1") denote this as stream clone
bundle version 1.

The next 2 bytes indicate the compression type. Only "UN" is currently
supported.

The next 16 bytes are two 64-bit big endian unsigned integers indicating
file count and byte count, respectively.

The next 2 bytes is a 16-bit big endian unsigned short declaring the length
of the requirements string, including a trailing . The following N bytes
are the requirements string, which is ASCII containing a comma-delimited
list of repo requirements that are needed to support the data.

The remaining content is the output of ``generatev1()`` (which may be
compressed in the future).

Returns a tuple of (requirements, data generator).
�UNz.we do not support the compression argument yetr,c3�
># �Sv� Tv� [T5upnTRR[S5X4-5 [R
"SX5v� [R
"S[
T5S-5v� TS-v� TS:XdeTRR[S5U[S	5S
9nURS5 UHnUR[
U5S9 Uv� M! UR5 g7f)
NsHGS1swriting %d bytes for %d files
�>QQ�>Hr�r��bundle�bytes��total�unitr��step)r�r;rTr�struct�packr1�makeprogressr!�	increment�complete)rlrmr��progress�chunk�compressionr(�requiress     ���r$�gen�generatebundlev1.<locals>.gen�s������
���#-�d�#3� �	�b������
�0�1�Y�4J�J�	
��k�k�&�)�7�7��k�k�%��X���!2�3�3������e�#�#�#��7�7�'�'�
�i�L�	��(��(�
��	������E����C��J��/��K��	����s�DDr�)rWr#r?r@)r(r�rr�r�s``  @r$�generatebundlev1r��sO���0�e���I�J�J�(��.�L��y�y���-�.�H���6����r&c��UR5 URR[S5U[R
"U54-5 URR
[S5U[S5S9nURS5 [R"5nSnURS5 URRURUS9 [U5GHen[US5(aUR5nOW/n	U	(a	U	SS	:Xd4U	RUR!S
55 U	(dM)U	SS	:XdM4SR#U	5nUR%SS
5up�['U5nURR0(a4URR3SU
[R
"U54-5 [4R6"U
5nURUSSS9n
US
-
n[R8"XS9H,nUR;[=U5S9 U
R?U5 M. SSS5 GMh SSS5 URASS9 SSS5 URC5 [EXXc5 SSS5 g![([*4a! [,R."[S
5U5ef=f!,(df   GM�=f!,(df   N�=f!,(df   N�=f!,(df   g=f)z�Apply the contents from version 1 of a streaming clone file handle.

This takes the output from "stream_out" and applies it to the specified
repository.

Like "stream_out," the status line added by the wire protocol is not
handled by this function.
�!%d files to transfer, %s of data
�cloner�r�r)�
expectedcountrU����
rr&r�rMsadding %s (%s)
�wT)�backgroundcloser�r�N��clearfilecache)#r\r;rTrrrmr�r!r~rr`�backgroundclosing�range�hasattrrUr�r�r?r=rVrWr[rrXr�r�r�	decodedirr�r�r1�writerfr�r�)r(rirlrmr��start�total_file_count�irj�l_bufr�r��path�ofpr�s               r$r]r]�s|��
���������
�3�4��$�.�.��3�4�
5�	
��7�7�'�'�
�h�K�y�q��{�(�
��	������
�
��� ��
�
�
�h�
'����,�,�T�W�W�I�,�N��y�)�A��r�:�.�.��K�K�M��
!#��#(�U�2�Y�%�-?�!�L�L������4�$)�5�U�2�Y�%�-?��H�H�U�O���%&�W�W�U�A�%6�
��"�4�y��
�w�w�(�(����
�
�/�4�����9M�2N�N��!�?�?�4�0�D����4��t��D��(�A�-�(�%)�%7�%7��%G�E�$�.�.�C��J�.�?��I�I�e�,�&H�E�D�3*�O�D
�O�O�4�O�0�G(�J	�����D�)9�E�A
���V'�	�2��#�1�1��H�I�1�����E�D��5O�N��(�
'��5
��s{�B$K=�5%K,�A+K�	K�K�$J�A6K�9A
K�
K�K,�'$K=�1K�K�
K�	K�
K)�%K,�,
K:	�6K=�=
Lc��URS5nUS:wa"[R"[S5U-5e[R
"SURS55up#[R
"SURS55SnURU5nUR
S5(d[R"[S	55e[URS5RS
55nX#U4$)NrNr�s<only uncompressed stream clone bundles are supported; got %sr��r�rr�s@malformed stream clone bundle: requirements not properly encodedr,)
r�rrYrr��unpack�endswithr�rstripr=)rir�rlrm�requireslenr�rs       r$�readbundle1headerr�
s����'�'�!�*�K��e���k�k�
�%�
��	
�
�	
�"�=�=�������=��I��-�-��r�w�w�q�z�2�1�5�K��w�w�{�#�H����U�#�#��k�k�
�5�
�
�	
��x���u�-�3�3�D�9�:�L���-�-r&c�`�[U5(a[R"[S55e[	U5up#nX@R
-
nU(a:[R"[S5SR
[U55-5e[XX#5 [R"U5 g)z�Apply the content from a stream clone bundle version 1.

We assume the 4 byte header has been read and validated and the file handle
is at the 2 byte compression identifier.
s2cannot apply stream clone bundle on non-empty repo�4unable to apply stream clone: unsupported format: %sr-N)r1rrYrr�r>r?r@r]rrc)r(rirlrmrrHs      r$�
applybundlev1r�)s����4�y�y��k�k�
�C�D�
�	
�*;�2�)>�&�I�,����/�K���k�k�
�E�F��j�j���,�-�
.�
�	
�
�d�	�-�����%r&c�,�\rSrSrSrSSjrSSjrSrg)�streamcloneapplieri@z�Class to manage applying streaming clone bundles.

We need to wrap ``applybundlev1()`` in a dedicated type to enable bundle
readers to perform bundle type-specific functionality.
c��Xlg�N��_fh)�self�fhs  r$�__init__�streamcloneapplier.__init__Gs���r&c�,�[XR5$r�)r�r�)r�r(s  r$�apply�streamcloneapplier.applyJs���T�8�8�,�,r&r�N�r��None)�__name__�
__module__�__qualname__�__firstlineno__�__doc__r�r��__static_attributes__�r&r$r�r�@s����-r&r��s�cc�V�/nUR5(dURS5 U$)z!list snapshot file from the stores
phaseroots)�
publishingr�)r(�fnamess  r$�_walkstreamfullstorefilesr�Xs%��
�F��?�?����
�
�m�$��Mr&c�Z�Uup4pVU[:waU$X4XQ"X#RU554$)z actually copy the snapshot files)�	_filefullr?)r��copy�vfsmap�srcr��ftype�datas       r$�_filterfullr`s8��"��C�u��	�����u�d�6�;�#3�#3�D�#9�:�;�;r&c��\rSrSrSr\R(aSOSrSSjrSr	Sr
SSjrSS	jrSS
jr
SSjrSSjr\R"S
5rSrg)�VolatileManageriha�Manage temporary backups of volatile files during stream clone.

This class will keep open file handles for the volatile files, writing the
smaller ones on disk if the number of open file handles grow too much.

This should be used as a Python context, the file handles and copies will
be discarded when exiting the context.

The preservation can be done by calling the object on the real path
(encoded full path).

Valid filehandles for any file should be retrieved by calling `open(path)`.
rN�dc�<�SUlSUlSUlSUlg�Nr)�_counter�
_volatile_fps�_copies�_dst_dir�r�s r$r��VolatileManager.__init__}s����
�!��������
r&c�|�URS:XaURbe0UlU=RS-
slU$�Nrr)rr	rs r$�	__enter__�VolatileManager.__enter__�s;���=�=�A���%�%�-�-�-�!#�D���
�
���
��r&c��U=RS-slURS:Xa�URR5Hup4UR5 M SUlURbWURR5Hn[
R"U5 M [
R"UR5 SUlSUlURbeURbeURbegg)zdiscard all backupsrrN)	rr	�values�closer
r�	tryunlink�tryrmdirr)r��args�kwars�_sizeri�tmps      r$�__exit__�VolatileManager.__exit__�s����
�
���
��=�=�A��!�/�/�6�6�8�	�����
�9�!%�D���|�|�'��<�<�.�.�0�C��N�N�3�'�1��
�
�d�m�m�,��D�L� �D�M��%�%�-�-�-��<�<�'�'�'��=�=�(�(�(�r&c��SUR:deURbeURbe0Ul[R"SS9Ulg)zpprepare a temporary directory to save volatile files

This will be used as backup if we have too many files openrNs	hg-clone-)�prefix)rr
rr�mkdtemprs r$�_init_tmp_copies� VolatileManager._init_tmp_copies�sO���4�=�=� � � ��|�|�#�#�#��}�}�$�$�$���� �(�(��=��
r&c�l�URcUR5 URS-n[URR55SUH�unup4[RRU5n[R"XPRS9upgXpRU'[R"U5 [US5nURS5 URUR!55 SSS5 URU	UR5 M� g!,(df   N0=f)z4move some of the open files to tempory files on diskNrN)r�dir�wbr)r
r �MAX_OPENr@r	�items�osr��basenamer�mkstemprr�open�seekr�r�)	r��flush_countr�r�rir�fd�dst�bcks	         r$�_flush_some_on_disk�#VolatileManager._flush_some_on_disk�s����<�<���!�!�#��m�m�q�(��%�d�&8�&8�&>�&>�&@�A�,�;�O�O�C��$��W�W�%�%�c�*�F��&�&�f�-�-�H�G�B� #�L�L����H�H�R�L��c�4��C�����
��	�	�"�'�'�)�$�!��"�"�3�'��H�H�J� P�!��s�
1D%�%
D3	c���S[US54=up#URU'URS[R5 UR5nXC4URU'U$)z-preserve an open file handle for a given pathN�rbr)r*r	r+r'�SEEK_END�tell)r�r�rrir�s     r$�	_keep_one�VolatileManager._keep_one�sZ��,0��c�4��*A�A����"�"�3�'�
����2�;�;���w�w�y��#'�*����3���r&c��SUR:de[UR5URS-
:�aUR	5 URU5 g)z!preserve the volatile file at srcrrN)rr1r	r%r0r6)r�r�s  r$�__call__�VolatileManager.__call__�sH���4�=�=� � � ��t�!�!�"�t�}�}�q�'8�9��$�$�&����s�r&c�B�SUR:de[UR5URS-
:�aUR	5 URU5$![a9nUR[R[R4;aeSnAgSnAff=f)z�record a volatile file and returns it size

return None if the file does not exists.

Used for cache file that are not lock protected.
rrN)
rr1r	r%r0r6�OSError�errno�ENOENT�EPERM)r�r��errs   r$�try_keep�VolatileManager.try_keep�s����4�=�=� � � ��t�!�!�"�t�}�}�q�'8�9��$�$�&�	��>�>�#�&�&���	��y�y����u�{�{� ;�;����	�s�
A�
B�%/B�Bc#�J# �SUR:deURRU5nUbUup4URS5 Uv� gURcUnOURRX5n[US5nUv� SSS5 g!,(df   g=f7f)Nrr3)rr	r6r+r
r*)r�r�r�rri�actual_paths      r$r*�VolatileManager.open�s�����4�=�=� � � ��"�"�&�&�s�+�����I�E��G�G�A�J��H��|�|�#�!��"�l�l�.�.�s�8���k�4�(�B���)�(�(�s�BB#�B�		B#�
B �B#)r
rrr	Nr�)r��bytesr�rV)r�rFr�r�)r�rFr�z
Optional[int])r�r�r�r�r�r�	iswindowsr%r�rrr r0r6r9rA�
contextlib�contextmanagerr*r�r�r&r$rrhsZ���$�&�&�q�C�H���)�">��&���"���
��
r&rc��[UR[UR0nURUR5;deU$)z$make a (src -> vfs) map for the repo)�	_srcstorer`�	_srccache�cachevfsr�r)r(r�s  r$�_makemaprN�s<��	�4�9�9��4�=�=��F��8�8�6�=�=�?�*�*�*��Mr&c#�# �[U5nURUR5;a[R"S5eUVVs/sHup4X2UU4PM nnn[U5 [
U5nS=pg[5n[R"5 UHFup�nURX�5 UR5HnUS-
nX{RU
5-
nM MH SSS5 URR[S5U[S5S9nUR!S5 U Xg4v� Sn
UH�up�nUR#UU
UUSS	9nUH�unnnUv� [R$"[
U55v� [R$"U5v� Uv� SnUH4nU[
U5-
nU
[
U5-
n
UR!U
5 Uv� M6 UU:wdM�[S
5n[R&"UUUU4-5e M� SSS5 SSS5 gs snnf!,(df   GND=f!,(df   N/=f!,(df   g=f7f)zactually emit the stream bundle�9repo.vfs must not be added to vfsmap for security reasonsrrNr�r�r�T)r(r��	volatiles�
max_changeset�preserve_file_counts=clone could only read %d bytes from %s, but expected %d bytes)rNr�rr�ProgrammingErrorr�r1rr�nogc�preserve_volatilesr�r�r;r�rr!�get_streams�
uvarintencoderY)r(r�r��vfs_keyrh�max_linkrevr��
totalfilesizerQ�kr�r�r��totalbytecountr��
entry_streamsr��streamr�rmr��msgs                      r$�_emit2ra�s+���
�d�^�F��x�x�6�=�=�?�"��$�$�G�
�	
�
BI�I���'����!�,��G�I��d�#��d�)�K�!"�"�J�	�	�i�
�Y�Y�[�$�	����$�$�S�4�����A��!�O�J�!�[�[��%5�5�M�#�%���7�7�'�'�
�i�L�
�A�h�K�(�
��	�����
��+�+��N�&���!� !�
�
���'�"-�(,�!.�!�
�+8�&�D�&�$��I��,�,�S��Y�7�7��,�,�T�2�2��J� !�I�!'��!�S��Z�/�	�&�#�e�*�4�� ����7�#��	"(�
!�D�(� �1���$�k�k�#��D�$�0G�*G�H�H�%+8� '��
�	��J��[���X��
�	�sc�AI�H�&I�I�A
H �#AI�+B-H2�-H2�	I�I� 
H/	�*I�2
I	�<I�
I�
Ic
#�# �[U5nURUR5;a[R"S5e[U5n[
U5 /n[5nUH�upVX%nSnUR(aNSnURXt5 UR5H'n	U	R(aU	RU5 SnM) U(dMsURXRUU45 M� [U5n
[U5nURR![#S5U
[#S5S9nUR%S5 Sv� U [&R("U
5v� UH�up�nUR+UUUUS	9n[&R("[U55v� UHRunnnU
v� [&R("[U55v� [&R("U5v� Uv� UShv�N MT UR-5 M� SSS5 SSS5 gN-!,(df   N=f!,(df   g=f7f)
z$actually emit the stream bundle (v3)rPTFr�sentryr�rN)r(r�rQrR)rNr�rrrT�listr�r�maybe_volatilerVr��is_volatiler�r�r1r;r�rr!rrXrWr�)r(r�r��base_entriesrQrYrhr��	any_filesr��total_entry_countrZr�r�r^r�r_r�s                  r$�_emit3ri:s����
�d�^�F��x�x�6�=�=�?�"��$�$�G�
�	
���=�L��d�#��G�	�	�i�&�J�G��/�C��I����!�	��$�$�S�4�����A��}�}����C�(� $�I�	#�
�y�������!�<�=�'� ��L���$�i���7�7�'�'�
�i�L�#��8��(�
��
	������
�
��$�$�%6�7�7�&���!� !�
�
���'�"-�	!.�!�
��(�(��]�);�<�<�*7�&�D�&�$��I��,�,�S��Y�7�7��,�,�T�2�2��J�%�%�%�+8��"�"�$� '��7
�	�V&�!�X��7
�	�sQ�A"I�$A2H2�A4H2�B#H!�1H�2H!�H2�	I�H!�!
H/	�+H2�2
I�<Ic��g)z�a function for synchronisation during tests

Triggered after gather entry, but before starting to process/preserve them
under lock.

(on v1 is triggered before the actual walk start)
Nr��r(s r$r�r�{��r&c��g)z�a function for synchronisation during tests

Triggered right before releasing the lock, but after computing what need
needed to compute under lock.
Nr�rks r$r�r��rlr&c��g)zWa function for synchronisation during tests

Triggered right after releasing the lock.
Nr�rks r$r�r��rlr&c�J^�\rSrSrSrSU4SjjrSSjrSU4SjjrSrU=r	$)	�
CacheEntryi�z�Represent an entry for Cache files

It has special logic to preserve cache file early and accept optional
presence.


(Yes... this is not really a StoreEntry, but close enough. We could have a
BaseEntry base class, bbut the store one would be identical)
c�">�[TU]USS9 g)NT)re)�superr�)r��
entry_path�	__class__s  �r$r��CacheEntry.__init__�s���
�����	�	
r&c��URURUR55UlURc/UlgUR
(de[
URURUR
S9/Ulg)N)r�r�re)rAr?�_entry_path�
_file_size�_files�_is_volatile�	CacheFile)r�r�rQs   r$rV�CacheEntry.preserve_volatiles�sm��#�,�,�S�X�X�d�6F�6F�-G�H����?�?�"��D�K��$�$�$�$��#'�#3�#3�"�o�o� $� 1� 1���D�Kr&c�>�URc$[URURS9/Ul[TU]5$)N)r�re)ryr{rwrzrrr�)r�rts �r$r��CacheEntry.files�s>����;�;���#'�#3�#3� $� 1� 1���D�K��w�}��r&)rxryr�)r�zlist[store.StoreFile])
r�r�r�r�r�r�rVr�r��
__classcell__�rts@r$rprp�s����
���r&rpc�$�\rSrSr%SrS\S'Srg)r{i�Tr8�optionalr�N)r�r�r�r�r��__annotations__r�r�r&r$r{r{�s���H�d�r&r{c#�# �URUR5ceSnU(dU(a![R"URX5nUR5(+n[R"5 [UUUUS9nUH
n[U4v� M [R"U5H6nURRU5(dM%[[US94v� M8 SSS5 g!,(df   g=f7f)z�emit a seris of files information useful to clone a repo

return (vfs-key, entry) iterator

Where `entry` is StoreEntry. (used even for cache entries)
Nrw)rs)�_currentlock�_lockrefr�match�rootr�rrUr|rKr�cachetocopyrM�existsrLrp)	r(�includes�excludes�includeobsmarkersr{rxr�r�r�s	         r$�
_entries_walkr��s�������T�]�]�+�7�7�7��G��8��"�"�4�9�9�h�A�����!�!�E�
����"����*�	
���E��e�$�$���)�)�$�/�D��}�}�#�#�D�)�)� �*��"=�>�>�0�
���s%�A:D�<AC5�C5�,	D�5
D�?Dc��UR5 URRS5 [UUUUS9n[	X5n[U5nUupx[
U5 SSS5 [U5 WWW4$!,(df   N=f)a�Emit content for version 2 of a streaming clone.

the data stream consists the following entries:
1) A char representing the file destination (eg: store or cache)
2) A varint containing the length of the filename
3) A varint containing the length of file data
4) N bytes containing the filename (the internal, store-agnostic form)
5) N bytes containing the file data

Returns a 3-tuple of (file count, file size, data iterator).
r��r�r�r�N)r\r;r�r�ra�nextr�r�)	r(r�r�r�r��chunks�firstr��total_file_sizes	         r$�
generatev2r��s|��
�������
�
�m�$�����/�	
����&���V���&+�#�
���%�
��D�!����.�.�
��s�A
A6�6
Bc	�|�UR5 [R"5 URR	S5 [UUUUS9n[
U[U55n[U5nUbe[U5 SSS5 SSS5 [U5 W$!,(df   N#=f!,(df   N,=f)a�Emit content for version 3 of a streaming clone.

the data stream consists the following:
1) A varint E containing the number of entries (can be 0), then E entries follow
2) For each entry:
2.1) The number of files in this entry (can be 0, but typically 1 or 2)
2.2) For each file:
2.2.1) A char representing the file destination (eg: store or cache)
2.2.2) A varint N containing the length of the filename
2.2.3) A varint M containing the length of file data
2.2.4) N bytes containing the filename (the internal, store-agnostic form)
2.2.5) M bytes containing the file data

Returns the data iterator.

XXX This format is experimental and subject to change. Here is a
XXX non-exhaustive list of things this format could do or change:

- making it easier to write files in parallel
- holding the lock for a shorter time
- improving progress information
- ways to adjust the number of expected entries/files ?
r�r�N)r\rrUr;r�r�rircr�r�r�)r(r�r�r�r�r�r�s       r$�
generatev3r�s���<
����d�i�i�k����
�
�m�$�����/�	
����d�7�m�,���V����}��}���%�"���D�!��M�"�k����s#�B-�AB�?B-�
B*	�&B-�-
B;c'�# �USnUSSnU U(a[U6 Sv� SSS5 OSv� SSS5 g!,(df   N=f!,(df   g=f7fr)�nested)�ctxs�this�rests   r$r�r�5sI�����7�D����8�D�	
��������
�
�����
��s/�
A�A�:�
A�	A�
A	�A�
A�Ac��\rSrSrSrSrSrg)�V2ReportiAz8a small class to track the data we saw within the streamc��SUlgr�r�rs r$r��V2Report.__init__Ds	����r&r�N)r�r�r�r�r�r�r�r�r&r$r�r�As
��B�r&r�c�^�TR5 TRR[S5U[R
"U54-5 TRR
[S5U[S5S9n[R"5n[5n[T5nTRUR5;a[R"S5e[R"TRS5n[R"TRS5n	TRR!SS	5n
TRR#SS
5nUS::a	[$UnTRR'SS5nUS:aS
nOUS:Xa	[(U	nTR+S5 U4SjUR55n
[-U
6 /nS
nS
nS
nU
(d	[.nUnOu[0n[3US9nUbUR4n[R6"U5n[8R:"UR<U4S9nUR?U5 URA5 [CTUUUUUUUS9nU
(d[EU5 Oi[GU5n[IU5H>n[8R:"[DU4S9nUR?U5 URA5 M@ URK5 UbURO[QU55 UHnURS5 M S
S
S
5 TRUSS9 S
S
S
5 URW5 URYS5nU(ae[[TXRUR\5 S
S
S
5 g
! UbURM5 e=f!UbURO[QU55 UHnURS5 M f=f!,(df   N�=f!,(df   N�=f!,(df   g
=f)z�Apply the contents from a version 2 streaming clone.

Data is read from an object that only needs to provide a ``read(size)``
method.
r�r�r�r�rPscpusmemorysworkers!parallel-stream-bundle-processings,parallel-stream-bundle-processing.num-writerrs/parallel-stream-bundle-processing.memory-targetNc3�X># �UHoRTR5v� M! g7fr��r�r;��.0r�r(s  �r$�	<genexpr>�consumev2.<locals>.<genexpr>z�!����N�o�s�)�)�$�'�'�2�2�o���'*)�
memory_target)�targetr)�file_chunker�	mark_usedTr�r)/r\r;rTrrrmr�r~r�rNr�rrrTr�get_resource_profilerr�	configint�DEFAULT_NUM_WRITER�configbytes�DEFAULT_MEMORY_TARGETrr��_FileChunker�_ThreadSafeFileChunker�
_DataQueuer��chunkbuffer�	threading�Thread�	fill_fromr�r��_v2_parse_files�_write_files�_FileInfoQueuer��fill�abortrr1r?rfr�r�r�r�)r(rirl�filesizer�r��reportr��cpu_profile�mem_profile�threaded�
num_writerr�r��workers�
info_queue�
data_queuer��fc�raw_data�wr��__�remainss`                       r$�	consumev2r�Hs����
���������
�3�4��$�.�.��2�3�
4�	
��7�7�'�'�
�h�K���8��(�
��
�
�
�������$����8�8�v�}�}��&��(�(�K��
��2�2�4�7�7�F�C���2�2�4�7�7�I�F���7�7�%�%��;�
���W�W�&�&��;�
�
���?�+�K�8�J����+�+��>�
�
��1�� �M�
�a�
�1�+�>�M�
�
�
�h�
'�N�f�m�m�o�N�D������!�
�!�
� �	�3!�#�)��#%��3��%/�m�%L�
�(�4�(2�(<�(<�I�#'�#3�#3�J�#?��%�,�,�#-�#7�#7�"$���� ���q�)����	�+�� ��!� ��%'�"+�	�E�$�$�U�+�%3�E�%:�
�"'�
�"3�B� )� 0� 0�'3�&0�]�!�A�$�N�N�1�-��G�G�I�
#4�#���)�"�-�#�(�(��W��6�$������%�o�x
�O�O�4�O�0�}(�@	�����'�'�!�*����{��D�%�F�4E�4E�F�a
���t�!�-�"�(�(�*���"�-�#�(�(��W��6�$������%��o���(�
'��W
��su�FO=�)#O,�	O�B'N�=N �>A(N�&N �'6O�O,�5A	O=�N	�N � 8O	�O�
O)�%O,�,
O:	�6O=�=
Pc�*�\rSrSrSrSrSrSrSrg)�_Queuei�zDa reimplementation of queue.Queue which doesn't use thread.Conditionc��[R"5Ul[R"5Ul[R"5Ulgr�)�collections�deque�_queuer��Lock�_lock�_waitrs r$r��_Queue.__init__�s0��!�'�'�)����^�^�%��
��^�^�%��
r&c��UR URRU5 URR	5(aURR5 SSS5 g!,(df   g=fr�)r�r�r�r��locked�release)r��items  r$�put�
_Queue.put�sH��
�Z�Z��K�K���t�$��z�z� � �"�"��
�
�"�"�$�	�Z�Z�s�AA+�+
A9c�^�UR [UR5S:Xa�URR	SS9 URR5 URR	5 URR	5 URR
5(a3[UR5S:�aURR5 [UR5S:XaM�URR5sSSS5 $!,(df   g=f)NrF��blockingr)r�r1r�r��acquirer�r��popleftrs r$r6�
_Queue.get�s���
�Z�Z��d�k�k�"�a�'��
�
�"�"�E�"�2��
�
�"�"�$��
�
�"�"�$��
�
�"�"�$�
�:�:�$�$�&�&�3�t�{�{�+;�a�+?��J�J�&�&�(��d�k�k�"�a�'� �;�;�&�&�(�#�Z�Z�s�C,D�;D�
D,)r�r�r�N)	r�r�r�r�r�r�r�r6r�r�r&r$r�r��s��N�&�%�)r&r�c�@�\rSrSrSrSSjrSrSrSrSr	S	r
S
rg)r�i�z�A queue passing data from the bundle stream to other thread

It has a "memory_target" optional parameter to avoid buffering too much
information. The implementation is not exact and the memory target might be
exceed for a time in some situation.
Nc�&�[5UlSUlXlURb&URS::a[R
"S5e[R"5Ul[R"5Ul	SUl
SUlg)NFrzmemory target should be > 0)r��_q�_abort�_memory_targetrrTr�r�r�r��
_current_read�
_current_used)r�r�s  r$r��_DataQueue.__init__sq���(������+�����*�t�/B�/B�a�/G��(�(�)F�G�G��^�^�%��
��^�^�%��
������r&c�j�URcgURUR-
UR:$)zfTrue if more data can be read without further exceeding memory target

Must be called under the lock.
T)r�r�r�rs r$�_has_free_space�_DataQueue._has_free_spaces7��
���&���"�"�T�%7�%7�7�4�;N�;N�N�Nr&c�2�URbyUR XR:�aXlURR	5(a/UR5(aURR
5 SSS5 gg!,(df   g=f)z{Notify we have used the buffer up to "offset"

This is meant to be used from another thread than the one filler the queue.
N)r�r�r�r�r�r�r�)r��offsets  r$r��_DataQueue.mark_used!sl��
���*�����.�.�.�)/�&��:�:�$�$�&�&�4�+?�+?�+A�+A��J�J�&�&�(���+���s�A$B�
Bc��URnUGH6nU=R[U5-
slURU5 UR(a O�UR
cMUUR UR5(d�URRSS9 URR5 URR5 URR5 URR5(aURR5 UR5(dM�SSS5 GM9 URS5 g!,(df   GM]=f!URS5 f=f)zffill the data queue from a bundle2 part object

This is meant to be called by the data reading thread
NFr�)r�r�r1r�r�r�r�r�r�r�r�r�)r�r�qr�s    r$r��_DataQueue.fill_from.s��

�G�G��	����"�"�c�$�i�/�"����d���;�;���&�&�2����"&�"6�"6�"8�"8�!�J�J�.�.��.�>� �J�J�.�.�0� �J�J�.�.�0� �J�J�.�.�0� $�z�z�0�0�2�2� $�
�
� 2� 2� 4�#'�"6�"6�"8�"8�$��
�*
�E�E�$�K�$���
�E�E�$�K�s+�AE0�%E0�1CE�>
E0�
E-	�'	E0�0Fc#�# �URnUR5=nb,Uv� UR(agUR5=nbM+gg7f)zWIterate over the bundle chunkgs

This is meant to be called by the data parsing thread.N)r�r6r��r�r�r�s   r$�__iter__�_DataQueue.__iter__LsA���
�G�G���E�E�G�|�q�(��G��{�{���E�E�G�|�q�(�s�A	A�
Ac�"�SUlURRS5 URbOUR UR
R
5(aUR
R5 SSS5 gg!,(df   g=f)zjstop the data-reading thread and interrupt the comsuming iteration

This is meant to be called on errors.
TN)r�r�r�r�r�r�r�r�rs r$r��_DataQueue.abortVsc��
��������D�����*�����:�:�$�$�&�&��J�J�&�&�(���+���s�:B�
B)r�r�r�r�r�r�r�r�)r�r�r�r�r�r�r�r�r�r�r�r�r�r&r$r�r��s&����,	O�)��<�)r&r�c�4�\rSrSrSrS	SjrSrSrSrSr	g)
r�idzDA thread-safe queue to passer parsed file information to the writersc�.�Xl[5Ulgr�)�_infor�r�)r��infos  r$r��_FileInfoQueue.__init__gs���
��(��r&c�d�URnURHnURU5 M g)z�iterate over the parsed information to file the queue

This is meant to be call from the thread parsing the stream information.
N)r�r�r�r�s   r$r��_FileInfoQueue.fillks&��

�G�G�����A�
�E�E�!�H�r&c�^�[U5HnURRS5 M  g)z�signal all the workers that we no longer have any file info coming

Called from the thread parsing the stream information (and/or the main
thread if different).
N)r�r�r�)r��
number_workerr�s   r$r�_FileInfoQueue.closets#���
�&�B��G�G�K�K���'r&c#�~# �URnUR5=nbUv� UR5=nbMgg7f)zZiterate over the available file info

This is meant to be called from the writer threads.
N)r�r6r�s   r$r��_FileInfoQueue.__iter__}s7���

�G�G���E�E�G�|�q�(��G��E�E�G�|�q�(�s�7=�=)r�r�N�r�zIterable[FileInfoT])
r�r�r�r�r�r�r�rr�r�r�r&r$r�r�ds��N����r&r�c�N�\rSrSrSrSS	SjjrS
SjrSSjrSrg)r�i�z�yield the chunk that constitute a file

This class exists as the counterpart of the threaded version and
would not be very useful on its own.
Nc�N�X@lX0l[R"XS9Ulg)Nr�)r�r�rr��_chunks)r�ri�data_lenr�r�r�s      r$r��_FileChunker.__init__�s ���� �
��)�)�"�=��r&c��g)z#Do nothing in non-threading contextNr�rs r$r��_FileChunker.fill�rlr&c#��# �URHQnUR=R[U5-
slURR[U5S9 Uv� MS g7f)Nr�)rr�r�r1r�r�)r�r�s  r$r��_FileChunker.__iter__�sJ����\�\�E��K�K�"�"�c�%�j�0�"��M�M�#�#��U��#�4��K�"�s�A#A%)rr�r�r��
ri�bundle2mod.unbundlepartrrVr��scmutil.progressr�r�r��Optional[Callable[[int], None]]r��r��FileChunksT)	r�r�r�r�r�r�r�r�r�r�r&r$r�r��sK���6:�
>�#�
>��
>�#�	
>�
�
>�3�
>�2�r&r�c�b^�\rSrSrSrSSU4SjjjrS	U4SjjrS
SjrSrU=r	$)r�i�z�yield the chunk that constitute a file

Make sure you  call the "fill" function in the main thread to read the
right data at the right time.
c�\>�[TU]XX45 Xl[5UlXPlgr�)rrr��_fpr�r��
_mark_used)r�rirr�r�r�rts      �r$r��_ThreadSafeFileChunker.__init__�s'���	����x�8����h���#�r&c�>�[TU]5H9nURR5nURRX45 M; URRS5 g!URRS5 f=f)z�fill the file chunker queue with data read from the stream

This is meant to be called from the thread parsing information (and
consuming the stream data).
N)rrr�rr5r�r�)r�r�r�rts   �r$r��_ThreadSafeFileChunker.fill�s^���	"���)�+����������������0�,�
�K�K�O�O�D�!��D�K�K�O�O�D�!�s�AA*�*Bc#��# �URR5=nbFUup#URbURU5 Uv� URR5=nbMEgg7f)zUIterate over all the file chunk

This is meant to be called from the writer threads.
N)r�r6r)r�r�r�r�s    r$r��_ThreadSafeFileChunker.__iter__�sW���
�{�{���(�(�t�5� �M�E����*�����'��K�	�{�{���(�(�t�5�s�A!A'�%A')rrr�r�rr�r)
r�r�r�r�r�r�r�r�r�rr�s@r$r�r��sV����6:�
$�#�$��$�#�	$�
�$�3�
$�$�"�	�	r&r�c#�*# �UbU"U5 Uv� g7f)zused for single chunk file,Nr�)r�r�r�s   r$�
_trivial_filer"�s������&��
�K�s�c	#�T# �[5nURS5 [U5GHyn	[R"US5n
[R
"U5n[R
"U5n[R"X5n
URR(a4URRSX�[R"U54-5 X*nURX�5unnU[R::awURU5nUR5nU=R[U5-
slUR![U5S9 [#UUU5nUU[%U54v� GMOU"UUUUUS9nUU[%U54v� UR'5 GM| g7f)zsdo the "stream-parsing" part of stream v2

The parsed information are yield result for consumption by the "writer"
rr�adding [%s] %s (%s)
r�)r�N)rr!r�r�readexactly�uvarintdecodestreamr;r�r�rm�prepare_streamed_file�DEFAULT_FILE_CHUNKr�r5r�r1r�r"�iterr�)r(ri�vfs_mapr�r�r�r�r��
known_dirsr�r��namelen�datalenr�r�r��mode�cr�r�s                    r$r�r��s`�����J��O�O�A��
�:�
�����r�1�%���*�*�2�.���*�*�2�.������,���7�7����G�G�M�M�(�C�t�~�~�g�7N�+O�O�
��l���.�.�t�@�
��d��d�-�-�-����� �A��W�W�Y�F�����Q��'�����C��F��+�"�1�i��8�F���t�F�|�,�,�!�����#��F���t�F�|�,�,��K�K�M�=�s�F&F(c�$�[R[R-n[R(aU[R
-nUH�up#nUc[R"X!5nO[R"X!US9nUHTn[R"XV5nU[U5:dM*[R"XVUS5nU[U5:aM*MV [R"U5 M� g![R"U5 f=f)zwrite files from parsed dataN)r.)
r'�O_WRONLY�O_CREATrrG�O_BINARYr*r�r1r)r��io_flagsr�r.rr-r��writtens        r$r�r�
s����{�{�R�Z�Z�'�H�����B�K�K��� ���D��<�����(�B�����d�3�B�	����(�(�2�-����E�
�*� �h�h�r���?�;�G���E�
�*��
�H�H�R�L�!��
�H�H�R�L�s�(C7�.(C7�C7�7Dc�L^�TR5 [R"5n[R"U5nTRR[
S5U-5 TRR[
S5U[
S5S9nURS5 Sn[T5nTRUR5;a[R"S5eSnTRS5 U4SjUR55n[U6 [!U5GHpn	[R"U5n
U
S:Xa9TRR"(aTRR%SU	-5 Xz-
n[!U
5H�n	[R&"US	5nXkn[R"U5n
[R"U5n[R&"X5nTRR"(a8S
nUX�[R("U54-nTRR%U5 X^-
nU"US5n[R*"XS9HnUR-U5 M S
S
S
5 M� UR/S	S9 GMs S
S
S
5 TR1SS9 S
S
S
5 UR35 [5TX'U5 S
S
S
5 g
!,(df   GMb=f!,(df   N^=f!,(df   NX=f!,(df   g
=f)z�Apply the contents from a version 3 streaming clone.

Data is read from an object that only needs to provide a ``read(size)``
method.
s%d entries to transfer
r�sentriesr�rrPc3�X># �UHoRTR5v� M! g7fr�r�r�s  �r$r��consumev3.<locals>.<genexpr>Ar�r�sentry with no files [%d]
rr$r�r�Nr�Tr�)r\rr~r&r;rTrr�r!rNr�rrrTrr�r�r�r�r%rmr�r�r�rfr�r�)r(rir��
entrycountr��bytes_transferredr�r�r�r�rlr�r�r,r-r�r`r�r�s`                  r$�	consumev3r;!sv���
�����
�
����-�-�b�1�
������q�4�5��D�E��7�7�'�'�
�h�K���:��(�
��
	��������$����8�8�v�}�}��&��(�(�K��
���
�
�
�h�
'�N�f�m�m�o�N�D�����z�*�A� $� 8� 8�� <�I� �A�~��7�7�,�,� �G�G�M�M�*G�1�*M�N�$�1�$�"�9�-��"�.�.�r�1�5��$�k��"&�":�":�2�">��"&�":�":�2�">��#�/�/��<���7�7�,�,�":�C��C�t�~�~�g�/F�#G�G�C� �G�G�M�M�#�.�)�4�)� ��t�_��)-�);�);�B�)N�� #�	�	�%� 0�*O�-�_�.�"�&�&�A�&�.�/+��8
�O�O�4�O�0�=(�@	�����D�%�;L�M�u
��`-�_��+���(�
'��3
��sU�C%L�7#L�D4K3�-K 
�; K3�L�2%L� 
K0�*	K3�3
L�=L�
L	�L�
L#c�f�SSKJn UVs/sHofUR;dMUPM nnU(a:[R"[S5SR
[U55-5e[R"5 [XX#5 SSS5 [URU5UlURURURUR5UR l[$R&"U5 [(R*"U5 gs snf!,(df   N�=f�NrrKr�r-)rPrLr>rrYrr?r@rrUr�r%rr^r;r_r`rarrbrrc)r(rirlr�rrL�rrHs        r$�
applybundlev2r?ds����*�F�l��t�~�~�.E�1�l�K�F���k�k�
�E�F��j�j���,�-�
.�
�	
�

�����$�I�0�
�6������D��"�8�8�����"�"�D�M�M��D�I�I���!�!�$�'�����%��%G�
��s�D�D�
D"�"
D0c��SSKJn UVs/sHoDUR;dMUPM nnU(a>[S5nUSR	[U55-n[R"U5e[X5 [URU5Ul
URURURUR5URl[ R""U5 [$R&"U5 gs snfr=)rPrLr>rr?r@rrYr;r%rr^r;r_r`rarrbrrc)r(rirrLr>rHr`s       r$�
applybundlev3rA~s����*�F�l��t�~�~�.E�1�l�K�F���G�H���u�z�z�&��-�.�.���k�k�#���
�d��5������D��"�8�8�����"�"�D�M�M��D�I�I���!�!�$�'�����%��!Gs
�D�Dc	��^^
�S/m
U
U4SjnUH�upVnXnXn	URU5n
U	RU5n[RRU5n[RR	U5(d[
R"U5 U	RU5 [
R"U
UT
SUSS9 TR5 M� T
S$![a U(deN-f=f)NTc�0>�STS'[S5Tlg)NFrscopying)r�topic)�hardlinkr�s��r$�	copy_used�_copy_files.<locals>.copy_used�s��������:���r&rF)rE�no_hardlink_cb�check_fs_hardlink)r?r'r��dirnamer�r�makedirs�
register_file�copyfile�FileNotFoundErrorr�)�src_vfs_map�dst_vfs_mapr�r�rFr\r�r��src_vfs�dst_vfs�src_path�dst_pathrJrEs   `         @r$�_copy_filesrU�s�����v�H�'�%�����.���.���<�<��%���<�<��%���'�'�/�/�(�+���w�w�~�~�g�&�&��M�M�'�"����d�#�
	��M�M���!�!��(�"'�
�	����/%�0�A�;���	!�	����	�s�*C�C3�2C3c��URVs1sHnU[R;dMUiM nnURVs1sHnU[R;dMUiM nnX4:XdeUR5 UR5 [R
"U5nUR
S5nSn[RRU5(aSn[USSSS9n[U5n[U5n	[U5n
[SU55U-nURR[!S5U[!S	5S
9nUV
VVs/sH5up�UR#5HnX�R$UR&4PM M7 nnn
n[)X�UU5nU(a>[R
"U5nUR
S5n[*R,"UU5 SSS5 WR/5 W(aSnOSnURR1UW-5 UR3S
5nUR4R7U5 SSS5 [2R8"URR:UR<5 SSS5 gs snfs snfs snnn
f!,(df   N�=f!,(df   Nn=f!,(df   g=f)zUcopy all content from one local repository to another

This is useful for local clones	bookmarksrrNTr�c3�Z# �UH!n[USR55v� M# g7f)rN)r1r�)r�rhs  r$r��local_copy.<locals>.<genexpr>�s"���A��A�c�!�A�$�*�*�,�/�/��s�)+slinkingsfiles)rDr�r�slinked %d files
scopied %d files
s
localclone)rr�WORKING_DIR_REQUIREMENTSr\r�bookmarksvfsr?r'r�r�r�rcrN�sumr;r�rr�r�r�rUrrMr�r�rrr��cleanup_undo_filesr<r*)�src_repo�	dest_repor>�src_store_requirements�dest_store_requirements�src_book_vfs�srcbookmarks�bm_countr�rO�dest_vfs_map�total_filesr�rYrhr�r�rE�dst_book_vfs�dstbookmarksr`�trs                      r$�
local_copyri�s����&�&��&�A��O�<�<�<�	
�&����'�'��'�A��O�<�<�<�	
�'���
"�<�<�<�	���	�
�]�]�_�%�1�1�(�;�L�'�,�,�\�:�L��H��w�w�~�~�l�+�+���#����"&�	�G��7�m�G�"�8�,�K�#�I�.�L��A��A�A�H�L�K��{�{�/�/��
�m�!��x�[�0��H�#*��")�J�G�����A��*�*�A�J�J�7�"�8�")�
��
#�;�e�X�N�H��(�5�5�i�@��+�0�0��>���
�
�l�L�9�W�X	�����&�C�&�C������#��+�,�
�
"�
"�=�
1�R��O�O�!�!�"�%�2�	�&�&�y�|�|�'8�'8�)�:K�:K�L�q
�	����
��P�A�_��f2�
1��i
�	�sg�J�J�J�J�<K�
CJ*�<J#�AJ*�$AK�7J;�=K�#J*�*
J8	�4K�;
K		�K�
K)r"�Iterable[bytes]r#rjr��
Set[bytes])r�rk)F)rr8r�)r�r8)NFF)rxr8ryr8)r�floatr�rVr�rV)r�z tuple[int, int, Iterator[bytes]]r�)r�)r�rFr�z"tuple[Set[bytes], Iterator[bytes]])rlrVrmrVr�r�)r�ztuple[int, int, Set[bytes]])r�zlist[bytes])r��Iterator[bytes | None])r�r8)r�r8r�rm)rlrVr�rVr�r�)r�rFr�rr�rVr�r)rirr�rVr�rr�r�r�zType[_FileChunker]r�rr�zIterator[FileInfoT]r)rlrVr�rVrrjr�r�)rrjr�r�)a�
__future__rr�rHr=r'r�r��typingrrrrrr	r
�i18nr�
interfacesr
rPrrr4rrrrrrrrrrr�revlogutilsr�RESOURCE_LOW�RESOURCE_MEDIUM�
RESOURCE_HIGHr�r�r%r#rIrnrur|r�r�r�r�r]r�r�r��_fileappendr�rKrLr�rrrNrarir�r�r��SimpleStoreEntryrp�	StoreFiler{r�r�r�rIr�r�r�rFrrV�	FileInfoTr�r�r�r�r�r"r�r�r;r?rArUrir�r&r$�<module>rzs8��#����	�
������"�
�
�
�
�����!����Q����1������,����[����9���
�)�
�*�
��
� �[�|H�V�&CH�L�#�L�;?�L����),��:=��"77�t�8 %�9��9�'�9�xIF�X.�8&�.-�-���
�	�
�	��	��<���D
�@I�F>%�B���(��'�'�(�V�����?�@/�>-�15�-��-�`��������vG�t�u�o���	��S�M���
�	�*)�*)�Zi)�i)�X � �F��:*�\�*�Z���.��
���	�$(4�15�.��.��	.�
�.�
�
.�%�.�/�.��.�b�(@N�F&��&�(+�&�;J�&�	�&�4&�,�DHMr&