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__/patch.cpython-313.pyc
�

6�h������SSKJr SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
Jr SSKJ
r
JrJr SSKJrJrJrJrJrJrJrJrJrJrJrJrJr SSKJ r J!r!J"r"J#r# \RH(aSSK%r%SSKJ&r&J'r' \RPr(\RR"S	5r*\RR"S
5r+\RR"S5r,\RZr-\R\r.\R^r/Sr0/S
Qr1\RdS5r3Sr4"SS5r5Sr6"SS5r7"SS5r8"SS\85r9"SS\95r:"SS5r;"SS\85r<\RR"S5r=\RR"S 5r>/S!Qr?"S"S#5r@"S$S%5rA"S&S'5rBS(rCSTS)jrD"S*S+5rE"S,S-5rFS.rGS/rHSTS0jrIS1rJS2rKS3rLS4rMS5rNS6rOSUS7jrPS8rQSUS9jrRS:rSSVS;jrTSWS<jrUSVS=jrVSXS>jrWSYS?jrX"S@SA\Y5rZ\R�r\\R�r[\R�r]SZSBjr^S[SCjr_SDr`SEraS\SFjrbSGrcSHrdSIreSJSKSLSM.rfSNrgSOrhSPriSQrjS]SRjrkSSrlg)^�)�annotationsN���_)�hex�sha1nodeconstants�short)
�copies�
diffhelper�diffutil�encoding�error�mail�mdiff�pathutil�pycompat�scmutil�similar�util�vfs)�dateutil�hashutil�procutil�
stringutil)�Any�Iteratorsdiff --git a/(.*) b/(.*)s(\t+|[^\t]+)s9(\t+| +|[a-zA-Z0-9_\x80-\xff]+|[^ \ta-zA-Z0-9_\x80-\xff])c�>^^�SmSmU4SjnU4SjnU4SjnUU4SjnU4Sjn"SS	5nS
n/nS/n	[US5(dU"U5nUH�n
URU
5 U
RS
5(a
U"X5s $U
RS5(a
U"X5s $T"X�5(a5SnU
RSS5SR	5U	;a
U"X5s $M�U
RS5(dM�U(dM�U"X5s $ U"U5$)z6return an iterator of individual patches from a streamc���U(aURS5(agURS5(agURSS5n[U5S:H=(a SUS	;$)
N)� �	T)r�-�+F�: r�rr)�
startswith�split�len)�line�inheader�ls   �1/usr/lib/python3/dist-packages/mercurial/patch.py�isheader�split.<locals>.isheaderJsU������
�6�6���?�?�-�.�.���J�J�u�a� ���1�v��{�/�t�1�Q�4�/�/�c�6�[SRU55$�Nr.)�stringio�join)�liness r+�chunk�split.<locals>.chunkTs��������(�(r.c3��># �SnUHVnUR5(dSnU(d$URS5(aT"U5v� /nSnURU5 MX U(aT"U5v� gg7f)NTF�# HG changeset patch)�stripr%�append)�stream�curr)r(r4s    �r+�hgsplit�split.<locals>.hgsplitWsk�������D��:�:�<�<� ������0G� H� H��C�j� ������J�J�t������*���s�A2A5c3�># �UHHnURS5(a[T"USS55Shv�N /nURU5 MJ U(a[T"USS55Shv�N ggN@N7f)N�From r)r%r&r9)r:r;r(r4s   �r+�	mboxsplit�split.<locals>.mboxsplitgst�����D����x�(�(� ��s�1�2�w��0�0�0����J�J�t�����U�3�q�r�7�^�,�,�,��1�
-�s!�3A;�A7�9A;�0A9�1A;�9A;c3�8># �SnUHnURU5 M T	"U5n[R"U5nUR5(dU"U5v� gSnUR	5H$nUR5nX�;aMU"U5v� M& g7f)Nc��[5n[R"USS9nURU5 UR	S5 U$)NF)�mangle_from_r)r1r�	Generator�flatten�seek)�m�fp�gs   r+�msgfp�'split.<locals>.mimesplit.<locals>.msgfpss4����B����r��6�A�
�I�I�a�L��G�G�A�J��Ir.)z
text/plainztext/x-diffztext/x-patch)r9r�parse�is_multipart�walk�get_content_type)
r:r;rKr(�crH�ok_types�part�ctr4s
         �r+�	mimesplit�split.<locals>.mimesplitrs�����	��D��J�J�t����#�J���J�J�q�M���~�~�����(�N�D�H�������*�*�,���%���D�k�!�	!�s�BBc3��># �SnUHLnU(dT"X25(aT"U5v� /nSnU(aT"X25(dSnURU5 MN U(aT"U5v� gg7f�NFT�r9)r:r;r)r(r4r,s    ��r+�headersplit�split.<locals>.headersplit�sh�������D���� 8� 8��C�j� �������� 8� 8� ���J�J�t������*���s�A(A+c3�"># �T"U5v� g7f�N�)r;r4s �r+�	remainder�split.<locals>.remainder�s�����C�j��s�c�*�\rSrSrSrSrSr\rSrg)�split.<locals>.fiter�c��Xlgr]�rI��selfrIs  r+�__init__�split.<locals>.fiter.__init__�s���Gr.c��U$r]r^�rgs r+�__iter__�split.<locals>.fiter.__iter__�s���Kr.c�T�URR5nU(d[eU$r])rI�readline�
StopIteration�rgr*s  r+�next�split.<locals>.fiter.next�s"����� � �"�A��#�#��Hr.reN)	�__name__�
__module__�__qualname__�__firstlineno__rhrlrr�__next__�__static_attributes__r^r.r+�fiterrb�s��	�	�	��r.rzFscontent-typerrr7r?T�:rr�--- )�hasattrr9r%r&�lower)
r:r<r@rUrZr_rzr)r;�mimeheadersr(r4r,s
           @@r+r&r&Gs���0�)�� 	-�"�2� �
�
��H�
�C�"�#�K��6�6�"�"��v������
�
�4���?�?�2�3�3��6�'�'�
�_�_�X�
&�
&��V�)�)�
�d�
%�
%��H��z�z�$��"�1�%�+�+�-��<� ��-�-�=��_�_�W�
%�
%�(�(��v�+�+��"�S�>�r.))sDatesdate)sBranchsbranch)sNode ID�nodeidc#�&# �[R"SS9up#[R"US5n[	XX45v� UR5 [R"U5 g!UR5 [R"U5 f=f7f)atextract patch from data read from fileobj.

patch can be a normal patch or contained in an email message.

return a dictionary. Standard keys are:
  - filename,
  - message,
  - user,
  - date,
  - branch,
  - node,
  - p1,
  - p2.
Any item can be missing from the dictionary. If filename is missing,
fileobj did not contain a patch. Caller must unlink filename when done.�	hg-patch-��prefix�wbN)r�mkstemp�os�fdopen�_extract�close�unlink)�ui�fileobj�fd�tmpname�tmpfps     r+�extractr��sh���$�"�"�,�7�K�B��I�I�b�$��E���r�G�3�3�
���
�
�	�	�'���	���
�
�	�	�'��s�.B�A&�'B�&(B�Bc	�:
�[R"S[R[R-5n0n[R
"U5nUS=(a [R"US5nUS=(a [R"US5US'U(d3US(d)SRSUR555S-n/nUSn	U	(a/[R"U	5=US'n	URS	U	-5 U(anURS
5(a,URS5n
U
S:�aXzS
-SR5n[R"SSU5nURSU-5 US(aURSUS-5 SnSnSn
UR5GH�n[R "UR#55nURSU-5 X�;aMC[$R&"[(UR+SS95nUR-U5nU(Ga6SnSnSnURSUR/S5-5 US
-
n[15nUSUR/S5R35GHnURS5(a@U(d9URS5 SnSnUR5S5 UR75 SnO�U(a�URS5(a USSUS'URSUS-5 O�URS5(a#UR9USSR55 OyURS5(aX[:HMunnS U-nURU5(dM#U[=U5SUU'URS!UUU4-5 MO OSnOUS":XaSnU(aGMSU(aGM]UR?U5 UR?S5 GM� URA5n
U(a>UR?U5 URCS5(dUR?S5 GM�GM�GM�U(aGM�U
(dGM�US#:XdGM�U
SU--
n
GM� U(aU
RU5(dS$X}4-n
X�S%'URE5 U(a/URGS5US&'U(aURGS5US''U(aX%S('U$))Ns}^(?:Index:[ \t]|diff[ \t]-|RCS file: |retrieving revision [0-9]+(\.[0-9]+)*$|---[ \t].*?^\+\+\+[ \t]|\*\*\*[ \t].*?^---[ \t])�Subject�Fromsuser�
c3�t# �UH.nSR[[RU55v� M0 g7f)r#N)r2�mapr
�
strtolocal��.0�hs  r+�	<genexpr>�_extract.<locals>.<genexpr>s,����AL�A��
�
�3�x�2�2�A�6�7�7��s�68zX-Mercurial-Noder�sNode ID: %s
s[PATCH�]rrs\n[ \t]+rsSubject: %s
s	From: %s
)�
text/plainstext/x-diffstext/x-patchr.sContent-Type: %s
T)�decodeFsfound patch at byte %d
r7spatch generated by hg export
s# User �s	# Parent �	�# s# %s s%s: %s
�---r�s%s
%ssmessagesp1sp2sfilename)$�re�compile�	MULTILINE�DOTALLrrM�
headdecoder2�items�debugr%�find�lstrip�subrOr�bytestrrP�typing�cast�bytes�get_payload�search�startr1�
splitlinesrG�truncater9�patchheadermapr'�write�getvalue�endswithr��pop)r�r�r�r��diffre�data�msg�subject�parents�nodeid�pend�
diffs_seenrR�messagerS�content_type�payloadrH�hgpatch�
hgpatchheader�
ignoretext�cfpr(�header�keyr�s                          r+r�r��sW���Z�Z�	%�	���r�y�y� ��F��D�
�*�*�W�
�C��)�n�@�����Y��!@�G���K�@�D�O�O�C��K�$@�D��M��4��=�
�J�J��AD�����
��
�	��G�
�#�
$�F�
�#'�?�?�6�#:�:��Y��&�
���!�F�*�+�����i�(�(��<�<��%�D��q�y�!��(�*�-�4�4�6���&�&��t�W�5��
���!�G�+�,��G�}�
�����g��.�/��J�?�H��G����
���'�'��(=�(=�(?�@��
���&��5�6��'��
�+�+�e�T�%5�%5�T�%5�%B�C���M�M�'�"����G�!�M��J��H�H�0�1�7�7�1�:�=�>��!�O�J��*�C���!�'�'�!�*�-�8�8�:���?�?�#:�;�;�G��H�H�>�?�"�G�$(�M��H�H�Q�K��L�L�N�"�G�"����z�2�2�(,�Q�R���W�
������g��!>�?�����6�6����t�A�B�x���'8�9�����/�/�+9�K�F�C�%-��%6�F�#���v�6�6�,0��V���,?��S�	� "������S�	�7J�)J� K�	,:�).�
��V�^�!%�J�$�}�Z�Z��I�I�d�O��I�I�e�$�7;�8�l�l�n�G�����G�$��'�'��.�.��K�K��&�/������L�M�,I��u�w��&�G�k�n�w�)�)�'�2�2��w�0�0�����	�K�K�M���k�k�!�n��U���!�+�+�a�.�D��K��#�[���Kr.c�B�\rSrSrSrSrSrSrSrSr	Sr
S	rS
rg)�	patchmetaida�Patched file metadata

'op' is the performed operation within ADD, DELETE, RENAME, MODIFY
or COPY.  'path' is patched file path. 'oldpath' is set to the
origin file when 'op' is either COPY or RENAME, None otherwise. If
file mode is changed, 'mode' is a tuple (islink, isexec) where
'islink' is True if the file is a symlink and 'isexec' is True if
the file is executable. Otherwise, 'mode' is None.
c�H�XlSUlSUlSUlSUlg)NsMODIFYF)�path�oldpath�mode�op�binary)rgr�s  r+rh�patchmeta.__init__os#���	������	������r.c�(�US-nUS-nX#4Ulg)Ni �@)r�)rgr��islink�isexecs    r+�setmode�patchmeta.setmodevs�����������$��	r.c��[UR5nURUlURUlURUlUR
UlU$r])r�r�r�r�r�r�)rg�others  r+�copy�patchmeta.copy{sA���$�)�)�$������
��Y�Y��
��7�7����{�{����r.c�v�US:XaURS:H$USUR=(d UR-:H$)N�	/dev/null�ADD�a/)r�r�r�)rg�afiles  r+�_ispatchinga�patchmeta._ispatchinga�s6���L� ��7�7�f�$�$������!:����;�;�;r.c�P�US:XaURS:H$USUR-:H$)Nr��DELETE�b/�r�r�)rg�bfiles  r+�_ispatchingb�patchmeta._ispatchingb�s-���L� ��7�7�i�'�'����	�	�)�)�)r.c�T�URU5=(a URU5$r])r�r�)rgr�r�s   r+�
ispatching�patchmeta.ispatching�s#��� � ��'�D�D�,=�,=�e�,D�Dr.c�@�SUR<SUR<S3$)Nz<patchmeta � �>r�rks r+�__repr__�patchmeta.__repr__�s��&*�g�g�t�y�y�9�9r.)r�r�r�r�r�N)
rtrurvrw�__doc__rhr�r�r�r�r�r�ryr^r.r+r�r�ds+����%�
�<�
*�
E�:r.r�c�L�Sn/nUGHnURS5nURS5(aT[RU5nU(a6U(aUR	U5 URS5n[
U5nM}MU(dM�URS5(aUR	U5 SnM�URS5(aSUlUSSUlM�URS	5(aUS
SUl	M�URS5(aSUlUS
SUlGM(URS
5(a
USSUl	GMKURS5(a
SUlGMkURS5(a(SUlUR[USSS55 GM�URS5(a!UR[USSS55 GM�URS5(dGM�SUlGM U(aUR	U5 U$)z9extract git-style metadata about patches from <patchname>N�
�
diff --git a/r$r|srename from �RENAME�s
rename to �
s
copy from �COPYscopy to �sdeleted filer�snew file mode r�i����s	new mode �GIT binary patchT)
�rstripr%�gitre�matchr9�groupr�r�r�r�r��intr�)�lr�gp�
gitpatchesr(rH�dsts      r+�readgitpatchr
�s���
�B��J����{�{�7�#���?�?�+�,�,����D�!�A����%�%�b�)��g�g�a�j���s�^��	�
�R����w�'�'��!�!�"�%��������/�/�!���!�"�#�Y��
�����/�/��r�s�)�������/�/����!�"�#�Y��
�����-�-��q�r�(�������1�1�!������!2�3�3�����
�
�3�t�B�C�y�!�,�-�����.�.��
�
�3�t�B�C�y�!�,�-����!4�5�5� ��	�A�B
����"���r.c�,�\rSrSrSrSrSrSrSrg)�
linereaderi�c��Xl/Ulgr])rI�bufrfs  r+rh�linereader.__init__�s������r.c�B�UbURRU5 ggr])rr9�rgr(s  r+�push�linereader.push�s�����H�H�O�O�D�!�r.c��UR(aURSnURS	U$URR5$�Nr)rrIrorqs  r+ro�linereader.readline�s9���8�8������A�������H��w�w���!�!r.c�.�[URS5$r0)�iterrorks r+rl�linereader.__iter__�s���D�M�M�3�'�'r.)rrIN)	rtrurvrwrhrrorlryr^r.r+rr�s���"�"�(r.rc�>�\rSrSrSrSrSrSrSrSr	Sr
S	rg
)�abstractbackendi�c��Xlgr]�r�)rgr�s  r+rh�abstractbackend.__init__�s���r.c��[e)zpReturn target file data and flags as a (data, (islink,
isexec)) tuple. Data is None if file is missing/deleted.
��NotImplementedError�rg�fnames  r+�getfile�abstractbackend.getfile�s
��"�!r.c��[e)z�Write data to target file fname and set its mode. mode is a
(islink, isexec) tuple. If data is None, the file content should
be left unchanged. If the file is modified after being copied,
copysource is set to the original file name.
r �rgr#r�r��
copysources     r+�setfile�abstractbackend.setfile�s
��"�!r.c��[e)zUnlink target file.r r"s  r+r��abstractbackend.unlink�s��!�!r.c��g)z�Write rejected lines for fname. total is the number of hunks
which failed to apply and total the total number of hunks for this
files.
Nr^)rgr#�failed�totalr3s     r+�writerej�abstractbackend.writerej�s�r.c��[er]r r"s  r+�exists�abstractbackend.exists����!�!r.c��[er]r rks r+r��abstractbackend.close�r5r.rN)rtrurvrwrhr$r)r�r0r3r�ryr^r.r+rr�s%���"�"�"��"�"r.rc�F^�\rSrSrU4SjrSrSrSrSrSr	Sr
U=r$)	�	fsbackendi�c�Z>�[TU]U5 [R"U5Ulgr])�superrh�vfsmodr�opener)rgr��basedir�	__class__s   �r+rh�fsbackend.__init__�s ���
������j�j��)��r.c�X�URRU5(aURRU5S4$SnURRU5RS-S:gnURR
U5SU44$![
a N,f=f![
a gf=f)N�TFFr�r�NN)r=r��readlink�lstat�st_mode�FileNotFoundError�read)rgr#r�s   r+r$�fsbackend.getfile�s����;�;���e�$�$��K�K�(�(��/��?�?���	��[�[�&�&�u�-�5�5��=��B�F�	��K�K�$�$�U�+�e�V�_�=�=��!�	��	��!�	��	�s$�+B�-B�
B�B�
B)�(B)c��UupVUcURRXU5 gU(aURRX!5 gURRX5 U(aURRUSS5 ggrX)r=�setflags�symlinkr�)rgr#r�r�r(r�r�s       r+r)�fsbackend.setfilesj������<��K�K� � ���7����K�K����,��K�K���e�*�����$�$�U�E�4�8�r.c�r�URRSS5nURRUSUS9 g)NsexperimentalsremoveemptydirsT)�
ignoremissing�rmdir)r��
configboolr=�
unlinkpath)rgr#rPs   r+r��fsbackend.unlinks2�����"�"�?�4F�G�������u�D���Fr.c���US-nURR[S5X#U4-5 URUS5nUR	U5 UR5 g)Ns.rejs7%d out of %d hunks FAILED -- saving rejects to file %s
�w)r��warnrr=�
writelinesr�)rgr#r.r/r3rIs      r+r0�fsbackend.writerejsX�����������
�I�J��e�$�
%�	
��[�[���
%��
�
�
�e��
���
r.c�8�URRU5$r])r=�lexistsr"s  r+r3�fsbackend.exists&s���{�{�"�"�5�)�)r.)r=)rtrurvrwrhr$r)r�r0r3ry�
__classcell__�r?s@r+r9r9�s'���*��
9�G��*�*r.r9c�L^�\rSrSrU4SjrSrU4SjrU4SjrSrSr	U=r
$)�workingbackendi*c�>�[TU]XR5 X lX0l[5Ul[5Ul/Ulgr])	r;rh�root�repo�
similarity�set�removed�changed�copied)rgr�rbrcr?s    �r+rh�workingbackend.__init__+s7���
����Y�Y�'��	�$���u����u�����r.c���URRRU5R(d.UR	U5(a[[
S5U-5egg�Ns$cannot patch %s: file is not tracked)rb�dirstate�	get_entry�any_trackedr3�PatchApplicationErrorrr"s  r+�_checkknown�workingbackend._checkknown3s[���y�y�!�!�+�+�E�2�>�>�4�;�;��D
�D
�(��9�:�U�B��
�D
�>r.c�>�URU5 [TU]	XX45 UbURR	XA45 UR
R
U5 gr])ror;r)rgr9rf�add)rgr#r�r�r(r?s     �r+r)�workingbackend.setfile;sL��������
����T�6��!��K�K���
�2�3�������r.c�>�URU5 [TU]	U5 URR	U5 UR
R	U5 gr])ror;r�rerrrf)rgr#r?s  �r+r��workingbackend.unlinkBsA��������
���u���������������r.c	���URRRUR5 URSn[UR5nUR
H2up4[R"URURXU5 M4 UR(acUR[UR55 URH/nXPRR;dMURU5 M1 U(a+[R"URX R5 [UR5sSSS5 $!,(df   g=fr])rbrk�changing_filesrdrfrgr�dirstatecopyr�re�forget�sorted�discard�marktouchedrc)rg�wctxrf�srcr	�fs      r+r��workingbackend.closeHs���
�Y�Y�
�
�
.�
.�t�y�y�
9��9�9�T�?�D��$�,�,�'�G� �K�K����$�$�T�W�W�d�i�i��C�H�(��|�|����F�4�<�<�0�1����A��	�	� 2� 2�2�
 ����*�
&���#�#�D�I�I�w���H��$�,�,�'�!:�
9�
9�s�CE�6AE�
E))rfrgrerbrc)rtrurvrwrhror)r�r�ryr\r]s@r+r_r_*s!����� � �(�(r.r_c�4�\rSrSrSSjrSSjrSrSrSrg)	�	filestorei\Nc�~�SUl0UlSUlXlURcSUlSUl0Ulg)Nri@)r=�files�created�maxsize�sizer�)rgr�s  r+rh�filestore.__init__]s;�������
�������<�<��&�D�L���	���	r.c���URS:d&[U5UR-UR::a0X#U4URU'U=R[U5-
slgURc/[
R"SS9n[R"U5UlSUR-nURRXb5 U=RS-
sl	XcU4URU'g)Nrr�r��%dr)r�r'r�r�r=r�mkdtempr<rr�r�r�)rgr#r�r�rgra�fns       r+r)�filestore.setfilegs����<�<�!���D�	�D�I�I� 5�$�,�,�F� $�F�3�D�I�I�e���I�I��T��"�I��{�{�"��'�'�|�<��$�j�j��.�������%�B��K�K���b�'��L�L�A��L�!#�6� 2�D�J�J�u�r.c���XR;aURU$UR(aXR;agURUup#nURRU5X44$)N)NNN)r�r=r�rH)rgr#r�r�rgs     r+r$�filestore.getfileus[���I�I���9�9�U�#�#��{�{�e�:�:�5�#��:�:�e�,���&��{�{����#�T�1�1r.c�|�UR(a+[R"URR5 ggr])r=�shutil�rmtree�baserks r+r��filestore.close}s$���;�;��M�M�$�+�+�*�*�+�r.)r�r�r�r�r=r�r])	rtrurvrwrhr)r$r�ryr^r.r+r�r�\s���3�2�,r.r�c�L^�\rSrSrU4SjrSrSrSrSrSr	Sr
S	rU=r$)
�repobackendi�c�>�[TU]U5 X lX0lX@l[5Ul[5Ul0Ulgr])	r;rhrb�ctx�storerdrfrerg)rgr�rbr�r�r?s     �r+rh�repobackend.__init__�s8���
������	����
��u����u�����r.c�P�XR;a[[S5U-5egrj)r�rnrr"s  r+ro�repobackend._checkknown�s,����� �'��9�:�U�B��
�!r.c��URUnUR5nUR	5SU;SU;44$![Ra gf=f)NrC�l�x)r�r�LookupError�flagsr�)rgr#�fctxr�s    r+r$�repobackend.getfile�sY��	��8�8�E�?�D��
�
����y�y�{�T�U�]�D�E�M�:�:�:��� � �	��	�s�;�A�Ac��U(aURU5 UcURUR5nURR	XX45 UR
R
U5 U(aX@RU'ggr])ror�r�r�r)rfrrrgr's     r+r)�repobackend.setfile�sh������Z�(��<��8�8�E�?�'�'�)�D��
�
���5��9���������!+�K�K���r.c�\�URU5 URRU5 gr])rorerrr"s  r+r��repobackend.unlink�s"�������������r.c��XR;$r])r�r"s  r+r3�repobackend.exists�s����� � r.c�4�URUR-$r])rfrerks r+r��repobackend.close�s���|�|�d�l�l�*�*r.)rfrgr�rerbr�)
rtrurvrwrhror$r)r�r3r�ryr\r]s@r+r�r��s+�����;�,� �!�+�+r.r�s*@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@s.(?:---|\*\*\*) (\d+)(?:,(\d+))? (?:---|\*\*\*))�strict�crlf�lf�autoc�B�\rSrSrSSjrSrSrSrSrSr	Sr
S	rg
)�	patchfilei�c��URUlXPlSUlX0lXl/UlSUlSUlURUl	URUlURS;Ul
URS:HUlURcURUR5upgO URUR5SSupgUGb(URSL=(d URUR5UlSUlU(a[ R""U5UlURcXpl	UR(a�URSR%S5(aSUlO*URSR%S5(aSUlUS	:waJ/nURH2n	U	R%S5(aU	SS
S-n	UR'U	5 M4 X�lO,UR(aSUlURcSUl	UR(aUUR
R)[+S5UR-5 UR
R)[+S
55 0UlSUlSUlSUl/UlSUlUR9S5 SUlg)NFT)r�r�r�r�r$rr�r�r����)FFs!unable to find '%s' for patching
sB(use '--prefix' to apply patch relative to the current directory)
)r�r#�eolmode�eol�backendr�r3r3�missingr�r�r(r��create�remover$r�
splitnewlinesr�r9rVr�hash�dirty�offset�skew�rej�fileprinted�	printfile�hunks)
rgr�rr�r�r�r�r��nlinesr*s
          r+rh�patchfile.__init__�s3���W�W��
������������
��������G�G��	��*�*����e�e�;�;����e�e�y�(����?�?�"� ������4�J�D�$����t���7���;�J�D����/�/�T�1�O�W�^�^�D�J�J�5O�D�K� �D�L��"�0�0��6��
��y�y� � �	��z�z��:�:�a�=�)�)�'�2�2�&�D�H��Z�Z��]�+�+�E�2�2�$�D�H��i�'��F�!�Z�Z���:�:�g�.�.� !�#�2����A��
�
�a�(�(�"(�J���{�{�$����y�y� �*��	��<�<��G�G�L�L��@�A�D�J�J�N�O��G�G�L�L��,��
���	���
������	���� ������u����
r.c��URS:Xa
URnOURS:XaSnOSnURS:waPU(aIUS:waC/nUH9nU(aURS5(aUSSU-nURU5 M; UnURRUSR
U5X0R5 g)Nr�r�r�r�r����r.)r�r�r�r9r�r)r2r()rgr#r3r�r��rawlinesr*s       r+rW�patchfile.writelines�s����<�<�7�"��(�(�C�
�\�\�W�
$��C��C��<�<�9�$������H�������E�*�*��#�2����A�����"���E������U�C�H�H�U�O�T�?�?�Kr.c�&�UR(agU(dURR(aSUl[S5UR-nU(aURRU5 gURR
U5 g)NTspatching file %s
)r�r��verboserr#rV�note)rgrV�ss   r+r��patchfile.printfilesX�������4�7�7�?�?�#�D��
�#�$�t�z�z�1����G�G�L�L��O��G�G�L�L��Or.c�^�URRU/5n[U5S:�aURU4SjS9 U$)Nrc� >�[UT-
5$r])�abs)�x�linenums �r+�<lambda>�%patchfile.findlines.<locals>.<lambda>s���C��G��$4r.)r�)r��getr'�sort)rgr*r��cands  ` r+�	findlines�patchfile.findliness8���
�y�y�}�}�Q��#���t�9�q�=��I�I�4�I�5��r.c���UR(dg[RRUR5nSX4-/nURHTnUR
HAnUR
U5 USSS:wdMUR
S[R-5 MC MV URRUR[UR5URU5 g)Ns--- %s
+++ %s
r�r�)
r�r�r��basenamer#�hunkr9r�MISSING_NEWLINE_MARKERr�r0r'r�)rgr�r3r�r*s     r+�	write_rej�patchfile.write_rejs���
�x�x���w�w����
�
�+��$��|�3�4�����A��V�V�����Q���R�S�6�U�?��L�L���)J�)J�!J�K���
	
�����d�j�j�#�d�h�h�-����U�Kr.c
�^�UR5(dk[[S5URUR[UR5UR[UR5UR4-5eU=RS-
sl
UR(aURRU5 gUR(a�UR(a�UR (a2UR"R%[S5UR&-5 O1UR"R%[S5UR&-5 URRU5 g[)U[*5(a�UR,(a&UR.R1UR&5 gUR3UR45nX R4SS&U=R6[U5-
slSUlgUnUR:S;d!UR:S	:Xa!UR<(aUR?5nURASS
5upEpgXPR6-
nUnURBS:Xa�[DRF"X@R4U5(a�UR,(a&UR.R1UR&5 gX`R4XU[U5-&U=R6[U5[U5-
-
slSUlg0Ul$[KUR45H0up�URHRMU
/5RU	5 M2 [OUR"RQSS5S-5GH�nS
GH�nURAX�5upEpgXPR6-URB-n[SU[UR455nU(aURUUSSSU5n
OU/n
U
GHnU(a([DRF"X@R4U5(dM3X`R4X"[U5-&U=R6[U5[U5-
-
slX(-
Ul!SUlX(-
U-
nU(aJ[S5nURWS5 UR"R%X�RUS-X�4-5 O8[S5nUR"RYX�RUS-U4-5 Us s s $ GM� GM� URWS5 UR"R%[S5URU4-5 URRU5 g)Nsbad hunk #%d %s (%d %d %d %d)rr�s-cannot create %s: destination already exists
sfile %s already exists
Tr)r�r�r�F�patchsfuzzrBs9Hunk #%d succeeded at %d with fuzz %d (offset %d lines).
s,Hunk #%d succeeded at %d (offset %d lines).
sHunk #%d FAILED at %d
)-�complete�PatchParseErrorr�number�descr'�a�lena�b�lenbr�r�r�r9r3r�r(r�rVr#�
isinstance�binhunkr�r�r��newr3r�r�r�r��
getnormalized�fuzzitr�r�testhunkr��	enumerate�
setdefault�range�	configint�minr�r�r�)rgr�r*�horig�old�oldstartr��newstart�
orig_startr�r��fuzzlen�toponlyr�r�r�s                r+�apply�patchfile.apply*s:���z�z�|�|�!��2�3��8�8�Q�V�V�S����X�q�v�v�s�1�3�3�x����H�I��
�
	
�
�
�a��
��<�<��H�H�O�O�A����;�;�4�;�;����������G�H��j�j�!��
�����Q�:�;�d�j�j�H�I��H�H�O�O�A����a��!�!��{�{����#�#�D�J�J�/��	�E�E�$�*�*�%�� !�
�
�1�
����s�1�v�%��!��
�����L�L�,�,��|�|�w�&����
���!�A�()�x�x��5�'9�$��s��K�K����
��9�9��>�j�1�1�#�z�z�8�L�L��{�{����#�#�D�J�J�/�
�>A�
�
�8��S��&9�:����s�3�x�#�c�(�2�2��!��
����	��d�j�j�)�D�A��I�I� � ��B�'�.�.�q�1�*��T�W�W�.�.�x��A�A�E�F�G�(��/0�x�x��/I�,��s�#�k�k�1�D�I�I�=���x��T�Z�Z��9����>�>�#�a�&���*�h�?�D�%�:�D��A��*�"5�"5�c�:�:�q�"I�"I�7:�
�
�1�3�s�8�|�4����s�3�x�#�c�(�':�:��$%�N��	�%)��
�!"��'�!9��"�"#�!8�#�C�
!�N�N�4�0� �G�G�L�L� #�x�x��Q���&H� H��#$�!8�#�C�!�G�G�L�L����!�a�%��/H�)H�I�&��/�)�G�H	
���t�������Q�1�2�a�h�h�
�5K�K�L��������r.c���UR(a1URURURUR5 UR5 [
UR5$r])r�rWr#r3r�r�r'r�rks r+r��patchfile.close�s=���:�:��O�O�D�J�J��
�
�D�I�I�>������4�8�8�}�r.)r�r(r�r�r�r�r3r�r#r�r�r3r�r�r�r�r�r�r�N)r�)rtrurvrwrhrWr�r�r�r�r�ryr^r.r+r�r��s*��:�xL�$	�	�L� i�Vr.r�c�,�\rSrSrSr\R"S5r\R"S5r\R"S5r	\R"S5r
\R"S5r\R"S5rS	r
S
rSrSrS
rSrSrSrSrSrSrg)r�i�zpatch headersdiff --git a/(.*) b/(.*)$sdiff -r .* (.*)$s(?:index|deleted file) s(?:new file|deleted file) s'(?:index|deleted|copy|rename|new mode) s(?:new file|copy to|rename to)c��Xl/Ulgr]�r�r�)rgr�s  r+rh�header.__init__�s������
r.c�:�[SUR55$)Nc3�B# �UHoRS5v� M g7f)�index N�r%r�s  r+r�� header.binary.<locals>.<genexpr>�s���@�K�q�<�<�	�*�*�K�s���anyr�rks r+r��
header.binary�s���@�D�K�K�@�@�@r.c��URGH5nURS5(aUR[S55  gURRU5(aBURU5 UR
5(aUR[S55  gURS5(avUR[S5[UR5[URVs/sH#n[URUR5PM% sn54-5  gURU5 GM8 gs snf)Nrs-this modifies a binary file (all or nothing)
sthis is a binary file
r�s%d hunks, %d lines changed
)
r�r%r�r�	pretty_rerr�r'r��sum�max�addedre)rgrIr�s   r+�pretty�
header.pretty�s������A��|�|�I�&�&�����L�M�N���~�~�#�#�A�&�&�������;�;�=�=��H�H�Q�9�:�;���|�|�F�#�#�����5�6��D�J�J���d�j�j�I�j��S����!�)�)�4�j�I�J������H�H�Q�K�%��Js�7*Ec�X�URSRUR55 gr0)r�r2r�rfs  r+r��header.write�s��
������$�+�+�&�'r.c�B^�[U4SjTR55$)Nc3�Z># �UH nTRRU5v� M" g7fr])�allhunks_rer�r�r�rgs  �r+r��"header.allhunks.<locals>.<genexpr>�s%����B�k��4�#�#�)�)�!�,�,�k���(+r	rks`r+�allhunks�header.allhunks�s����B�d�k�k�B�B�Br.c��URRURS5nU(aUR5up#X#:XaU/$X#/$URRURS5R5$r)�
diffgit_rerr��groups�diff_re)rgr�fromfile�tofiles    r+r��header.files�sl�����%�%�d�k�k�!�n�5���$�|�|�~��H��!� �z�!��%�%��<�<�%�%�d�k�k�!�n�5�<�<�>�>r.c�(�UR5S$)Nr�)r�rks r+�filename�header.filename�s���z�z�|�B��r.c��SSR[R"[RUR	555-$)Nz<header %s>r�)r2r�rapply�fsdecoder�rks r+r��header.__repr__�s2����H�H�X�_�_�X�%6�%6��
�
��E�F�
�	
r.c�B^�[U4SjTR55$)Nc3�Z># �UH nTRRU5v� M" g7fr])�
newfile_rerrs  �r+r��#header.isnewfile.<locals>.<genexpr>�s#����A�[��4�?�?�(�(��+�+�[�rr	rks`r+�	isnewfile�header.isnewfile�s����A�T�[�[�A�A�Ar.c�^�[TR5S:HnTR5=(a UnU=(d [U4SjTR55$)Nr$c3�Z># �UH nTRRU5v� M" g7fr])�
special_rerrs  �r+r��!header.special.<locals>.<genexpr>�s&����#
�.9��D�O�O�!�!�!�$�$�k�r)r'r�r/r
)rg�	nocontent�emptynewfiles`  r+�special�header.special�sN�������$��)�	��~�~�'�5�I���
�s�#
�.2�k�k�#
� 
�	
r.rN)rtrurvrwr�r�r�rr rr
r3r-rhr�rr�rr�r%r�r/r7ryr^r.r+r�r��s�������8�9�J��j�j�,�-�G��*�*�7�8�K��
�
�8�9�I����F�G�J����=�>�J��A��*(�C�?� �
�
B�
r.r�c�p�\rSrSrSrS
SjrSrSrSrSr	S	r
\
rS
r\
RS5rSrg)�
recordhunki�zCpatch hunk

XXX shouldn't we merge this with the other hunk class?
Nc	��^�SU4Sjjn	XlU	"US5uo�lX*-UlX:-UlU	"US5uo�lX@lX`lURUR5uUlUl	g)NFc�`>�Tb'[U5T-
nUS:�aU(aX US4$X ST4$SU4$r)r')r3�reverse�delta�
maxcontexts   �r+�trimcontext�(recordhunk.__init__.<locals>.trimcontext�sI����%��E�
�Z�/���1�9��$�E�F�m�3�3�$�K�Z�&8�8�8��e�8�Or.T)F)
r��before�fromline�toline�after�procr��countchangesrre)rgr�rCrDrFrBr�rEr?r@�trimedbefore�_trimedafters        `   r+rh�recordhunk.__init__�sl���	���$/���$=�!��k� �/��
��+���#.�u�e�#<� ��j��	��	�#'�#4�#4�T�Y�Y�#?� ��
�D�Lr.c�X�[U[5(dgURUR:H=(au URUR:H=(aU URUR:H=(a5 UR
R
5UR
R
5:H$)NF)r�r:r�rFrCr�r�)rg�vs  r+�__eq__�recordhunk.__eq__sz���!�Z�(�(���V�V�t�y�y�
 �
:����4�9�9�$�
:����!�*�*�,�
:����"�"�$������(8�8�		
r.c��[[UR5[URR	55UR
UR45$r])r��tupler�r�r�rCrFrks r+�__hash__�recordhunk.__hash__sC����d�i�i� ��d�k�k�'�'�)�*��
�
��	�	�	
�
�	
r.c���[UVs/sHo"RS5(dMUPM sn5n[UVs/sHo"RS5(dMUPM sn5nX44$s snfs snf)zhunk -> (n+,n-)r"r!)r'r%)rgr�r�rr�rems     r+rG�recordhunk.countchanges%sU���d�9�d��l�l�4�&8�1�d�9�:���d�9�d��l�l�4�&8�1�d�9�:���x���:��9s�A*�A*�A/�A/c	��SSSS.nURVs/sHnSXSSUSS4-PM nn[URURURUR
URUUR5$s snf)	z�return another recordhunk which is the reverse of the hunk

If this hunk is diff(A, B), the returned hunk is diff(B, A). To do
that, swap fromline/toline and +/- signs while keep other things
unchanged.
r!r"�\)r"r!rWs%s%srrN)r�r:r�rDrCrFrBrE)rgrHr*r�s    r+�reversehunk�recordhunk.reversehunk+s����t�E�2��6:�i�i�@�i���1�q��V�9�a���e�,�,�i��@���K�K��K�K��M�M��I�I��K�K���J�J�
�	
��As�A=c	�"�[UR5[UR5-nUR(a&URS[R:XaUS-nX R
-nX R-nURSURUURUUR=(a SUR-4-5 URSRURUR-UR-55 g)Nr�rs@@ -%d,%d +%d,%d @@%s
rr.)
r'rBrErr�rerr�rCrDrFr2r�)rgrIr>�fromlen�tolens     r+r��recordhunk.write>s����D�K�K� �3�t�z�z�?�2���:�:�$�*�*�R�.�J�,M�,M�M��Q�J�E��,�,�&���
�
�"��
���&��
�
�������	�	�0�t�d�i�i�/��
�		
�	������$�+�+��	�	�1�D�J�J�>�?�@r.c�6�URR5$r])r�r%rks r+r%�recordhunk.filenameRs���{�{�#�#�%�%r.c�@�SUR5UR4-$)Ns<hunk %r@%d>)r%rCrks r+r��recordhunk.__repr__Us���$�-�-�/�4�=�=�!A�A�Ar.)	rrErBrCr�r�rFrerDr])rtrurvrwr�rhrMrQrGrXr�rr%r
�	strmethodr�ryr^r.r+r:r:�sT����@�<	
�
��
�&A�$�F�&����B��Br.r:c��[S5[S5[S5[S5S.[S5[S5[S5[S	5S.[S
5[S5[S5[S
5S.S.$)Nsapply change %d/%d to '%s'?sdiscard change %d/%d to '%s'?skeep change %d/%d to '%s'?srecord change %d/%d to '%s'?)sapplysdiscardskeep�recordsapply this change to '%s'?sdiscard this change to '%s'?skeep this change to '%s'?srecord this change to '%s'?s0[Ynesfdaq?]$$ &Yes, apply this change$$ &No, skip this change$$ &Edit this change manually$$ &Skip remaining changes to this file$$ Apply remaining changes to this &file$$ &Done, skip remaining changes and files$$ Apply &all changes to all remaining files$$ &Quit, applying no changes$$ &? (display help)s8[Ynesfdaq?]$$ &Yes, discard this change$$ &No, skip this change$$ &Edit this change manually$$ &Skip remaining changes to this file$$ Discard remaining changes to this &file$$ &Done, skip remaining changes and files$$ Discard &all changes to all remaining files$$ &Quit, discarding no changes$$ &? (display help)s-[Ynesfdaq?]$$ &Yes, keep this change$$ &No, skip this change$$ &Edit this change manually$$ &Skip remaining changes to this file$$ Keep remaining changes to this &file$$ &Done, skip remaining changes and files$$ Keep &all changes to all remaining files$$ &Quit, keeping all changes$$ &? (display help)s4[Ynesfdaq?]$$ &Yes, record this change$$ &No, skip this change$$ &Edit this change manually$$ &Skip remaining changes to this file$$ Record remaining changes to this &file$$ &Done, skip remaining changes and files$$ Record &all changes to all remaining files$$ &Quit, recording no changes$$ &? (display help))�multiple�single�helprr^r.r+�getmessagesrhZs����6�7��:�;��4�5��8�9�	
��5�6��9�:��3�4��7�8�	
��	(���	(���	(���	(��K1
�?�?r.c�^^^^�[5mTcSmUUU4Sjn[5n0nSupxS[SU55p�UGH�nU	[UR5-
n	SnSnSRUR5n
X�;aMBURU
5 UcURT5 UR5n[S	5[S
5RSU55-n[U4SjU55(aS
unnnOU"XxUS5unpxnU(dM�U/XkR5'UR5(a'XkR5==UR-
ss'GM+[UR5GH\unnUcUcURT5 U
S:XaTSTUR5-nO7U	[UR5-
U-nTSTUU
UR54-nU"XxUU5unpxnU(aVU(a+[R"U5nU=R U-
slUUR5R#U5 M�Ub]UHTnURHAnU(aU=R U-
slUUR5R#U5 MC MV GM@UUR$UR&-
-
nGM_ GM� [UR)5Vs/sH-o�SR+5(d[U5S:�dM+UPM/ sn/504$s snf)z:Interactively filter patch chunks into applied-only chunksNrdc	�>�SnUbXX4$UbXX4$TSTnTRSX%4-5nTRS5 US:XaITRU5SH/upxTRSU[R"U54-5 M1 M~US	:XaSn	GO�US:XaS
n	GO�US:XGaiUc-TR[S55 TRS5 M�URR5(a.TR[S
55 TRS5 GMS[S5-n
[R"SSS9up�Sn
[R"[R"US55nURRU5 URU5 URSRU
R5Vs/sHnSU-S-PM
 sn55 UR!5 TR#5nTR%SUU4-STR'50SS9n	U	S	:wa8TR)[S5U	-5 [R*"U5 A
GM^[-US5n[/5n
UHBn[R0"U5nUR3S5(aM1U
RU5 MD UR!5 U
R5S	5 [7U
5n[R*"U5 A
S
n	OMUS:XaS
=p�OCUS:XaS=p�O9US:XaS
=p�O/US :XaS=p�O%US!:Xa[8R:"[S"55eW	XU4$s snf![R*"U5 A
f=f)#z�prompt query, and process base inputs

- y/n for the rest of file
- y/n for the rest
- ? (help)
- q (quit)

Return True/False and possibly updated skipfile and skipall.
NTrgs%s
(enter ? for help) %sr�r�rs%s - %s
rFr$s cannot edit patch for whole files!cannot edit patch for binary filer�s�
To remove '-' lines, make them ' ' lines (context).
To remove '+' lines, delete them.
Lines starting with # will be removed from the patch.

If the patch applies cleanly, the edited hunk will immediately be
added to the record list. If it does not apply cleanly, a rejects
file will be generated: you can use that when you try again. If
all lines of the hunk are removed, then the edit is aborted and
the hunk is left unchanged.
s
hg-editor-s.diff)r��suffixr�r.r�s%s "%s"sHGUSERsfilterpatch)�environ�
blockedtags editor exited with exit code %d
�rb�#����r�s	user quit)�promptchoicer��extractchoicesr
r~rr�r�rr�r�nativeeolwriterr�r�r2r�r��	geteditor�system�usernamerVr��openr1�
fromnativeeolr%rG�
parsepatchr�
CanceledError)�skipfile�skipall�queryr4�
newpatches�resps�rrQ�t�ret�phelp�patchfd�patchfn�	ncpatchfpr�i�editor�patchfpr(�messages�	operationr�s                   ���r+�prompt�filterpatch.<locals>.prompt�sT����
����g�9�9����w�:�:���W�%�i�0�E���� <��~� M�N�A��H�H�U�O��A�v��-�-�e�4�Q�7�D�A��H�H�\�Q����q�0A�,B�B�C�8���a�����a�����a���=��H�H�Q�B�C�D��H�H�U�O���<�<�&�&�(�(��H�H�Q�C�D�E��H�H�U�O����
�"���&.�%5�%5�(��&�"��!�	�!"��,�,�R�Y�Y�w��-E�F�A��L�L�&�&�q�)��K�K��N��G�G����8=�8H�8H�8J�K�8J�1�U�Q�Y��.�8J�K���
�G�G�I��\�\�^�F��)�)�$���'8�8�!*�B�K�K�M� :�#1�$��C�
�a�x�����"F� G�#� M�N� ��I�I�g�&�!�#�7�D�1�G� (�
�I� '��#�1�1�$�7��#���t�4�4�%�O�O�D�1�!(��M�M�O��N�N�1�%�!+�I�!6�J��I�I�g�&�!����a��!&�&��h��a��!%�%��h��a�� %�%��g��a�� $�$��g��a���)�)�!�L�/�:�:���:�5�5��QL��2�I�I�g�&�!�s.�A?M+�M&�!A4M+�0AM+�9AM+�&M+�+NrCrc3�L# �UHn[UR5v� M g7fr])r'r�r�s  r+r��filterpatch.<locals>.<genexpr>s���6�g���A�G�G���g�s�"$rr.sexamine changes to %s?s and c3�,# �UH
nSU-v� M g7f)s'%s'Nr^�r�rs  r+r�r�s���>
�!&�A�G�a�K��s�c3�F># �UHnTRU5v� M g7fr])�exact)r�rrs  �r+r�r� s����-�u�!�u�{�{�1�~�~�u�s�!)TNNrfre)rhrdrr'r�r2r�rrrr�r�allr%rr�r�rDr9rer�valuesr7)r��headersrr�r��seen�appliedr~r�posr/r��	fixoffset�hdrr�r�r��npr�r4�idxr��newpatch�newhunkr�s` ``                    @r+�filterpatchr��s�����}�H����	�h6�T�5�D��G�"��H��C�6�g�6�6��
���s�1�7�7�|������	��h�h�q�x�x� ���;������
��?�
�H�H�R�L����	���)�*�Q�x�[�-=�-=�>
�!&�>
�.
�
���-�u�-�-�-�-�N�A�w��'-�h��d�'K�$�A�x�"���!"���
�
����:�:�<�<��J�J�L�!�Q�W�W�,�!��!�!�'�'�*�H�A�u���G�O����R� ���z��y�)�)�4�u�~�~�7G�G���C����L�(�1�,���{�+�I�6����N�N�$�:���
06��3��0�,�A�x�*��� �I�I�e�,�E��L�L�I�-�L�����(�)�0�0��7��'� *�H�#+�>�>��$�#�N�N�i�7�N��� 0� 0� 2�3�:�:�7�C�$2�!+��U�]�]�U�[�[�8�8�	�7+�1�j	����(�I�(�1�a�D�L�L�N�N�c�!�f�q�j�Q�(�I��	
�	����Is�>*L<�,L<c�D�\rSrSrSrSrSrSrSrSr	Sr
S	rS
rg)r�iOc���X lXlU/Ul/Ul/UlS=UlUlS=UlUlUb+U(aURU5 gURU5 ggr])r�r�r�r�r��startar��startbr��read_context_hunk�read_unified_hunk)rgr��numr�contexts     r+rh�
hunk.__init__Psh�����	��F��	�������"&�&���d�i�"&�&���d�i�
�>���&�&�r�*��&�&�r�*�	r.c��Sn[URURSS5nURUlURUlURUlU"UR5UlU"UR5UlUR
UlURUlURUlURUlU$)z1Return a copy with line endings normalized to LF.c�z�/nUH2nURS5(aUSSS-nURU5 M4 U$)Nr�r�r�)r�r9)r3r�r(s   r+�	normalize�%hunk.getnormalized.<locals>.normalizeasC���F����=�=��)�)����9�u�,�D��
�
�d�#���Mr.N)	r�r�r�r�r�r�r�r�r�)rgr��nhs   r+r��hunk.getnormalized^s���	��$�)�)�T�[�[�$��
5���K�K��	��)�)����)�)������� ������� ����K�K��	��K�K��	��)�)����)�)����	r.c�X�[RUR5nU(d![[	S5UR
-5eUR
5uUlUlUl	Ul
URcSUlO[UR5UlURcSUl
O[UR5Ul
[UR5Ul[UR5Ul	[R"XRURURURUR 5 ['URS5S:XaoURS	URS	UR S	U=RS-slU=RS-sl
['URS5S:XaMoUR)U5 g!["R$a(n[[	S5UR
U4-5eSnAff=f)N�bad hunk #%drsbad hunk #%d: %sr�r)�unidescrr�r�rr�rr�r�r�r�rr�addlinesr�r�r�r�
ParseErrorr'�_fixnewline)rgrrH�es    r+r��hunk.read_unified_hunkvs����M�M�$�)�)�$���!�!�O�"4�t�{�{�"B�C�C�9:����6���T�Y���T�Y��9�9���D�I��D�I�I��D�I��9�9���D�I��D�I�I��D�I��$�+�+�&����$�+�+�&���	M�����I�I�t�y�y�$�)�)�T�V�V�T�V�V�
��$�)�)�B�-� �A�%��	�	�"�
����r�
����r�
��I�I��N�I��I�I��N�I��$�)�)�B�-� �A�%�	
���������	M�!�!�$7�"8�D�K�K��;K�"K�L�L��	M�s�AG-�-H)�#H$�$H)c��UR5Ul[RUR5nU(d![	[S5UR-5eUR5uUln[UR5UlUcURn[U5UR-
Ul
UR(aU=RS-
sl
[UR5H�nUR5nURS5(aURU5  O�USSnURS5(dURS5(aSU-nO?URS5(aS	U-nO#[	[S
5URU4-5eURRU5 UR RU5 M� UR5nURS5(a>URSSSnX`RS'X`R S'UR5n[RU5nU(d![	[S5UR-5eUR5uUln[UR"5UlUcUR"n[U5UR"-
UlUR"(aU=R$S-
slSn	[UR$5GH�nUR5nURS5(a3UR&SSSnX`R&S'X`R U	S-
'M]U(dURU5  GO2USSnURS
5(dURS5(aSU-nOkURS5(aS	U-nOO[)UR&5S:XaURU5  O�[	[S
5URU4-5eUR&RU5 U	[)UR 5:�aSn
OUR U	n
U	S-
n	X�:XaGMnU
RS5(aMQUR R+U	S-
U5 GM� UR(d\UR HLnURS5(dURS	5(dM1URRU5 MN UR&(d_UR HOnURS5(dURS	5(dM1UR&RUSS5 MQ SURURUR"UR$4-UlURUR S'UR-U5 g)Nr�rr�r$s- s! r!s  rsbad hunk #%d old text line %d�\ r�s+ r"rr.s@@ -%d,%d +%d,%d @@
)ror��contextdescrr�rr�rr�rr�r�r%rr�r9r�r�r�r�r'�insertr�)rgrrH�aendr�r*r��u�bend�hunkir�s           r+r��hunk.read_context_hunk�s����K�K�M��	����d�i�i�(���!�!�O�"4�t�{�{�"B�C�C��H�H�J����T��$�+�+�&����<��;�;�D���I����+��	��;�;��I�I��N�I��t�y�y�!�A����
�A��|�|�F�#�#�����
���!�"��A��|�|�E�"�"�a�l�l�5�&9�&9��1�H�����e�$�$��1�H��%��6�7�4�;�;��:J�J���
�F�F�M�M�!���I�I���Q��!"�$
�K�K�M���<�<�������r�
�3�B��A��F�F�2�J��I�I�b�M����
�A����a� ���!�!�O�"4�t�{�{�"B�C�C��H�H�J����T��$�+�+�&����<��;�;�D���I����+��	��;�;��I�I��N�I����t�y�y�!�A����
�A��|�|�F�#�#��F�F�2�J�s��O�����r�
�'(�	�	�%�!�)�$�������
���!�"��A��|�|�E�"�"�a�l�l�5�&9�&9��1�H�����e�$�$��1�H���T�V�V���!�����
��%��6�7�4�;�;��:J�J���
�F�F�M�M�!����C��	�	�N�*��A��	�	�%�(�A���
���6���\�\�$�'�'���I�I�$�$�U�Q�Y��2��Q"�T�v�v��Y�Y���<�<��%�%����d�);�);��F�F�M�M�!�$���v�v��Y�Y���<�<��%�%����d�);�);��F�F�M�M�!�A�B�%�(��-��K�K��I�I��K�K��I�I�	0
�
��	��y�y��	�	�!������r.c���UR5nURS5(a7[R"URUR
UR5 gURU5 g)Nr�)ror%r�
fixnewliner�r�r�r)rgrr*s   r+r��hunk._fixnewlinesE���K�K�M���<�<�����!�!�$�)�)�T�V�V�T�V�V�<��G�G�A�Jr.c��[UR5UR:H=(a" [UR5UR:H$r])r'r�r�r�r�rks r+r��
hunk.complete	s/���4�6�6�{�d�i�i�'�D�C����K�4�9�9�,D�Dr.c��[U[U55nU(a�SnSn[UR5n[US-
5H0nURUS-R	S5(aUS-
nM0 O U(dD[US-
5H2nURXv-
S-
R	S5(aUS-
nM2 O [X65n[X55nX[U5U-
X%[U5U-
U4$XS4$)Nrrr)r�r'r�r�r%)	rgr�r��fuzzr��top�bot�hlenr�s	         r+�_fuzzit�hunk._fuzzits����4��S��"����C��C��t�y�y�>�D��4�!�8�_���9�9�Q��U�#�.�.�t�4�4��1�H�C��%���t�a�x��A��y�y���a��0�;�;�D�A�A��q����	)��d�.�C��d�.�C��S��X��^�,�c��C��3��.G��L�L���{�r.c�
�URURURX5up4nURU-nURU-nUR
(aUS:�aUS-nUR(aUS:�aUS-nX6XG4$)Nrr)r�r�r�r�r�r�r�)rgr�r�r�r�r�r�r�s        r+r��hunk.fuzzit'ss�����T�V�V�T�V�V�T�C�
��#��;�;��$���;�;��$���9�9��A����M�H��9�9��A����M�H��c�+�+r.)	r�r�r�r�r�r�r�r�r�N)
rtrurvrwrhr�r�r�r�r�r�r�ryr^r.r+r�r�Os-��+��0�>k�Z�E��6	,r.r�c�0�\rSrSrSrSrSrSrSrSr	g)	r�i3zA binary patch file.c�^�SUlSUlS/UlX lUR	U5 g)NFsGIT binary patch
)�textr>r��_fname�_read)rgrr#s   r+rh�binhunk.__init__6s*����	���
�*�+��	����
�
�2�r.c��URSL$r])r�rks r+r��binhunk.complete=s���y�y��$�$r.c��UR(a&[URSRU55/$UR/$r0)r>�
applybindeltar�r2)rgr3s  r+r��binhunk.new@s1���:�:�!�$�)�)�S�X�X�e�_�=�>�>��	�	�{�r.c�.�SnU"XR5nU(d![[S5UR-5eUR	S5(a[USSR
55nO<UR	S5(a$[USSR
55nSUlOM�/nU"XR5n[U5S:�a�US	SnUS
::a!US:�a[U5[S5-
S-nO[U5[S5-
S
-nUR[R"USS5SU5 U"XR5n[U5S:�aM�[ R""SR%U55n[U5U:wa-[[S5UR[U5U4-5eX�lg![a<n[[S5UR[R"U54-5eSnAff=f)Nc�f�UR5nURU5 URS5$)Nr�)ror9r)rr�r*s   r+�getline�binhunk._read.<locals>.getlineFs'�����
�A��K�K��N��8�8�G�$�$r.Ts"could not extract "%s" binary datasliteral r�sdelta rsrr�Z�A�a�s&could not decode "%s" binary patch: %sr.s%"%s" length is %d bytes, should be %d)r�r�rr�r%rrr>r'�ordr9r�	b85decode�
ValueErrorr�forcebytestr�zlib�
decompressr2r�)	rgrr�r(r��decr*r�r�s	         r+r��
binhunk._readEs���	%�
��2�y�y�)�D��%��;�<�t�{�{�J������{�+�+��4���8�?�?�,�-������y�)�)��4���8�?�?�,�-��!��
������r�9�9�%���$�i�!�m��Q�q�	�A��D�y�Q�$�Y���F�S��Y�&��*����F�S��Y�&��+��
��
�
�4�>�>�$�q�r�(�3�B�Q�7�8��2�y�y�)�D��$�i�!�m����s�x�x��}�-���t�9���!��:�;��;�;��D�	�4�0�1��
��	���
�%��?�@��{�{�J�$;�$;�A�$>�?�@����
�s�+G�
H�7H�H)r�r>r�r�N)
rtrurvrwr�rhr�r�r�ryr^r.r+r�r�3s����%��
)r.r�c��USSRS5nURS5nUS:aURS5nUS:aU$USU$)Nrqr�r rr)rr�)�strr�r�s   r+�
parsefilenamer�qsN���A�B����w��A�	���u�
�A��1�u�
�F�F�4�L���q�5��H��R�a�5�Lr.c��/nUH5n[US5(aUR5nURU5 M7 U$)a�reverse the signs in the hunks given as argument

This function operates on hunks coming out of patch.filterpatch, that is
a list of the form: [header1, hunk1, hunk2, header2...]. Example usage:

>>> rawpatch = b"""diff --git a/folder1/g b/folder1/g
... --- a/folder1/g
... +++ b/folder1/g
... @@ -1,7 +1,7 @@
... +firstline
...  c
...  1
...  2
... + 3
... -4
...  5
...  d
... +lastline"""
>>> hunks = parsepatch([rawpatch])
>>> hunkscomingfromfilterpatch = []
>>> for h in hunks:
...     hunkscomingfromfilterpatch.append(h)
...     hunkscomingfromfilterpatch.extend(h.hunks)

>>> reversedhunks = reversehunks(hunkscomingfromfilterpatch)
>>> from . import util
>>> fp = util.stringio()
>>> for c in reversedhunks:
...      c.write(fp)
>>> fp.seek(0) or None
>>> reversedpatch = fp.read()
>>> print(pycompat.sysstr(reversedpatch))
diff --git a/folder1/g b/folder1/g
--- a/folder1/g
+++ b/folder1/g
@@ -1,4 +1,3 @@
-firstline
 c
 1
 2
@@ -2,6 +1,6 @@
 c
 1
 2
- 3
+4
 5
 d
@@ -6,3 +5,2 @@
 5
 d
-lastline

rX)r}rXr9)r��newhunksrQs   r+�reversehunksr�|s?��p�H�
���1�m�$�$��
�
��A��������Or.c�`^�"U4SjS5nU"5n[5nURSRU55 URS5 Sn[	U5H upgUR
UU"X75 UnM" AUR5$![a [SXV4-5ef=f)a�patch -> [] of headers -> [] of hunks

If maxcontext is not None, trim context lines if necessary.

>>> rawpatch = b'''diff --git a/folder1/g b/folder1/g
... --- a/folder1/g
... +++ b/folder1/g
... @@ -1,8 +1,10 @@
...  1
...  2
... -3
...  4
...  5
...  6
... +6.1
... +6.2
...  7
...  8
... +9'''
>>> out = util.stringio()
>>> headers = parsepatch([rawpatch], maxcontext=1)
>>> for header in headers:
...     header.write(out)
...     for hunk in header.hunks:
...         hunk.write(out)
>>> print(pycompat.sysstr(out.getvalue()))
diff --git a/folder1/g b/folder1/g
--- a/folder1/g
+++ b/folder1/g
@@ -2,3 +2,2 @@
 2
-3
 4
@@ -6,2 +5,4 @@
 6
+6.1
+6.2
 7
@@ -8,1 +9,2 @@
 8
+9
c�>�\rSrSrSrSrSrU4SjrSrSr	Sr
S	r\\	\\S
.\	\\\
S.\\	\S.\\S
.S\
0S.rSr
g)�parsepatch.<locals>.parseri�zpatch parsing state machinec�t�SUlSUlSUlSUl/Ul/Ul/Ul/Ulg)Nrr.)rCrDrFr�r�rBr�r�rks r+rh�#parsepatch.<locals>.parser.__init__�s:���D�M��D�K��D�I��D�K��D�L��D�K��D�I��D�Lr.c�~�UR/5 Uup#pEn[U5Ul[U5UlX`lgr])�
addcontextrrCrDrF)rg�limits�	fromstart�fromend�tostart�toendrFs       r+�addrange�#parsepatch.<locals>.parser.addrange�s5���O�O�B��7=�4�I����	�N�D�M��g�,�D�K��Ir.c
�
>�UR(a�[URURURUR
URURUT5nURRRU5 U=R[UR5UR--
slU=R[UR5UR--
sl/Ul/UlXlgr])
r�r:r�rCrDrFrBr�r9r'rerr�)rgr�r�r?s   �r+r��%parsepatch.<locals>.parser.addcontext�s�����y�y���K�K��M�M��K�K��I�I��K�K��I�I���	�����!�!�(�(��+��
�
��T�[�[�!1�A�I�I�!=�=�
����s�4�;�;�/�!�'�'�9�9�� �����	�"�Lr.c��UR(aURUl/UlUR(aUR/5 Xlgr])r�rBr�r�)rgr�s  r+�addhunk�"parsepatch.<locals>.parser.addhunks3���|�|�"�l�l���!����y�y�����#��Ir.c�~�UR/5 [U5nURRU5 X lgr])r�r�r�r9)rgr�r�s   r+�newfile�"parsepatch.<locals>.parser.newfiles.���O�O�B���s��A��L�L����"��Kr.c��gr]r^rs  r+�addother�#parsepatch.<locals>.parser.addothers��r.c�<�UR/5 UR$r])r�r�rks r+�finished�#parsepatch.<locals>.parser.finished s���O�O�B���<�<�r.)�context�file�hunk�range)rrr�other)rrr)rrr)rrrrr)rBr�rCr�r�r�rFrDN)rtrurvrwr�rhr�r�rrr
r
�transitionsry)r?s�r+�parserr��sx���)�	�	�	#�&	�	�	�	 �'� � �"�	�!� �"�"�	�'� �"��
$.��@���*�'
�r.rr.rrsunhandled transition: %s -> %s)	r1r�r2rG�	scanpatchr�KeyErrorr�r
)�originalchunksr?r�prI�state�newstater�s `      r+r|r|�s����XP
�P
�d	��A�	��B��H�H�S�X�X�n�
%�&��G�G�A�J��E�#�B�-���	�
�M�M�%� ��*�1�3�
��(�	��:�:�<���
�	�!�1�U�4E�E��
�	�s�$B�B-c��[U5nSnUS:XaSX R5-4$UnUS:�apURSU5nUS:Xa[[	S5XQU4-5eUS-
nXCS-
:a%XUS-S:XaUS-
nXCS-
:a
XUS-S:XaMUS-nUS:�aMpUSUR5X USR5-4$)ajturn a path from a patch into a path suitable for the repository

prefix, if not empty, is expected to be normalized with a / at the end.

Returns (stripped components, path in repository).

>>> pathtransform(b'a/b/c', 0, b'')
('', 'a/b/c')
>>> pathtransform(b'   a/b/c   ', 0, b'')
('', '   a/b/c')
>>> pathtransform(b'   a/b/c   ', 2, b'')
('a/b/', 'c')
>>> pathtransform(b'a/b/c', 0, b'd/e/')
('', 'd/e/a/b/c')
>>> pathtransform(b'   a//b/c   ', 2, b'd/e/')
('a//b/', 'd/e/c')
>>> pathtransform(b'a/b/c', 3, b'')
Traceback (most recent call last):
PatchApplicationError: unable to strip away 1 of 3 dirs from a/b/c
rr.�/r�s*unable to strip away %d of %d dirs from %srN)r'rr�rnrr�)r�r8r��pathlenr��counts      r+�
pathtransformr Ls���*�$�i�G�	�A���z��F�[�[�]�*�*�*��E�
�!�)��I�I�d�A�����7�'��?�@���&�'��
�	
�Q����A�+�o�$�1�q�5�/�T�"9�
��F�A��A�+�o�$�1�q�5�/�T�"9�
��
���!�)����8�?�?��f�A�B�x���'8�8�8�8r.c��US:HnUS:HnU=(a% URS:H=(a URS:HnU=(a% URS:H=(a URS:Hn	[	XU5up�U(+=(a URU5n[	X$U5up�X�:XaUnOU(+=(a URU5nU(+=(a U(+=(a U(+nUSUR
S5S-nUSUR
S5S-nU(a@UU:Xa:URU5(a$URS:XaURS:XaSnSnX�:H=(a URU5nSnU(d$U(aU(a
U(aUnOUnO	U(aUnU(d2U(d
U(aUnO!UnOU(dUnO[[S55e[U5nU(a	SUlU$U	(aS	UlU$)
Nr�rrrTFs&undefined source and destination filesr�r�)r�r�r�r�r r3�rfindr%r�rr�r�)r��
afile_orig�
bfile_origr�r8r��nulla�nullbr�r��abaser��gooda�bbaser��goodbr��abasedir�bbasedir�isbackupr#rs                      r+�
makepatchmetar.us����,�&�E��,�&�E�
�
:�t�{�{�a�'�
:�D�I�I��N�F�
�
:�t�{�{�a�'�
:�D�I�I��N�F� ��F�;�L�E��I�/�'�.�.��/�E� ��F�;�L�E��~����	�3�g�n�n�U�3���i�4��I�4�f�*�G��,�u�{�{�4�(�1�,�-�H��,�u�{�{�4�(�1�,�-�H���� ����U�#�#��K�K�1���I�I��N�����
�~�9�%�"2�"2�5�"9�H��E���U������
��E����������E�!�!�$M�"N�O�O�	�5�	�B�
�����I�
����
�Ir.c#��^	^
# �[R"S5n[U5m
U
4Sjn[T
RS5GHnURS5(dURS5(aaSnU"X45nT
R	5nURS5(aT
R	5nXVU/-
nOT
R
U5 SU4v� M�URS	5(aS
m	SU"UU	4Sj54v� M�URS
5(aSm	SU"UU	4Sj54v� M�URU5nU(aSUR54v� GMSU4v� GM g7f)z�like patch.iterhunks, but yield different events

- ('file',    [header_lines + fromfile + tofile])
- ('context', [context_lines])
- ('hunk',    [hunk_lines])
- ('range',   (-start,len, +start,len, proc))
s'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)c�>�U/n[TRS5H5nU"U5(aURU5 M#TRU5  U$ U$)zscan lr while predicate holdsr.)rror9r)�firstrr3r(rs    �r+�	scanwhile�scanpatch.<locals>.scanwhile�sN����������c�*�D���w�w����T�"�����
����
+��r.r.r�sdiff -r c�R�URSS5nU(+=(d USS;$)Nrr)r��diff)r&)r(r�s  r+�	notheader�scanpatch.<locals>.notheader�s)���J�J�t�Q�'���u�=��!��,=� =�=r.r�rr)rrWrc�&>�URT5$r]r�r*�css �r+r��scanpatch.<locals>.<lambda>�s������R�8Hr.)r!r")r!r"rWrc�&>�URT5$r]rr9s �r+r�r;�s���Q�\�\�"�5Er.rrN)	r�r�rrror%rrr)rI�lines_rer2r(r6r�r!r"rHr:rs         @@r+rr�s/�����z�z�E�F�H�	�B��B�	��R�[�[�#�&���?�?�+�,�,�����0L�0L�
>��t�/�F��{�{�}�H��"�"�6�*�*�������V�,�,������!��6�/�!�
�_�_�T�
"�
"��B��i��.H�I�I�I�
�_�_�\�
*�
*�$�B��9�T�+E�F�F�F����t�$�A������
�*�*���n�$�5'�s�E E$c�.�SnURR5nURn[U5nUR
U5 [U5nURU5 U$![a& [URR	55nNif=f)ao
Git patches can emit:
- rename a to b
- change b
- copy a to c
- change c

We cannot apply this sequence as-is, the renamed 'a' could not be
found for it would have been renamed already. And we cannot copy
from 'b' instead because 'b' would have been changed already. So
we scan the git patch for copy and rename commands so we can
perform the copies ahead of time.
r)	rI�tell�OSErrorr1rHrrr
rG)r�	firstliner�rI�gitlrrs      r+�scangitpatchrC�s}���C�$��e�e�j�j�l��
�U�U��
�r�N�E�	�J�J�y���e�$�J��G�G�C�L����
�$�
�b�e�e�j�j�l�
#��$�s�&A$�$-B�Bc#�# �SnSnSnSnS=pVSnSnSn	[U5n
[U
RS5GH�nX8:XGaU	(dURS5(d1U	SLaURS5(dURS5(a�SnU(a)US	R	X5(aUR5nURS5(a[
X�R5n
O*U	cURS5(aS
n	[X�S-X�5n
US-
nU(a*SnSXX�=(a UR5=(d S44v� SU
4v� GO�URS
5(GaS[RURS55nU(dGMcUcQ[X�5nSUVs/sH$o�RS;dMUR5PM& sn4v� UR5 SUR!S5-nSUR!S5-nU(a}US	R	X5(ddUR5nSSUR-SUR-SUR544v� U(aUS	R	X5(dMdU(d[#[%S5USS-5eS
nGO URS5(aUU
R5nURS5(dU
R'U5 GM�S
nSn	[)U5n[)U5nO�URS5(a�U
R5nURS5(dU
R'U5 GMCU
R5nU
R'U5 URS5(dU
R'U5 GM�S
nS
n	[)U5n[)U5nU(dGM�SnS
nUnSnGM� U(aLUR5nSSUR-SUR-SUR544v� U(aMKggs snf7f)a,Read a patch and yield the following events:
- ("file", afile, bfile, firsthunk): select a new target file.
- ("hunk", hunk): a new hunk is ready to be applied, follows a
"file" event.
- ("git", gitchanges): current diff is in git format, gitchanges
maps filenames to gitpatch records. Unique event.
r.NrFr�@s***************rr�Trrr�r��git)r�r�r�r�r$s'failed to synchronize metadata for "%s"r��+++s***)rrror%r�r�r�r�r�r�rrrrCr�r=rr�rrr�)rIr�r�r�hunknum�emitfilerr�BFILEr�rr�rr�rHrJ�l2�l3s                  r+�	iterhunksrMs����
�E��E��E��G���H��J�
�E��G�	�B��B�
�"�+�+�s�
#���>��Q�\�\�$�/�/��u�$����6H�)I�)I��|�|�/�0�0��B��j��n�7�7��E�E��^�^�%���|�|�/�0�0��B���(���?�q�|�|�4F�'G�'G�"�G���a�K��5���q�L�G�� ����a�1A����	�1I�T�J�J�J��1�*��
�\�\�*�
+�
+����A�H�H�W�-�.�A����!�)�"�0�
��&0��&0��D�D�<P�4P�H�A�F�F�H�j�����"�"�$��A�G�G�A�J�&�E��A�G�G�A�J�&�E��Z��^�%>�%>�u�%L�%L��^�^�%����B�G�G�O��B�G�G�O���G�G�I�	 ����Z��^�%>�%>�u�%L�%L��%��@�A�E�!�"�I�M����G�
�\�\�&�
!�
!�����B��=�=��(�(��������G��G�!�!�$�E�!�"�%�E�
�\�\�&�
!�
!�����B��=�=��(�(�����������B��G�G�B�K��=�=�!3�4�4��������G��G�!�!�$�E�!�"�%�E��7��G��H��E��G�Y$�\�
�^�^�
�������������$����	�J�J�J��*��g�s-�F)Q
�+Q�Q�CQ
�E
Q
�'AQ
�Q
c�6�SnSnU"U5nXSnU"U5nXSnSnU[U5:Gai[XUS-5nUS-
nUS-(GaSnSnUS-(a[XUS-5nUS-
nUS-(aU[XUS-5S--nUS-
nUS	-(aU[XUS-5S
--nUS-
nUS-(aU[XUS-5S--nUS-
nUS
-(a[XUS-5nUS-
nUS-(aU[XUS-5S--nUS-
nUS
-(aU[XUS-5S
--nUS-
nUS:XaSnXx-n	X1Xy-
nO)US:waXV-n	X0XY-
nXV-
nO[[S55eU[U5:aGMiU$)zWApply a binary delta hunk
The algorithm used is the algorithm from git's patch-delta.c
c�|�Sn[R"U5HnUS-
n[U5S-(aMUs $ U$)Nrr�)rr�r�)�binchunkr�rQs   r+�	deltahead� applybindelta.<locals>.deltaheadls>��
���!�!�(�+�A�
��F�A���F�T�M�M���,��r.r.NrrrPr$r�rq��� r�isunexpected delta opcode 0)r'r�rnr)
rQr�rR�outr�r��cmdr�r��
offset_ends
          r+r�r�gs��
��C��(��A���|�H��(��A���|�H�	�A�
�c�(�m�
��(�q�1�u�%�&��	�Q�����:�:��F��D��T�z��X�!�a�%�0�1���Q����T�z��#�h�1�q�5�1�2�a�7�7���Q����T�z��#�h�1�q�5�1�2�b�8�8���Q����T�z��#�h�1�q�5�1�2�b�8�8���Q����T�z��8��A��.�/���Q����T�z���H��Q��/�0�A�5�5���Q����T�z���H��Q��/�0�B�6�6���Q����q�y�����J���*�*�C�
�A�X���J��A�)�)�C�
�H�A�'��*F�(G�H�H�I�c�(�m�
�J�Jr.c�*�[UU[UUUUUS9$)a6Reads a patch from fp and tries to apply it.

Returns 0 for a clean patch, -1 if any rejects were found and 1 if
there was any fuzz.

If 'eolmode' is 'strict', the patch content and patched file are
read in binary mode. Otherwise, line endings are ignored when
patching then normalized according to 'eolmode'.
�r8r�r�)�
_applydiffr�)r�rIr�r�r8r�r�s       r+�	applydiffr]�s)���
�
���
����	�	r.c��U(a;[R"URUR5U5nUS:waUS-
nU$)Nr.r)r�	canonpathra�getcwd)rbr�s  r+�_canonprefixra�s8��
��#�#�D�I�I�t�{�{�}�f�E���S�=��d�N�F��Mr.c	�^^�[URT5mUU4SjnSn	Sn
Sn[U5GH�up�US:Xa&U(dMURU
5nUS:�aSn
M0M2US:XGa�U(aX�R	5-
n	SnU
unnnnU(a@U"UR
5UlUR(aU"UR5UlO[X?UUTT5nURS:XaURUR5 U(GdAURS:XaURUR
5 GMSunnURS	;aEURUR5SS
unnUc![[S5UR-5eUR(aURnURS:XaS
nU(dU(ayURS;aAURUR
5(a![[S5UR
-5eURUR
UUUR5 GM%U"UUX4US9nGM2US:XaJU
HAnU"UR5nURU5unnUcM.URUUU5 MC GM�[(R*"[S5U-5e U(aX�R	5-
n	U	(agU
$![ a;nUR#[$R&"U5S-5 SnU	S-
n	SnAGM	SnAff=f)Nc�*>�[UTS-
T5S$)Nr)r )rr�r8s ��r+�pstrip�_applydiff.<locals>.pstrip�s����Q���	�6�2�1�5�5r.rrrrr�r�rC)r�r�r$ssource file '%s' does not existr�r.)r�r�r�s,cannot create %s: destination already exists)r�r�rF�unsupported parser state: %sr�)rarbrMr�r�r�r�r.r�r�r$rnrr�r3r)�
PatchErrorrVrr�r�Abort)r�rI�patcherr�r�r8r�r�rd�rejects�err�current_filerr�r�r�r��
first_hunkrr�r��instr�s     ``                r+r\r\�s�����'�,�,��
/�F�6��G�
�C��L�"�2��
���G�����$�$�V�,�C��Q�w����
�g�
���-�-�/�/��#��+1�(�E�5�*�b�� ����/����:�:�!'��
�
�!3�B�J��"��E�:�u�f����u�u�	�!����r�z�z�*���5�5�I�%��N�N�2�7�7�+��'�
��d��5�5�0�0�!&���r�z�z�!:�2�A�!>�J�D�$��|�3��@�A�B�J�J�N����7�7��7�7�D��u�u��� #���4��u�u� <�<�������B�B�4��!2��!�g�g�	&����O�O�B�G�G�T�4����D��
�&�r�2�w�w�O���f�_����b�j�j�)��$�_�_�T�2�
��d��<�
��M�M�$��d�3���+�+�a� ?�@�5�H�I�I�S'�V��%�%�'�'�����J��3�
����
�/�/��5��=�>�#���1�����	
�s�	K:�:
L?�/L:�:L?c��Sn/nURn	U	(a(URS[R"U	5-5 SUSR	U5U[R"U54-n
URSU
-5 [R"U
S5nUGH&nUR5nURUS-5 URS5(a+[R"U5n
SnURU
5 MiURS	5S
:�a5SnW(dURW
S-5 SnURUS-5 M�URS5S
:�aURUS-5 M�URS
5S
:�dM�W(dURW
S-5 SnURUS-5 GM) U(a[R "XU5 UR#5nU(a+[%['S5[R("U5-5eU$!U(a[R "XU5 ff=f)zpuse <patcher> to apply <patchname> to the working directory.
returns whether patch was applied with fuzz factor.Fs-d %ss%s %s -p%d < %srsUsing external patch tool: %s
srbr�spatching file s	with fuzzrTssaving rejects to filesFAILEDspatch command failed: %s)rar9r�
shellquoter2r��popenrr�r%r�parsepatchoutputrrr�rVrr|r�rnr�explainexit)r�rbri�	patchnamer8r�rcr��args�cwdrXrIr(�pf�printed_file�codes                r+�_externalpatchrz	s����D�
�D�
�)�)�C�
����H�x�2�2�3�7�7�8�
���	�	�$��
����I�&�	 ��C��H�H�
/�#�
5�6�	����U�	#�B�9��D��;�;�=�D��G�G�D�5�L�!����0�1�1��*�*�4�0��$���	�	�"�
����<�(�A�-���#��G�G�B��J�'�#'�L�����u��%����4�5��:�����u��%����9�%��*�#��G�G�B��J�'�#'�L�����u��%�'�*�����Z�8�
�8�8�:�D��#�
�)�*�X�-A�-A�$�-G�G�
�	
��K�������Z�8��s�C3H'�6H'�'!Ic
��Uc
[5nUcURSS5nUR5[;a"[R
"[
S5U-5eUR5n[5n[US5n[XXX4US9n	X�:waUR5 URUR55 UR5 U	S:a[[
S55eU	S:�$![a UnN~f=f!X�:waUR5 URUR55 UR5 f=f)Nr�seols!unsupported line endings type: %srnr[rspatch failed to apply)rd�configr~�eolmodesrrhrr�rz�	TypeErrorr]r��updatern)
r�r��patchobjr8r�r�r�r�rIr�s
          r+�patchbackendr�P	s��
�}�������)�)�H�f�-���}�}��h�&��k�k�!�@�A�G�K�L�L��m�m�o�G��K�E��
�(�D�
!�����G�%��
���>��H�H�J�
���W�]�]�_�%�
���
�
�Q�w�#�A�&>�$?�@�@���7�N����
�����>��H�H�J�
���W�]�]�_�%�
���
�s�8C4�D�4D�D�AEc	�6�[XU5n[XX#XEU5$)zsuse builtin patch to apply <patchobj> to the working directory.
returns whether patch was applied with fuzz factor.)r_r�)	r�rbr�r8r�r�r�rcr�s	         r+�
internalpatchr�n	s!���R�z�2�G���X�f�W�M�Mr.c		�6�[XX#5n	[X	XEXgU5$r])r�r�)
r�rbr�r�r�r8r�r�r�r�s
          r+�	patchrepor�~	s!���"�C�/�G���X�f�W�M�Mr.c
��URSS5nUc
[5nU(a[XX�X5U5$[XX#XEXg5$)a�Apply <patchname> to the working directory.

'eolmode' specifies how end of lines should be handled. It can be:
- 'strict': inputs are read in binary mode, EOLs are preserved
- 'crlf': EOLs are ignored when patching and reset to CRLF
- 'lf': EOLs are ignored when patching and reset to LF
- None: get it from user settings, default to 'strict'
'eolmode' is ignored when using an external patcher program.

Returns whether patch was applied with fuzz factor.
suir�)r|rdrzr�)	r�rbrtr8r�r�r�rcris	         r+�patchr��	sQ��*�i�i��x�(�G��}�������g�%�
�
�	
��
�)�F�7��r.c
��[XR5n[X5n[US5n[	5n[U5H�up�US:Xa�U	up�p�U
(aV[
U
RUS-
U5SU
lU
R(a"[
U
RUS-
U5SU
lO
[XZX�X45n
URU
R5 U
RS:XaURU
R5 M�M�US;dM�[R"[S5U-5e UsSSS5 $!,(df   g=f)Nrnrrr�)rrFrf)r9rararzrdrMr r�r�r.rrr�rrhr)r�rb�	patchpathr8r�r�rIrfrr�r�r�rmrs              r+�changedfilesr��	s����I�I�&�G�
�$�
'�F�	
�i��	�"��%��&�r�]�M�E����/5�,��j��+�B�G�G�U�Q�Y��G��J�B�G��z�z�%2��J�J���	�6�&��&��
��'���5��B����B�G�G�$��5�5�I�%��K�K��
�
�+�&��/�/��k�k�!�$C�"D�u�"L�M�M�#+�$�)
�	�	�s�CD>�%D>�>
Ec��\rSrSrSrg)�GitDiffRequiredi�	r^N)rtrurvrwryr^r.r+r�r��	s��r.r�c
#�# �U(d!U(dURR5nXnXn[UUUUUUUUUU	S9
Huup�nnU
bUcS5eU
"UU5nSRSU55nU(a,U(d[	U5S:�aSRU5S-v� U(dMqUv� Mw g7f)a=yields diff of changes to files between two nodes, or node and
working directory.

if node1 is None, use first dirstate parent instead.
if node2 is None, compare node1 with working directory.

losedatafn(**kwarg) is a callable run when opts.upgrade=True and
every time some change cannot be represented with the current
patch format. Return False to upgrade to git patch format, True to
accept the loss or raise an exception to abort the diff. It is
called with the name of current file being diffed as 'fn'. If set
to None, patches will always be upgraded to git format when
necessary.

prefix is a filename prefix that is prepended to all filenames on
display (used for subrepos).

relroot, if not empty, must be normalized with a trailing /. Any match
patterns that fall outside it will be ignored.

copy, if not empty, should contain mappings {dst@y: src@x} of copy
information.

if copysourcematch is not None, then copy sources will be filtered by this
matcher

hunksfilterfn, if not None, should be a function taking a filectx and
hunks generator that may yield filtered hunks.
)	�ctx1�ctx2r�changes�opts�
losedatafn�pathfnr��copysourcematchNs-fctx2 unexpectly None in diff hunks filteringr.c3�H# �UHupSRU5v� M g7f)r.N�r2)r��hrange�hliness   r+r��diff.<locals>.<genexpr>
s���E�u�^�V�����(�(�u�s� "rr�)rk�p1�	diffhunksr2r')rb�node1�node2rr�r�r�r�r�r��
hunksfilterfnr�r��fctx1�fctx2r�r�r�s                  r+�diffr��	s����T���
�
� � �"���;�D��;�D�$-��
�
���
���
�'�%� ��c�5��$�
�!�
@�?�
@�!�!�%��/�E��x�x�E�u�E�E���D�C��H�q�L��*�*�S�/�E�)�)��4��J�1%�s�B0B?�6	B?c

�d^^^^^^^^^^^�Uc[RnSn
U
"5mU(dTRTUS9n[U[5(a
USSummmO%UR
URURsmmmT(dT(d	T(d/$TRR(a[nO[nTR5TR54Vs/sHo�(dMU"U5PM snmTc:0mUR(dUR(a[R "TTUS9mU	(a5TR""5V
Vs0sHup�U	"U5(dMX�_M snn
m[%T5n[%T5n[%T5nTH-nUT;dMUR'U5 UR)U5 M/ THnUT;dMUR'U5 M [+U5m[+U5m[+U5m[	TR""55Hup�UT;dM
TU
	M [,R."T[	UU-U-55nTR15U4TR15U4/n[,R2"TU5 UUUUUUUUUU4
SjnUR(a7UR(d&U4Sjn[	U"UR5SS9U55$U"US5$s snfs snn
f![6a U"UR5S	S9S5s$f=f)
z�Yield diff of changes to files in the form of (`header`, `hunks`) tuples
where `header` is a list of diff headers and `hunks` is an iterable of
(`hunkrange`, `hunklines`) tuples.

See diff() for the meaning of parameters.
Nc�F^^�0m[R"5mUU4SjnU$)Nc�>�URUTRU5S9nUT;a4[T5S:�aTTR5	UR	5TU'OTRU5 TR
U5 U$)N)�filelog�)�filectxr�r'�popleftr�r�r9)rr�r��cache�orders   ��r+�
getfilectx�4diffhunks.<locals>.lrugetfilectx.<locals>.getfilectx.
sg����;�;�q�%�)�)�A�,�;�7�D���~��u�:��?��e�m�m�o�.��<�<�>��a�����Q���L�L��O��Kr.)�collections�deque)r�r�r�s @@r+�
lrugetfilectx� diffhunks.<locals>.lrugetfilectx*
s#������!�!�#��		��r.)rrpc�0>
�[T
TTTTTT	TTUUT5$r])�trydiff)r��losedatarr�r�r�r��modifiedr�rerb�revss  ����������r+�difffn�diffhunks.<locals>.difffn{
s4����������������

�
	
r.c�6>�T(aT"US9(d[eg)N)r�)r�)r�r�s �r+r��diffhunks.<locals>.losedata�
s���!��r�):�)�)�*;r.F)�gitT)r�defaultopts�statusr��listr�rrer��	debugflagrr	�noder��upgrader
�
pathcopiesr�rdr�rrrzr�
matchfiles�rev�
prefetchfilesr�r�)rbr�r�rr�r�r�r�r�r�r��hexfuncr�r	r~�modifiedset�addedset�
removedsetr�
prefetchmatch�
revmatchesr�r�rr�r�rer�s```   ```              @@@@@r+r�r�
s�����&�|�� � ���"��J���+�+�d�%�+�0���'�4� � �#*�2�A�;� ��%��
����M�M��O�O�	!��%���E�'��	��w�w�������'+�y�y�{�D�I�I�K�&@�I�&@�d�D�M�G�D�M�&@�I�D��|����8�8�t�|�|��$�$�T�4�u�=�D��*.����N��X�S���9M�����N���h�-�K��5�z�H��W��J�
���D�=�
���q�!��L�L��O�����D�=�
���a� �	�
�k�"�H��8��E��Z� �G������&����d�?��S�	�	'��&�&��d�;��)�J�6�7��M�
����]�#�	
����]�#��J����$�
�+�
�
� �|�|�D�H�H�		5�
*�
��t�y�y�U�y�3�X�>�?�?��d�D�!�!��QJ��O��v�	5��$�)�)��)�-�t�4�4�	5�s*�%
L�3L�L�1L�$L� L/�.L/c#��# �UH�nURS5nUR5nURS5(aSnO2URS5(aSnO[R"SU-5e[RU5H&nURS5(aUS4v� M!XT4v� M( X#:waU[
U5S	S
4v� X!:wdM�U[
U5S	S4v� M� g	7f)z1yield tokens for a list of lines in a single hunkr�r!�diff.deletedr"�
diff.inserted�unexpected hunk line: %sr �diff.tabN�diff.trailingwhitespacer.)rr%r�ProgrammingError�tabsplitter�findallr')�	hunklinesr(�	chompline�	stripline�label�tokens      r+�diffsinglehunkr��
s�������K�K��(�	��$�$�&�	��?�?�4� � �#�E�
�_�_�T�
"�
"�$�E��(�(�)D�t�)K�L�L� �(�(��3�E�����&�&��k�*�*��n�$�	4��!��S��^�-�.�0J�K�K�����I��(�)�3�/�/�)�s�CC(�C(c#�# �[5n[5nUH>nUSSS:Xa	XSS-
nMUSSS:Xa	X#SS-
nM'[R"SU-5e U(aU(d[U5Shv�N g[R[
U55n[R[
U55nUVs/sHofS:XaUOUS-PM nnUVs/sHofS:XaUOUS-PM nnSRU5n	SRU5n
/n/n[R"X�XxS	9n
U
H�uup�nnnUS
:Hn[R"SRXNU55HnURUU45 M [R"SRUUU55HnURUU45 M M� SSU4SSU44H�unnnS
nUH�unnU(aUU4v� SnURS5nU(aLUSSnURS5(aUSSnU[U5SnUR5nU[U5Sn[RU5H'nSUSS:XaSnOU(aUS-nOUS-nUU4v� M) U(dM�W(aUS4v� WS4v� S
nM� M� gGNBs snfs snf7f)zEyield tokens for a list of lines in a single hunk, with inline colorsrrr!Nr"r�r�r.)�lines1�lines2�!r�r�TFr��
r r�s.changeds
.unchangedr�)�	bytearrayrr�r��wordsplitterr�r�r2r�	allblocksr�r9r�r'rr�)r�r�r�r(�al�blr��aln�bln�an�bn�atokens�btokens�blocks�a1�a2�b1�b2�btyperfr�r�r��tokens�
nextisnewline�isendofline�chomp�	endofline�	endspaces�maybetab�currentlabels                               r+�diffsinglehunkinliner��
s����	��A���A�����!�9���
�a�b��M�A�
�!�A�Y�$�
�
�a�b��M�A��(�(�)D�t�)K�L�L�
�
�A�!�)�,�,�,��	�	�	�e�A�h�	'�B�	�	�	�e�A�h�	'�B�35�
6�2�a�U�
�1��E�	�)�2�C�
6�35�
6�2�a�U�
�1��E�	�)�2�C�
6�	���#��B�	���#��B��G��G�
�_�_�R�C�
<�F�#)�����R�%��4�-���(�(����"��)�)<�=�E��N�N�G�U�+�,�>��(�(����"�R��)�)<�=�E��N�N�G�U�+�,�>�	$*�
���(�	
���)�"����v��
�$�N�G�U���u�o�%� %�
��.�.��/�K���c�r�
���>�>�%�(�(�!�#�2�J�E�!�#�e�*�,�/�	������!�#�e�*�,�/�	�'�/�/��6���H�Q�q�M�)�#.�L��',�{�':��',�}�'<����.�.�7��{��$�&@�A�A� �#�&�&� $�
�7%�"�-	-��7��
6�s8�A5K�7J9�8AK�=J<�K�K�/F(K�K�<
Kc/�r^^# �URS5(aUSR(a[mO[m/SQnS/nSn/mUU4SjnU"U0UD6GHWnUR	S5n[U5n	[
U5GHup�U(aURS5(aSnOU(aURS5(dS	nSnU(dU(aURS
5(aS	nUn
U(aUn
U(a#UnU
S-U	:aUS-
nTRU5 M�U"5Shv�N UR5nU
H;unnURU5(dMUU4v� X�:waU[U5SS
4v�  O US4v� U
S-U	:dGMSv� GM U"5Shv�N GMZ gN�N7f)z@yields 2-tuples of (output, label) based on the output of func()r�)
)r5s
diff.diffline)�copy�
diff.extended)�renamer�)soldr�)snewr�)sdeletedr�)sindexr�)s
similarityr�)r�sdiff.file_a)rGsdiff.file_b)rEs	diff.hunkFc3�L># �T(aT"T5Shv�N /TSS&ggN7fr]r^)�
dodiffhunk�
hunkbuffers��r+�consumehunkbuffer�$difflabel.<locals>.consumehunkbuffers(�����!�*�-�-�-��J�q�M��-�s�$�"�$r�rE)rr"r!rErWT)r"r!rNr�r.�r�r.)
r��worddiffr�r�r&r'r�r%r9r)�funcru�kw�headprefixes�textprefixes�headrr4r3�	linecountr�r(�diffline�prefixes�bufferedliner�r�r�r�r�s                  @@r+�	difflabelr
�
s�����	�v�v�f�~�~�"�V�*�-�-�)�
�#�
��L�	��L��D��J��
�t�"�r�"�����E�"����J�	� ��'�G�A���?�?�4�(�(� �D������3�!�!� �D��H��D�T�_�_�\�%B�%B���#�H��'���#���q�5�9�$� �E�)�L��!�!�,�/�-�.�.�.� �K�K�M�	�%-�M�F�E� �+�+�F�3�3�(�%�0�0��,� $�S��^�%5� 6� :�#���&.� ��+�%��q�5�9�$�&�&�M(�N%�&�&�&�U#�6/�	'�s0�D)F7�-F3�.0F7�".F7�F7�(F5�)F7�5F7c�(�[[/UQ70UD6$)zBlike diff(), but yields 2-tuples of (output, label) for ui.write())r
r�)rurs  r+�diffuirIs���T�'�D�'�B�'�'r.c#��# �[5nUR"5VVs0sHupgXv_M	 nnn[U5[U5p�[X-U-5H�nSnX�p�X�;a=Sn
X�;a5UR(a$X;n
X�;aX�;aSnUR	U
5 O5SnO2X�;a-SnUR(aX�;aX�U	;a
X8UU:XaM{X�U4v� M� gs snnf7f)a
generates tuples (f1, f2, copyop), where f1 is the name of the file
before and f2 is the the name after. For added files, f1 will be None,
and for removed files, f2 will be None. copyop may be set to None, 'copy'
or 'rename' (the latter two only if opts.git is set).Nr�r�)rdr�rzr�rr)r�rrer�r��gone�krL�copytor�r�r�copyop�f1�f2s               r+�
_filepairsrNs����
�5�D�#�z�z�|�
,�|�t�q�a�d�|�F�
,��u�:�s�7�|�j�
�H�$�w�.�
/�����B��=��B��y��8�8���B��'�B�N�!*�������!(���
�_��B��x�x��K��	�X�-��A�Y��1�,���f�n��/0��	-�s�C#�C�B4C#c��U(dSn[U5n[R"SU-5nURU5 [	UR55$)Nr.sblob %d)r'r�sha1rr�digest)r�r*r�s   r+�	_gitindexrssA������D�	�A��
�
�l�Q�&�'�A��H�H�T�N��q�x�x�z�?�r.s120000s100755s100644)r�r�r.c#�# �U	R(aS=p�OSnSn
SnSn[R"UR55n[R"UR55nU(dSn[	XEXgU	5GHOunnnSnSnSnSnSnSnU(a2U"UU5nU	R
(dU
(aUR
U5nU(a2U"UU5nU	R
(dU
(aUR
U5nU	R(aSnO[S	UU455nU
(ayU	R
(dhU(dPUU;dJU(d
U"U5(d6U"U5(aU(a"U(dU(dU(aU(aUU:waU
"U=(d U5 U"U=(d U5nU"U=(d U5n/nU	R
(GaURS
UUU
U4-5 U(dURS[U-5 O�U(dURS[U-5 O�[U[Un nUU :wa(URS
U-5 URSU -5 UbqU	R(a4[R"UUUU5S-n!URSU!-5 URSUU4-5 URSUU4-5 OU(aURU"UU55 U(akU	R
(a3U	R
(aIU	R(a8U	R(d'UbSnUbUbUR!U5(dSnO)SnO&UbUR#5nUbUR#5nUUUUUU4n"UUUUUU4n#[%U"U#UUU	5v� GMR g7f)z�given input data, generate a diff and yield it in blocks

If generating a diff would lose data like flags or binary data and
losedatafn is not None, it will be called.

pathfn is applied to every path in the diff output.
r.r�r�c�b�SRUVs/sHnSU-PM
 sn5nSX04-$s snf)Nrs-r %ss
diff %s %sr�)rr�r��revinfos    r+r
�trydiff.<locals>.diffline�s5���)�)�t�<�t��X��^�t�<�=����|�+�+��=s�,c�>�USL=(d UR5S:H$r)r�)r�s r+�isempty�trydiff.<locals>.isempty�s���t�|�/�t�y�y�{�a�/�/r.c��U$r]r^)rs r+r��trydiff.<locals>.<lambda>�s��1r.NFc3�J# �UHocMUR5v� M g7fr])�isbinaryr�s  r+r��trydiff.<locals>.<genexpr>�s���O�~�!�������~�s�#�#sdiff --git %s%s %s%ssnew file mode %ssdeleted file mode %ssold mode %ssnew mode %s�dssimilarity index %d%%s
%s from %ss%s to %s�s)�noprefixr�datestr�daterr�r�r�r
r9�_gitmode�showsimilarityr�score�nobinary�index�cmpr��diffcontent)$rbr�r�r�r�rrer�r�r�r�r��aprefix�bprefixr
r!�date1�date2rrr�content1�content2r�r��flag1�flag2r��path1�path2r��mode1�mode2�sim�data1�data2s$                                    r+r�r�s3���,�}�}����'�����,�0�
���T�Y�Y�[�)�E����T�Y�Y�[�)�E����$�X�g�T�J���B��������������
��r�4�(�E��x�x�:��
�
�2���
��r�4�(�E��x�x�:��
�
�2����9�9��F��O��u�~�O�O�F��d�h�h���d�
��G�E�N�N�������E���u��~��2�8��$��r�x�R� ���r�x�R� �����8�8�8��M�M�'�7�E�7�E�*J�J�
���
�
�1�H�U�O�C�D���
�
�5����G�H�'������u���E�>��M�M�.�5�"8�9��M�M�.�5�"8�9��%��*�*�%�m�m�D��K��e��E��K���
�
�&>��&D�E��M�M�-�6�5�/�"A�B��M�M�+����"?�@��
��M�M�(�5�$�/�0�����T�X�X�$�-�-��
�
�
� � ��� ��$�U�Y�Y�u�-=�-=�$�H�&�H��� � �:�:�<��� � �:�:�<���u�e�U�H�e�<���u�e�U�H�e�<���%�����=�=�IK�s�OOc��UupVpxp�Uup�p�nnXu;a[U	5O[RnX�;a[U5O[RnU(a\UR(aKUR(d:[
R"X�5nU(aURSUU4-5 SU/44nO�UR(aOURS:�a?UnUcUnURSUSURUSUR[U4-5 [
R"U	U
UUUU
UUS9unnURU5 XlUU4$)adiffs two versions of a file.

data1 and data2 are tuples containg:

    * ctx: changeset for the file
    * fctx: file context for that file
    * path1: name of the file
    * flag: flags of the file
    * content: full content of the file (can be null in case of binary)
    * date: date of the changeset

header: the patch header
binary: whether the any of the version of file is binary or not
opts:   user passed options

It exists as a separate function so that extensions like extdiff can wrap
it and use the file content directly.
sindex %s..%sNrsindex %s..%s %s)r�r�)rr�nullhexr�r0r�b85diffr9r1r-�unidiff�extend)rArBr�r�r�r�r�r<r:r8r6r�r�r=r;r9r7�index1�index2r�r��flag�uheaderss                       r+r3r3s3��(27�.�D��x�16�.�D��x��$)�M�Y�x�
 �7H�7P�7P�F�$)�M�Y�x�
 �7H�7P�7P�F�
�$�(�(�4�=�=��}�}�X�0����M�M�/�V�V�,<�<�=�����!���8�8��
�
�Q���D��|����M�M�"��1�t�z�z�*��1�t�z�z�*��T�N���
� �-�-���������	
���%�	�
�
�h�����&�&r.c��Supp4nUHGupgp�[U[R"U55n[X'U-5nX7-
nXH-
nU=(d U	nMI XX4U4$)N)rrrrF)rr
�colwidth)
�stats�maxfile�maxtotal�addtotal�removetotalr�rr�r�r�s
          r+�diffstatsumrSHsh��7H�4�G�x�f��
��a��g�x�0�0��3�4���x�Q��'���
�������1����h�V�;�;r.c�l^^^^^	�[R"S5n/m	SummmmUUUUU	4SjnSnUGHunURS5(a�U"5 SnSummmURS5(a&[R	U5RS	5mMeURS
5(a"UR	U5RS5mM�M�URS5(aSnM�URS
5(aU(dTS-
mM�URS5(aU(dTS-
mGMURS5(dURS5(aSmGM3URS5(aUSSmGMQURS5(dGMjTSUSS--
mGMx U"5 T	$)Ns^diff .*-r [a-z0-9]+\s(.*)$)NrrFc�@>�T(aTRTTTT45 ggr]rY)�addsr%r&�removes�resultss�����r+�	addresult�diffstatdata.<locals>.addresultZs �����N�N�H�d�G�X�>�?�r.Fr5T)rrFr�r$sdiff -rrs@@r"r!rsBinary filesrename fromr�s	rename tos => %sr�)r�r�r%rr�r)
r3r�rYr)r(rVr%r&rWrXs
     @@@@@r+�diffstatdatar[Ts}���
�Z�Z�7�
8�F��G�(9�%�H�d�G�X�@�@��H����?�?�7�#�#��K��H�&1�#�D�'�8����/�0�0� �<�<��-�3�3�A�6������,�,�!�=�=��.�4�4�Q�7��-��_�_�U�
#�
#��H�
�_�_�T�
"�
"�8��A�I�D�
�_�_�T�
"�
"�8��q�L�G�
�_�_�0�
1�
1�T�_�_��6
�6
��H�
�_�_�^�
,�
,��B�C�y�H�
�_�_�\�
*�
*��	�D���I�-�-�H�3�4�K��Nr.c
�^^�/n[U5n[U5unmpVn[[T55nU(aUS:aSnX-
U-
S-
mTS:aSmUU4Sjn	UHaup�p�U
(aSnOSX�--nSU	"U5-nSU	"U5-nUR	S	U
S
U[
R"U
5-
-UUUU4-5 Mc U(a(UR	[S5[U5XV4-5 SRU5$)
Nrprsr�c�\>�TT::aU$[UT-T-[[U555$r])rr�bool)r��
graphwidthrPs ��r+�scale�diffstat.<locals>.scale�s0����z�!��H��1�z�>�X�-�s�4��7�|�<�<r.sBinr�r"r!s %s%s |  %*s %s%s
rs5 %d files changed, %d insertions(+), %d deletions(-)
r.)	r[rSr'r�r9r
rMrr2)r3�width�outputrN�maxname�	totaladds�totalremoves�	hasbinary�
countwidthr`r%rVrWr&r�pluses�minusesr_rPs                 @@r+�diffstatrk�s!���
�F����E�<G��<N�9�G�X�y�	��S��]�#�J��Z�!�^��
��#�g�-��1�J��B���
�=�.3�)�����E��T�^�,�E���d��#����w��'���
�
�"����(�"3�"3�H�"=�=�>�����
�
�
	
�.3�&
��
�
�
�G�H��5�z�9�3�
4�	
�
�8�8�F��r.c/�# �[U0UD6R5H�nU(a�USS;a�URSS5up4US-S4v� [R"SU5nU(aURS5S4v� [R"S	U5nU(aURS5S
4v� OUS4v� Sv� M� g7f)
zGlike diffstat(), but yields 2-tuples of (output, label) for
ui.write()
r�s+-rrr.s\++rsdiffstat.inserteds-+sdiffstat.deletedrN)rkr��rsplitr�r�r)rurr(�name�graphrHs      r+�
diffstatuirp�s����
�$�%�"�%�0�0�2���D��H��%��+�+�d�A�.�K�D��$�;��$�$��	�	�'�5�)�A���w�w�q�z�#7�8�8��	�	�&�%�(�A���w�w�q�z�#6�7�7����+����3�s�CCr])rr.r�)Nr�)r.Nr�r)rr.Nr�r)rr.)
NNNNNNNNNN)NNNNNNN)�returnzIterator[tuple[Any, bytes]])�P)m�
__future__rr��
contextlibr�r�r�r�r�r��i18nrr�rrr	�r
rrr
rrrrrrrrrr<�utilsrrrr�
TYPE_CHECKING�emailrrr1r�rr�r�rgr�rnr&r��contextmanagerr�r�r�r
rrr9r_r�r�r�r�r}r�r�r:rhr�r�r�r�r�r|r r.rrCrMr�r]rar\rzr�r�r�r�r��	Exceptionr��diffallopts�diffopts�difffeatureoptsr�r�r�r�r
rrrr-r�r3rSr[rkrpr^r.r+�<module>rs��#����	�	�
�
�����
������
�����
�=�=��
�
�
�/�0���j�j�)�*���z�z�A����
�
�
��'�'���3�3��
@�J��������4s�l-:�-:�`*�Z(�(�* "� "�F.*��.*�b/(�Y�/(�d#,�#,�L*+�/�*+�\
�*�*�C�
D���j�j�K�L��/��d�d�NM
�M
�`kB�kB�\@�Fo�da,�a,�H;�;�|�=�@M�`&9�R:�z0%�f�6dK�N8�v�,�CL�\�~.�d?H��F�
���
N�"HQ�N���
����B�4	�i�	������"�"���*�*��
�
�
��	
���	
���H�^��	
���	
��C"�L0�2D%�RJ'�Z(�
"�J��9�9�=��M>�`6'�r	<�*�Z-�`r.