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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /kunden/kunden/usr/lib/python3/dist-packages/breezy/__pycache__/merge.cpython-313.pyc
�

p��g<��	�^�SSKrSSKrSSKJr \"\"5S5 SSKJrJrJrJrJ	r	J
r
Jr SSKJr
 SSKJr SSKJr "S	S
\R$5rS<Sjr"SS
\R*5r"SS5r"SS\5r"SS\5r"SS5r"SS5r"SS5r\"5r"SS5r"SS\5r"SS\5r "S S!\5r!"S"S#\R$5r""S$S%\5r#"S&S'5r$"S(S)\5r%S*S*\S*S*SSSS4	S+jr&\	RN\(\)\4"5r*\*RWS,\!S-5 \*RWS.\ S/5 \*RWS0\S15 \*RWS2\S35 S4r,S5r-"S6S75r."S8S9\.5r/"S:S;\.5r0g)=�N�)�lazy_importz�
import patiencediff

from breezy import (
    debug,
    graph as _mod_graph,
    textfile,
    ui,
    )
from breezy.bzr import (
    generate_ids,
    )
from breezy.i18n import gettext
)�
decorators�errors�hooks�osutils�registry�trace�	transform)�revision)�	transport)�treec��\rSrSrSrSrg)�CantReprocessAndShowBase�/znCan't reprocess and show base, because reprocessing obscures the relationship of conflicting lines to the base�N)�__name__�
__module__�__qualname__�__firstlineno__�_fmt�__static_attributes__r��./usr/lib/python3/dist-packages/breezy/merge.pyrr/s��	<�	rrc
��UR5 [URUUSUUS9 SSS5 g!,(df   g=f)NT)�ignore_zero�	this_tree�interesting_files)�lock_tree_write�merge_inner�branch)�	from_tree�to_treers   r�transform_treer$6s:��	�	"�	"�	$���������/�
	
�
%�	$�	$�s	�3�
Ac��\rSrSrSrSrg)�
MergeHooks�Bc��[RRUSS5 URSSS5 URSSS5 URS	S
S5 g)Nzbreezy.mergezMerger.hooks�merge_file_contenta�Called with a breezy.merge.Merger object to create a per file merge object when starting a merge. Should return either None or a subclass of ``breezy.merge.AbstractPerFileMerger``. Such objects will then be called per file that needs to be merged (including when one side has deleted the file and the other has changed it). See the AbstractPerFileMerger API docs for details on how it is used by merge.)�r�	pre_mergezGCalled before a merge. Receives a Merger object as the single argument.)r*��
post_mergezcCalled after a merge. Receives a Merger object as the single argument. The return value is ignored.)r�Hooks�__init__�add_hook��selfs rr/�MergeHooks.__init__Csc��
�����T�>�>�B��
�
� �
�
�	
�	
�
�
��U��	
�
	
�
�
��
+�
�	
rrN)rrrrr/rrrrr&r&Bs��
rr&c�$�\rSrSrSrSrSrSrg)�AbstractPerFileMerger�`z�PerFileMerger objects are used by plugins extending merge for breezy.

See ``breezy.plugins.news_merge.news_merge`` for an example concrete class.

:ivar merger: The Merge3Merger performing the merge.
c��Xlg)z+Create a PerFileMerger for use with merger.N��merger)r2r9s  rr/�AbstractPerFileMerger.__init__hs���rc��g)a[Attempt to merge the contents of a single file.

:param merge_params: A breezy.merge.MergeFileHookParams
:return: A tuple of (status, chunks), where status is one of
    'not_applicable', 'success', 'conflicted', or 'delete'.  If status
    is 'success' or 'conflicted', then chunks should be an iterable of
    strings for the new file contents.
)znot applicableNr)r2�merge_paramss  r�merge_contents�$AbstractPerFileMerger.merge_contentsls��(rr8N)rrrr�__doc__r/r=rrrrr5r5`s����	(rr5c�*�\rSrSrSrSrSrSrSrg)�
PerFileMerger�xz�Merge individual files when self.file_matches returns True.

This class is intended to be subclassed.  The file_matches and
merge_matching methods should be overridden with concrete implementations.
c�,�[UR5e)z�Return True if merge_matching should be called on this file.

Only called with merges of plain files with no clear winner.

Subclasses must override this.
)�NotImplementedError�file_matches�r2�paramss  rrE�PerFileMerger.file_matchess��"�$�"3�"3�4�4rc��URS:Xd+UR5(aURU5(dgURU5$)z$Merge the contents of a single file.�other��not_applicableN)�winner�
is_file_mergerE�merge_matchingrFs  rr=�PerFileMerger.merge_contents�sH��

�M�M�W�$��$�$�&�&��!�!�&�)�)�)��"�"�6�*�*rc�,�[UR5e)z�Merge the contents of a single file that has matched the criteria
in PerFileMerger.merge_contents (is a conflict, is a file,
self.file_matches is True).

Subclasses must override this.
)rDrOrFs  rrO�PerFileMerger.merge_matching�s��"�$�"5�"5�6�6rrN)	rrrrr?rEr=rOrrrrrArAxs���5�+� 7rrAc�N^�\rSrSr%Sr\\S'SrU4SjrSr	Sr
SrS	rU=r
$)
�ConfigurableFileMerger�a2Merge individual files when configured via a .conf file.

This is a base class for concrete custom file merging logic. Concrete
classes should implement ``merge_text``.

See ``breezy.plugins.news_merge.news_merge`` for an example concrete class.

:ivar affected_files: The configured file paths to merge.

:cvar name_prefix: The prefix to use when looking up configuration
    details. <name_prefix>_merge_files describes the files targeted by the
    hook for example.

:cvar default_files: The default file paths to merge when no configuration
    is present.
�name_prefixNc��>�[TU]U5 SUlURR=(d /UlURR
UlUR
c[
S5eg)Nzname_prefix must be set.)�superr/�affected_files�	__class__�
default_filesrV�
ValueError)r2r9rZs  �rr/�ConfigurableFileMerger.__init__�s^���
���� �"���!�^�^�9�9�?�R����>�>�5�5������#��7�8�8�$rc��URnUcYURRR5nURS-nURU5nUcURnX lU(aURnXR;agg)z�Check whether the file should call the merge hook.

<name_prefix>_merge_files configuration variable is a list of files
that should use the hook.
�_merge_filesTF)rYr9�this_branch�
get_configrV�get_user_option_as_listr[�	this_path)r2rGrY�config�
config_key�filepaths      rrE�#ConfigurableFileMerger.file_matches�s����,�,���!��[�[�,�,�7�7�9�F�
�)�)�N�:�J�#�;�;�J�G�N��%�!%�!3�!3��"0����'�'�H��)��rc�$�URU5$�N)�
merge_textrFs  rrO�%ConfigurableFileMerger.merge_matching�s�����v�&�&rc�,�[UR5e)z�Merge the byte contents of a single file.

This is called after checking that the merge should be performed in
merge_contents, and it should behave as per
``breezy.merge.AbstractPerFileMerger.merge_contents``.
)rDrjrFs  rrj�!ConfigurableFileMerger.merge_text�s��"�$�/�/�2�2r)rYr[rV)rrrrr?�str�__annotations__r[r/rErOrjr�
__classcell__�rZs@rrTrT�s.����"���M�9��2'�3�3rrTc��\rSrSrSrSrSr\RS5r	\RS5r
\RS5rSrg	)
�MergeFileHookParams��a�Object holding parameters passed to merge_file_content hooks.

There are some fields hooks can access:

:ivar base_path: Path in base tree
:ivar other_path: Path in other tree
:ivar this_path: Path in this tree
:ivar trans_id: the transform ID for the merge of this file
:ivar this_kind: kind of file in 'this' tree
:ivar other_kind: kind of file in 'other' tree
:ivar winner: one of 'this', 'other', 'conflict'
c�v�XlX lUuUlUlUlX0lX@lXPlX`lgri)	�_merger�paths�	base_path�
other_pathrc�trans_id�	this_kind�
other_kindrM)r2r9rwrzr{r|rMs       rr/�MergeFileHookParams.__init__�s2�����
�:?�7������� �
�"��$���rc�L�URS:H=(a URS:H$)z1True if this_kind and other_kind are both 'file'.�file)r{r|r1s rrN�!MergeFileHookParams.is_file_merge�s���~�~��'�E�D�O�O�v�,E�Erc�v�URRURRUR5$)z,The lines of the 'base' version of the file.)rv�	get_lines�	base_treerxr1s r�
base_lines�MergeFileHookParams.base_lines�)���|�|�%�%�d�l�l�&<�&<�d�n�n�M�Mrc�v�URRURRUR5$)z,The lines of the 'this' version of the file.)rvr�rrcr1s r�
this_lines�MergeFileHookParams.this_linesr�rc�v�URRURRUR5$)z-The lines of the 'other' version of the file.)rvr��
other_treeryr1s r�other_lines�MergeFileHookParams.other_lines
s)���|�|�%�%�d�l�l�&=�&=�t���O�Or)	rvrxr|ryrwr{rcrzrMN)
rrrrr?r/rNr�cachedpropertyr�r�r�rrrrrsrs�sf����F����N��N����N��N����P��Prrsc�8�\rSrSr%\"5r\\S'SSjrSr	\
S5rSrSr
\
"\
\5rS	rS
r\
"\\5r\SSj5r\S5r\SS
j5rSSjrSSjrSrSrSrSSjrSrSrSrSr Sr!Sr"Sr#Sr$Sr%g) �Mergeri�
merge_typeNc�~�[RU5 XlUR5UlSUlX@lSUlSUlX l	SUl
X0lSUlSUl
SUlSUlSUlSUlX`lXPl0UlXplSUlSUlSUlSUlg�NF)�objectr/r`�
last_revision�
this_basis�this_rev_idr�this_revision_tree�this_basis_treer��other_branchr�r�backup_filesr�	show_base�	reprocess�pp�recurse�change_reporter�
_cached_trees�_revision_graph�_base_is_ancestor�_base_is_other_ancestor�_is_criss_cross�
_lca_trees)r2r`r�r�rr�r��revision_graphs        rr/�Merger.__init__s���	�����&��%�3�3�5������"��"&���#���$�� ���"�� ���!���!%��������������.�����-��!%���'+��$�#�����rc��UH'nUcMUR5nX RU'M) g![a M9f=f)z0Cache any tree in trees if it has a revision_id.N)�get_revision_id�AttributeErrorr�)r2�trees�
maybe_tree�rev_ids    r�cache_trees_with_revision_ids�$Merger.cache_trees_with_revision_ids9sL���J��!��
�#�3�3�5��*4���v�&� ��
"�
��
�s�/�
=�=c��URc)URRR5UlUR$ri)r�r`�
repository�	get_graphr1s rr��Merger.revision_graphDs7�����'�#'�#3�#3�#>�#>�#H�#H�#J�D� ��#�#�#rc��Xlgri)r��r2�values  r�_set_base_is_ancestor�Merger._set_base_is_ancestorJs��!&�rc��URc5URRURUR5UlUR$ri)r�r��is_ancestor�base_rev_idr�r1s r�_get_base_is_ancestor�Merger._get_base_is_ancestorMsD���!�!�)�%)�%8�%8�%D�%D�� � �$�/�/�&�D�"��%�%�%rc��Xlgri)r�r�s  r�_set_base_is_other_ancestor�"Merger._set_base_is_other_ancestorVs��',�$rc��URcCURcgURRURUR5UlUR$)NT)r��other_basisr�r�r�r1s r�_get_base_is_other_ancestor�"Merger._get_base_is_other_ancestorYsU���'�'�/����'��+/�+>�+>�+J�+J�� � �$�"2�"2�,�D�(��+�+�+rc���UcUR5n[URXU5nURR	5UlSUlUR
UlU$)aReturn a Merger for uncommitted changes in other_tree.

:param tree: The tree to merge into
:param other_tree: The tree to get uncommitted changes from
:param base_tree: The basis to use for the merge.  If unspecified,
    other_tree.basis_tree() will be used.
N)�
basis_treer�r!r�r�r��other_rev_idr�)rr�r�r9s    r�from_uncommitted�Merger.from_uncommittedfs\����"�-�-�/�I�����Z�D�A��#�-�-�=�=�?���"���#�/�/����
rc���URURR5 URURR5up4nURRR	5nUb[U[
R:wa1URX1RR55(aSnO[R"S5 URXX6S9nXu4$)z�Return a Merger for a bundle or merge directive.

:param tree: The tree to merge changes into
:param mergeable: A merge directive or bundle
NzPerforming cherrypick)r�)�install_revisionsr!r��get_merge_requestr��
_mod_revision�
NULL_REVISIONr�r�r
�warning�from_revision_ids)�klassr�	mergeable�base_revision_id�other_revision_id�verifiedr�r9s        r�from_mergeable�Merger.from_mergeablews���	�#�#�D�K�K�$:�$:�;�8A�8S�8S��K�K�"�"�9
�5��X����/�/�9�9�;���'� �M�$?�$?�?�"�.�.�$�k�k�&?�&?�&A���$(� ��
�
�5�6��(�(��%5�)�
����rc���UcURn[X`US9nUcURnURX5 UcUR5 U$UcUnUR	X$5 U$)a�Return a Merger for revision-ids.

:param tree: The tree to merge changes into
:param other: The revision-id to use as OTHER
:param base: The revision-id to use as BASE.  If not specified, will
    be auto-selected.
:param other_branch: A branch containing the other revision-id.  If
    not supplied, tree.branch is used.
:param base_branch: A branch containing the base revision-id.  If
    not supplied, other_branch or tree.branch will be used.
:param revision_graph: If you have a revision_graph precomputed, pass
    it in, otherwise it will be created for you.
:param tree_branch: The branch associated with tree.  If not supplied,
    tree.branch will be used.
)rr�)r!r��set_other_revision�	find_base�set_base_revision)rrJ�baser��base_branchr��tree_branchr9s        rr��Merger.from_revision_ids�st��2���+�+�K���N�S�����;�;�L��!�!�%�6��<�����
�
��"�*���$�$�T�7��
rc��XR;a9UcURnURRU5nX0RU'URU$![R
a URRU5nNNf=fri)r�r`r�
revision_treer�NoSuchRevisionInTreer�)r2�revision_idr!rs    rr��Merger.revision_tree�s����0�0�0��~��)�)��
D��~�~�3�3�K�@��/3���{�+��!�!�+�.�.���.�.�
D��(�(�6�6�{�C��
D�s�A�/B
�	B
c��Uup4Uc(SSKJn URU5SnURU4$SSKJn URX25SnUS:XaUR5n	OUR
U5n	X�RX�54$)Nr)�WorkingTreer)�Branch���)�workingtreer��open_containingr!r�r��
get_rev_idr�)
r2�treespec�possible_transports�location�revnor�rr�r!r�s
          r�	_get_tree�Merger._get_tree�s���"����=�0��.�.�x�8��;�D��;�;��$�$�"��'�'��F�q�I���B�;� �.�.�0�K� �+�+�E�2�K��)�)�+�>�>�>rc��Xlgri)r)r2�	file_lists  r�set_interesting_files�Merger.set_interesting_files�s��!*�rc��UR(aUR(a
URcgUR5 gri)�base_is_ancestor�base_is_other_ancestorr��_add_parentr1s r�set_pending�Merger.set_pending�s/���%�%��.�.�� � �(�����rc��URR5UR/-n/n[R"5nUHFnURU5nUR
UR55 URXE45 MH URRUSS9 SSS5 g![Ra SnNQf=f!,(df   g=f)NT)�allow_leftmost_as_ghost)r�get_parent_idsr��
contextlib�	ExitStackr��
enter_context�	lock_readr�NoSuchRevision�append�set_parent_trees)r2�new_parents�new_parent_trees�stackr�rs      rr��Merger._add_parent�s����n�n�3�3�5��9J�9J�8K�K����
�
!�
!�
#�u�*��:��-�-�k�:�D��'�'����(8�9� �'�'��(;�<� +�
�N�N�+�+� �$�
,�
�$�
#���,�,� ��D� ��	$�
#�s1�C�B0�AC�0C	�C�C	�	C�
Cc��URX5uUlUlUSS:XavURR5Ul[
R"UR5(a [R"UR5eURUl	O�USb5URRUS5UlURUl	OSSUlURR5Ul	URc [R"UR5eURb#URURUR'URURURUR5 g)z�Set the revision and tree to merge from.

This sets the other_tree, other_rev_id, other_basis attributes.

:param other_revision: The [path, revision] list to merge from.
rr�N)r�r�r�r�r�r��is_nullr�	NoCommitsr�r�r��_maybe_fetchr`)r2�other_revisionr�s   r�	set_other�Merger.set_other�sD��.2�^�^��.
�*���4�?��!���"� $� 1� 1� ?� ?� A�D���$�$�T�%6�%6�7�7��&�&�t�'8�'8�9�9�#�0�0�D��
�A�
�
*� $� 1� 1� <� <�^�A�=N� O�D��#�0�0�D�� $�D��#�0�0�>�>�@�D�����'��&�&�t�'8�'8�9�9����(�48�O�O�D���t�0�0�1����$�+�+�T�-=�-=�t�?O�?O�Prc��XlX lURX RUR5 UR	U5UlXlg)z�Set 'other' based on a branch and revision id.

:param revision_id: The revision to use for a tree
:param other_branch: The branch containing this tree
N)r�r�rr`r�r�r�)r2r�r�s   rr��Merger.set_other_revisionsD��(��(�����,�(8�(8�$�:K�:K�L��,�,�[�9���&�rc��XlX lURX RU5 UR	U5Ulg)z�Set 'base' based on a branch and revision id.

:param revision_id: The revision to use for a tree
:param branch: The branch containing this tree
N)r�r�rr`r�r�)r2r�r!s   rr��Merger.set_base_revisions8��'��!�����&�"2�"2�K�@��+�+�K�8��rc�|�URRUR5(dURX5 ggri)r��has_same_location�fetch)r2�source�targetr�s    rr�Merger._maybe_fetch"s1��� � �2�2�6�3D�3D�E�E��L�L��-�Frc��URUR/n[RU;a>[RUlURUR5UlSUlGO�URRUSUS5nSUl[U5S:Xa[RUlO�[U5S:Xa[U5SUlO�SUl[U5S:�a(URRUSUS5UlOURR"U6UlURRUSU5nUR[R:Xa
USUlUR[R:Xa[R"5eUR(Ga^[ R""S5 [ R$"SR'U55 URU;a/[ R$"SR'UR55 [)U5nUR+UR5 UR,R.R1U5Vs0sHnUR35U_M nnUR4R7U5 URU;aX`RUlO UR9UR5UlWVs/sHovUPM	 snUlO URUR5UlSUlSUl[ R$"S	R'UR55 gs snfs snf)
NFrrTr*zBWarning: criss-cross merge encountered.  See bzr help criss-cross.zCriss-cross lcas: {!r}z8Unable to find unique lca. Fallback {!r} as best option.zBase revid: {!r}) r�r�r�r�r�r�r�r�r��find_lca�len�list�find_unique_lca�find_merge_orderr�UnrelatedBranchesr
r��mutter�format�set�addr`r��revision_treesr�r��update�popr�r�r�)r2�	revisions�lcas�sorted_lca_keys�interesting_revision_ids�t�interesting_trees�keys        rr��Merger.find_base&s����_�_�d�&6�&6�7�	��&�&�)�3�,�:�:�D��!�/�/��0@�0@�A�D�N�#(�D� ��&�&�/�/�	�!��i��l�K�D�#(�D� ��4�y�A�~�#0�#>�#>�� ��T��a��#'��:�a�=�� �'+��$��t�9�q�=�
(,�':�':�'J�'J�!�!��i��l�(�D�$�(,�':�':�'J�'J�D�'Q�D�$�"&�"5�"5�"F�"F��a�L�$�#���#�#�}�'B�'B�B�'6�q�'9�D�$����=�#>�#>�>��.�.�0�0��#�#�#��
�
�X�����5�<�<�T�B�C��#�#�t�+��L�L�8�8>��t�?O�?O�8P��,/�t�9�(�(�,�,�T�-=�-=�>�"�-�-�8�8�G�G�0��%����%�%�'��*��"�%��"�"�)�)�*;�<��#�#�t�+�%6�7G�7G�%H�D�N�%6�%:�%:�4�;K�;K�%L�D�N�ET�"U�_�c�S�#9�_�"U���!%�!3�!3�D�4D�4D�!E��� $���&*��#�
���'�.�.�t�/?�/?�@�A��!%��#Vs�N�Nc��[R"S5 USS/:XaUR5 gURU5uo lUSS:XaUR5UlO5USc[RUlOURUS5UlURX RUR5 g)zsSet the base revision to use for the merge.

:param base_revision: A 2-list containing a path and revision number.
z-doing merge() with no base_revision specifiedNrr�)r
r#r�r�r�r�r�r�r�r�rr`)r2�
base_revisionr�s   r�set_base�Merger.set_basees���
	���D�E��T�4�L�(��N�N��*.�.�.��*G�'�K���Q��2�%�#.�#<�#<�#>�� ��q�!�)�#0�#>�#>�� �#.�#9�#9�-��:J�#K�� ����k�+;�+;�T�=M�=M�Nrc�T�URURURURURURSS.nUR
R(aURUS'UR
R(aURUS'O@UR(a/[R"SRUR
55eUR
R(aURUS'O@UR(a/[R"SRUR
55e[UR
SS	5(d&UR (d[R""5eUR
R$(a,UR&(+=(d UR (+US
'UR((a+[UR
SS5(aUR*US'UR
"SS
UR,0UD6$)NF)�working_treerr�rr`r��do_merger�r�z6Conflict reduction is not supported for merge type {}.r�z5Showing base is not supported for this merge type. {}�supports_reverse_cherrypickT�
cherrypick�supports_lca_trees�	lca_treesr�r)rr�rr`r�r��
requires_baser��supports_reprocessr�r�BzrErrorr$�supports_show_baser��getattrr��CannotReverseCherrypick�supports_cherrypickr�r�r�r�)r2�kwargss  r�make_merger�Merger.make_mergerws��� �N�N�����/�/�!%�!7�!7��+�+� �-�-��
���?�?�(�(�"&�.�.�F�;���?�?�-�-�"&�.�.�F�;��
�^�^��/�/�H�O�O��O�O���
�
�?�?�-�-�"&�.�.�F�;��
�^�^��/�/�G�N�N��O�O���
�����)F��M�M��/�/��0�0�2�2��?�?�.�.��)�)�)�L��1L�1L�-L�
�<� ����G��O�O�1�5�%
�%
�#'�/�/�F�;�����N�t�/C�/C�N�v�N�Nrc���UR5nURb%URRUR5 [R
SHnU"U5 M
 UR
5 [R
SHnU"U5 M
 URS:XGa�URR5GH�nURRU5nURRU5nXTR5:XaMOURRU5nURRR R#UR 5nUR%UR5U5(aUR'XeS9 M�[	URUS9nUR(UlUR+XV5 [,R."URUR0U5n	U	c[2eUR0RU	5n
URR R5U
5UlX�lUR
5 GM� U$)Nr+r-�down)�
stop_revision)r)rEr��update_referencesr`r�rr8r�r�iter_references�get_nested_treer��get_reference_revisionr��reference_parentr!r�r�r��pullr�r��	_mod_tree�find_previous_pathr�rDr�r�)r2�merge�hook�relpath�sub_treerr��graph�	sub_merge�base_tree_pathr3s           r�_do_merge_to�Merger._do_merge_to�s���� � �"�����(����/�/��0@�0@�A��L�L��-�D���K�.�
�����L�L��.�D���K�/��<�<�6�!��>�>�9�9�;���>�>�9�9�'�B��!%���!G�!G��!P��!�%;�%;�%=�=��#���?�?��H�����-�-�8�8�B�B� �+�+����$�$�X�%;�%;�%=�~�N�N��M�M�,�M�M� &�x���(� K�I�+/�?�?�I�(��0�0��N�%.�%A�%A��������&�N�&�-�1�1�$(�N�N�$I�$I�&�%�M�+3�/�/�*D�*D�*R�*R�%�+�I�'�-:�)��&�&�(�7<�8�rc�
�[R"5nURURR	55 UR
b)URUR
R
55 URb)URURR
55 UR5nSSS5 [WR5S:XaVUR(d9[R"5(d[R"[S55 UR$[R"[S5[UR5-5 UR$!,(df   N�=f)Nrz!All changes applied successfully.z%d conflicts encountered.)rrrrrr�rr�rYr�cooked_conflictsrr
�is_quiet�note�gettext)r2r	rRs   rr8�Merger.do_merge�s��
�
!�
!�
#�u������� >� >� @�A��~�~�)��#�#�D�N�N�$<�$<�$>�?����*��#�#�D�O�O�$=�$=�$?�@��%�%�'�E�
$��u�%�%�&�!�+��#�#�E�N�N�,<�,<��
�
�7�#F�G�H��%�%�%�	
�J�J��3�4�s�5�;Q�;Q�7R�R�
��%�%�%�$�
#�s�B&E4�4
F)r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r�r�r�r�r�r�r�r�r�r`r�r�r)NNNNrHNri)NNNNN)&rrrrr&rr�ror/r��propertyr�r�r�r�r�r�r��staticmethodr��classmethodr�r�r�r�r�r�r�rr�r�rr�r4rErYr8rrrrr�r�s���L�E���
������!�F	4��$��$�
'�&� � 5�7L�M��-�,�&�#�%@������� � �� �4������$��$�L	/�?� +��� Q�6
'�	9�.�=B�~O�$)O�V&�P&rr�c�:�\rSrSrSrSrSrSrSrSr	Sr
SrSrSr
g)�_InventoryNoneEntryi�z�This represents an inventory entry which *isn't there*.

It simplifies the merging logic if we always have an InventoryEntry, even
if it isn't actually present
Nc��XL$rir)r2rJs  r�
is_unmodified�!_InventoryNoneEntry.is_unmodified�s
���}�rr)rrrrr?�
executable�kind�name�	parent_idr�symlink_target�	text_sha1rgrrrrrere�s1����J��D��D��I��H��N��I�rrec�J�\rSrSrSrSrSrSrSrSr	Sr
SSSS.rSrSr
S$S	jrS
rSrSrS
rSrSrSr\S5r\S5r\S5r\S5r\S5r\S5r\S%Sj5rSrSrSr Sr!Sr"Sr#Sr$S&Sjr%S'S jr&S!r'S"r(S#r)g)(�Merge3Mergeri�z2Three-way merger that uses the merge3 text merger.TFr*r)�thisrJ�conflictNc�(�[RU5 UcURnX�lXlX lX0lX@lX�lX�l	/Ul
/UlXPlX`l
X�lXplX�lU	(aUR#5 gg)adInitialize the merger object and perform the merge.

:param working_tree: The working tree to apply the merge to
:param this_tree: The local tree in the merge operation
:param base_tree: The common tree in the merge operation
:param other_tree: The other tree to merge changes from
:param this_branch: The branch associated with this_tree.  Defaults to
    this_tree.branch if not supplied.
:param other_branch: The branch associated with other_tree, if any.
:param: reprocess If True, perform conflict-reduction processing.
:param show_base: If True, show the base revision in text conflicts.
    (incompatible with reprocess)
:param change_reporter: An object that should report changes made
:param interesting_files: The tree-relative paths of files that should
    participate in the merge.  If these paths refer to directories,
    the contents of those directories will also be included.  If not
    specified, all files may participate in the
    merge.
:param lca_trees: Can be set to a dictionary of {revision_id:rev_tree}
    if the ancestry was found to include a criss-cross merge.
    Otherwise should be None.
N)r�r/r!rr7rr�r�r`r��_raw_conflictsr\r�r�r�r�r:r8)r2r7rr�r�r�r�r�rr8r:r<r`r�s              rr/�Merge3Merger.__init__s���L	�������#�*�*�K�!2��(��"��"��$��&��(�� ��� "���"��"��#�� /��$����M�M�O�rc��[R"5nURURR	55 URUR
R
55 URURR
55 URURR
55 URR5Ul
URUR5 UR5 URRSS9nURU5 URRUR5 SSS5 g![ R"a Nf=f!,(df   g=f)NT)�no_conflicts)rrrr7rrrr�r�r�tt�_compute_transform�apply�write_modified�
add_conflictsr\r�UnsupportedOperation)r2r	�resultss   rr8�Merge3Merger.do_merge?s��
�
!�
!�
#�u����� 1� 1� A� A� C�D������� 8� 8� :�;������� 8� 8� :�;������� 9� 9� ;�<��'�'�1�1�3�D�G�������(��#�#�%��g�g�m�m��m�6�G�����(�
��!�!�/�/��0E�0E�F�$�
#���.�.�
��
��$�
#�s*�DE8�0%E�E5�2E8�4E5�5E8�8
Fc�^�URR5 URR5 URR	5UlUR
5 UR
sSSS5 sSSS5 $!,(df   O=fSSS5 g!,(df   g=fri)r�rr�r7�preview_transformrxryr1s r�make_preview_transform�#Merge3Merger.make_preview_transformOsj��
�^�^�
%�
%�
'����)B�)B�)D��'�'�9�9�;�D�G��#�#�%��7�7�*E�)D�
'�
'�)D�)D��
'�
'�
'�s"�B�;B�1	B�
B	�B�
B,c��URc&[UR55nURnO%[UR	55nUR
n[RSnUVs/sH
oD"U5PM snU/-nUVs/sH	ofcMUPM snUl[RR5n[U5H�unun	n
nnn
nnU(a$SUSS4nSUSS4nSU
SS4n
SUSS4nSn
SnURRU	5nUR[!S5U[#U55 UR%UX�X�US9 U
(aUR'UUU	5nOSnUR)UUUUUS9 M� SSS5 URR+5 UR-5 gs snfs snf!,(df   NC=f)Nr)rTF�Preparing file merge)�resolver�
unmodified)r�r�	_entries3�
_three_way�_entries_lca�_lca_multi_wayr�r�active_hooks�ui�
ui_factory�nested_progress_bar�	enumeraterx�trans_id_file_idr(r_r�_merge_names�_do_merge_contents�_merge_executable�fixup_new_roots�_finish_computing_transform)r2�entriesr��	factories�factoryrrS�child_pb�num�file_id�changed�paths3�parents3�names3�executable3�copiedrz�file_statuss                  rry�Merge3Merger._compute_transformUs����?�?�"��4�>�>�+�,�G����H��4�,�,�.�/�G��*�*�H��L�L�!5�6�	�.7�8�i�7����i�8�D�6�A��.3�H�e�d�T�e�H���
�]�]�
.�
.�
0�H��7�#������������"�F�1�I�t�4�F� $�h�q�k�4�8�H�"�F�1�I�t�4�F�#'��Q���">�K�"�G�"�F��7�7�3�3�G�<������(>� ?��c�'�l�S��!�!��g�x�(�"���"&�"9�"9�&�(�G�"T�K�".�K��&�&��H�k�;��'��'$�1�>	
�����!��(�(�*��E9��H�
0�
0�s�0G�G�G�CG
�

Gc��^�[RR5n[R"TR
UU4Sj5nSSS5 TRb:SSKJn URTR
R5TR5 TRW5 TRH(n[R"SUR55 M* g!,(df   N�=f)z_Finalize the transform and report the changes.

This is the second half of _compute_transform.
c�F>�[R"XTR5$ri)r�
conflict_passr�)r.�cr2s  �r�<lambda>�:Merge3Merger._finish_computing_transform.<locals>.<lambda>�s���Y�4�4�Q�4�?�?�KrNr)�deltaz%s)r�r�r�r�resolve_conflictsrxr��breezyr��report_changes�iter_changes�cook_conflictsr\r
r��describe)r2r��fs_conflictsr�rrs`    rr��(Merge3Merger._finish_computing_transform�s����
�]�]�
.�
.�
0�H�$�6�6�����K��L�1����+�$�� � ����!5�!5�!7��9M�9M�N����L�)��-�-�H��M�M�$�� 1� 1� 3�4�.�1�
0�s�'C � 
C.c#�# �URRURURUR/S9nURRURUR/S9n[
URRUS95nUGH/nURSb:[R"URURURS5nO9[R"URURURS5nURU5nUb%URnURnURn	OSnSnSn	URU4-n
URU4-nURU4-nURU	4-n
URUR UU
UU
UR"4v� GM2 g7f)a�Gather data about files modified between three trees.

Return a list of tuples of file_id, changed, parents3, names3,
executable3.  changed is a boolean indicating whether the file contents
or kind were changed.  parents3 is a tuple of parent ids for base,
other and this.  names3 is a tuple of names for base, other and this.
executable3 is a tuple of execute-bit values for base, other and this.
)�specific_files�extra_trees)r��r�rNr)r�r�r�rr�find_related_paths_across_trees�dict�iter_entries_by_dir�pathrPrQ�getrkrlrir��changed_contentr�)r2�iterator�this_interesting_files�this_entries�changerc�
this_entry�	this_name�this_parent�this_executabler�r�r�r�s              rr��Merge3Merger._entries3�s�����?�?�/�/��N�N��1�1����(�0�
��
"&���!O�!O��"�"�4�?�?�*;�"P�"
����N�N�.�.�>T�.�U�
���F��{�{�1�~�)�%�8�8��N�N�D�N�N�F�K�K��N��	�&�8�8��O�O�T�^�^�V�[�[��^��	�&�)�)�)�4�J��%�&�O�O�	�(�2�2��",�"7�"7�� �	�"��"&���'�'�;�.�8�H��[�[�I�<�/�F��[�[�I�<�/�F� �+�+��.@�@�K��N�N��*�*������M�M��

�-�s�GGc#�# �URbZURUR/nURUR5 UR
R
URU5nOSnSSKJn U"UR
UR5nUR5GH�upVpxUc[nSnUbXR;aMSn	UH$up�UcM
URU5(dM"Sn	 O U	(aMQ/n/n
UHRup�Uc(UR[5 U
RS5 M0URU5 U
RU
5 MT URRU5n[URRU/S95SnURRU5n[URRU/S95Sn/n/n/n/nUHonURUR$5 URUR&5 URUR(5 URUR*5 Mq UR-UR$U4UR$UR$5nUR-UR&U4UR&UR&5nUR-UR(U4UR(UR(5nSnUS:XGaUR$S:XaUS:Xa	US:XaGMoSnGO�UR$bUR$S	:Xa�S
nU"URU5n[/URU
5VV
s/sHunn
U"UU
5PM nnn
U"URU5nU"UR
U5n UR-UU4U USS9n!UR-UR*U4UR*UR*5n"US:XaUS:XaU!S:Xa	U"S:XaGM`U!S:XaSnO�UR$S:Xa�S
n#U#"UURU5n$[/X�RU
5VVV
s/sHunnn
U#"UUU
5PM n%nnn
U#"UURU5n&U#"XpR
U5n'UR-U$U%4U'U&5n(US:XaUS:Xa	U(S:XaGMU(S:XaSnOFUR$S:XaSnUS:Xa	US:XaGMAO$[1SR3UR$55eUUX�4UU4UR&U4UR&UR&4UR(U4UR(UR(4UR*U4UR*UR*4S4v� GM� g![ R"a Sn[nGNf=f![ R"a [nSnGN�f=fs sn
nfs sn
nnf7f)a�Gather data about files modified between multiple trees.

This compares OTHER versus all LCA trees, and for interesting entries,
it then compares with THIS and BASE.

For the multi-valued entries, the format will be (BASE, [lca1, lca2])

:return: [(file_id, changed, paths, parents, names, executable, copied)], where:

    * file_id: Simple file_id of the entry
    * changed: Boolean, True if the kind or contents changed else False
    * paths: ((base, [path, in, lcas]), path_other, path_this)
    * parents: ((base, [parent_id, in, lcas]), parent_id_other,
                parent_id_this)
    * names:   ((base, [name, in, lcas]), name_in_other, name_in_this)
    * executable: ((base, [exec, in, lcas]), exec_in_other,
                exec_in_this)
Nr)�MultiWalkerFTr�rq�	directoryrc�b�UcgURU5$![Ra gf=fri��
get_file_sha1�_mod_transport�
NoSuchFile�rr�s  r�get_sha1�+Merge3Merger._entries_lca.<locals>.get_sha1Cs8���<�#'�(�#'�#5�#5�d�#;�;��-�8�8�(�#'�(�s��.�.��allow_overriding_lca�symlinkc�F�URS:wagURU5$)Nr�)rj�get_symlink_target)�ierr�s   r�
get_target�-Merge3Merger._entries_lca.<locals>.get_targetjs"���7�7�i�/�#'�#�6�6�t�<�<rztree-referencezunhandled kind: {})rrr��extendr�r�r��multiwalkerr��iter_all�_none_entryrgr�id2path�nextr�r�NoSuchIdrjrlrkrir��zip�AssertionErrorr$))r2�lookup_treesrr��walkerryr��other_ie�
lca_valuesrg�lca_pathr��lca_entries�	lca_paths�lca_ierx�base_ierc�this_ie�	lca_kinds�lca_parent_ids�	lca_names�lca_executable�kind_winner�parent_id_winner�name_winner�content_changedr��	base_sha1r�	lca_sha1s�	this_sha1�
other_sha1�sha1_winner�exec_winnerr��base_target�lca_targets�this_target�other_target�
target_winners)                                         rr��Merge3Merger._entries_lca�s����&�!�!�-� �N�N�D�N�N�;�L�������0� $��� O� O��&�&��!��!%��,��T�_�_�d�o�o�>��9?���9J�5�J����&��!�
� �,��1T��"�M� *����>�h�&<�&<�R�&@�&@�$(�M��!+����K��I�$.� ���>��&�&�{�3��$�$�T�*��&�&�v�.��$�$�X�.�
%/�
� �N�N�2�2�7�;�	�
��N�N�6�6�y�k�6�R�����
� �N�N�2�2�7�;�	�
��N�N�6�6�y�k�6�R������I��N��I��N�%��� � ����-��%�%�f�&6�&6�7�� � ����-��%�%�f�&7�&7�8�	&��-�-����y�)�8�=�=�'�,�,��K� $�2�2��"�"�N�3��"�"��!�!� ��
�-�-����y�)�8�=�=�'�,�,��K�#�O��f�$��=�=�K�/�'�6�1�k�V�6K� �&+�O��]�]�*�h�m�m�v�.E�(�!)����� C�I�/2�$�/�/�9�.M�!�.M�N�D�(�!��x�0�.M��!�!)����� C�I�!)�$�/�/�:�!F�J�"&�"5�"5�"�I�.�"�!�-2�	#6�#�K�#'�"5�"5� �+�+�^�<� �+�+��*�*�#�K�)�F�2�'�6�1�'�6�1�'�6�1�!�"�f�,�*/����]�]�i�/�=�
#-�W�d�n�n�i�"P�K�36�'���)�3�#�3�.�B��h�#�2�t�X�6�3� �#�#-�W�d�n�n�i�"P�K�#-�h����#T�L�$(�$7�$7�$�k�2�L�+�%�M�)�F�2�'�6�1�)�V�3�!�$��.�*/����]�]�&6�6�',�O�'�6�1�k�V�6K� ��(�)=�)D�)D�X�]�]�)S�T�T����'��Y�?��&�&��7��&�&��%�%��
�,�,�	�*�H�M�M�7�<�<�H��'�'��8��'�'��&�&���#�
�K:K��J�?�?�
&� �	�%��
&���?�?�
!�%�� �	�
!��b!��H#�sv�CW�	W�!A+W�
V�(&W�V&�*F4W�W	�4CW�	W
�!D"W�V#�W�"V#�#W�&W�W�W�Wc�f�URR5(dg0nURHdnURRU5nURR	U5(dM@URRU5nUcM`XRU'Mf URR
U5 gri)r7�supports_merge_modified�modified_pathsrT�is_versionedr��set_merge_modified)r2r~�modified_hashesr��
wt_relpath�hashs      rr{�Merge3Merger.write_modified�s���� � �8�8�:�:�����*�*�D��*�*�2�2�4�8�J��$�$�1�1�*�=�=���$�$�2�2�:�>�D��|��*.�J�'�+�	
���,�,�_�=rc�"�UcgUR$)z:Determine the parent for a file_id (used as a key method).N)rl��entrys r�parent�Merge3Merger.parent�s���=�����rc�"�UcgUR$)z8Determine the name for a file_id (used as a key method).N)rkrs rrk�Merge3Merger.name�s���=���z�z�rc�Z�URU5$![Ra gf=f)z?Determine the sha1 of the file contents (used as a key method).Nr�r�s  r�
contents_sha1�Merge3Merger.contents_sha1�s0��	��%�%�d�+�+���(�(�	��	����*�*c��URU5S:wagURU5$![Ra gf=f)z@Determine the executability of a file-id (used as a key method).rFN)rjr�r��
is_executabler�s  rri�Merge3Merger.executable�sL��	��y�y���&�(��)��!�!�$�'�'���(�(�	��	�s�*�A�Ac�Z�URU5$![Ra gf=f)z7Determine the kind of a file-id (used as a key method).N)rjr�r�r�s  rrj�Merge3Merger.kind�s-��	��9�9�T�?�"���(�(�	��	�rc�,�X:XagX U4;agX!:Xagg)NrqrrrJr)r�rJrqs   rr��Merge3Merger._three_way�s&���=��
���
&��
�]��rc�L�X:XagUupEUVs/sHofU:wdM
UPM nn[U5S:Xa[RXAU5$[U5n[U5S:Xa$[RUR	5X5$U(aX;aX(;aggX(;aggs snf)aBConsider LCAs when determining whether a change has occurred.

If LCAS are all identical, this is the same as a _three_way comparison.

:param bases: value in (BASE, [LCAS])
:param other: value in OTHER
:param this: value in THIS
:param allow_overriding_lca: If there is more than one unique lca
    value, allow OTHER to override THIS if it has a new value, and
    THIS only has an lca value, or vice versa. This is appropriate for
    truly scalar values, not as much for non-scalars.
:return: 'this', 'other', or 'conflict' depending on whether an entry
    changed or not.
rqrrrrrJ)rrpr�r%r))	�basesrJrqr��base_val�lca_vals�lca_val�filtered_lca_vals�unique_lca_valss	         rr��Merge3Merger._lca_multi_way�s���$�=��"���4<�T�H��8�@S�W�H��T�� �!�Q�&��*�*�8�D�A�A��/�0�����1�$��*�*�?�+>�+>�+@�%�N�N���'��*�%�"��(����/Us
�	B!�B!c	�F�Uupxn	Uup�nUup�nU"U6nU"U6nU	cUS:XaSnUS:XaSnUS:XaUS:XagUS:XdUS:Xa"URRSUUUU	UU45 UcgX@RUnXPRUnUcUb�UcRUbOXPRUS:wa)[SR	XPRU55e[
RnOURRU5nURRUUU5 gg)z*Perform a merge on file names and parents.NrqrJrrz
path conflict�z$File looks like a root, but named {})
rtr�
winner_idxr�r$r�ROOT_PARENTrxr��adjust_path)r2rzr�rw�parents�namesr��	base_name�
other_namer��base_parent�other_parentr��unused_base_pathryrcr�r�rlrk�parent_trans_ids                     rr��Merge3Merger._merge_namessp��+0�(�	�y�18�.��;�27�/��i���&��#�W�-�����f�$�%���6�)�#*� ��&� �%5��%?���*�$�(8�J�(F�
���&�&�#����� ���

���
��O�O�,<�=�>�	��_�_�[�1�2��� �D�$4�� �T�%5����)9�:�;�r�A�(�>�E�E�!�/�/�2B�"C�D����
#,�"7�"7��"&�'�'�":�":�9�"E���G�G����o�x�@�%5rc	���SnUupVnU"URU5nU"URU5n	UR(a[UupZU"URU5n[	URU
5VV
s/sH
up�U"X�5PM nnn
URX�4UU	SS9nO@U"URU5nX�:XaSnO%U"URU5n	UR
X�U	5nUS:Xag[UXVU4UU	SUSU5nURnSnUHnURU5unnUS:wdM O SnSnUS:XGavS	nURRU5nURRU5nSnURcyURRU5(aXS
nURRX#S9 [ R""URUURUUR%U5S9 S
nO1UR&c$URRU5(aS
nS
nU(d}URbURR)U5 UR+UXVU4U5nUHnURRUUS9  O UR,R/S
U45 O�US:XaURR1WU5 O�US:Xa�URR1WU5 UR,R/SU45 URRU5nURRU5nUR+UXVU4U5 OEUS:XaURR)U5 SnO!US:XaO[3SR5U55eU(dUS:XaURRX#S9 U(dURR7U5 U$s sn
nf)z%Performs a merge on file_id contents.c���UcgURU5nUS:XaURU5nX#4$US:XaUR	U5nX#4$SnX#4$![Ra gf=f)N�NNrr�)rjr�r�r�r�)rr�rj�contentss    r�
contents_pair�6Merge3Merger._do_merge_contents.<locals>.contents_pairUs����|�#�
$��y�y�����v�~��-�-�d�3��
�>�!�	��"��2�2�4�8���>�!� ���>�!��"�,�,�
$�#�
$�s�A�A'�&A'Fr�rqr�rrL�modifiedNT)r���filter_tree_pathzcontents conflict�success�
conflicted�
text conflict�delete�deleted�donezunknown hook_status: {!r})r�rr�r�r�r�r�rsr�r=rx�
final_name�final_parentr{r�version_filer�create_from_tree�_get_filter_tree_pathr|�unversion_file�_dump_conflictsrtr�create_filer�r$�delete_contents)r2rwrzr�r6rxryrc�
other_pair�	this_pairr��	base_pairrr��	lca_pairsrMrGr�hook_statusrS�lines�	keep_this�resultrkrl�inhibit_content_conflict�
file_group�tids                            rr��Merge3Merger._do_merge_contentsRs���
	"�,1�(�	�y�#�4�?�?�J�?�
�!�$�.�.�)�<�	��?�?�%.�"�Y�%�d�n�n�i�@�I�#&�d�o�o�y�"A��"A�J�D��d�)�"A�
���(�(��&���%*�	)��F�&�d�n�n�i�@�I��&���*�$�.�.�)�D�	�����	�J���V���%��
�I�.���a�L��q�M��

���!�!��&���D�!%�!4�!4�V�!<��K���.�.��	��	����*�*��F��7�7�%�%�h�/�D����,�,�X�6�I�',�$����'��>�>�.�.�z�:�:� $�I��G�G�(�(��(�C��.�.���� ����"�)-�)C�)C�J�)O��04�,���"�"�*��?�?�/�/�	�:�:�!%�I�/3�,�+��#�#�/��G�G�*�*�8�4�"�1�1��9�)�<�i��
�&�C��G�G�(�(��g�(�>��&��#�#�*�*�,?��+L�M��
�I�
%��G�G����x�0�
�L�
(�
�G�G����x�0����&�&���'B�C��7�7�%�%�h�/�D����,�,�X�6�I�� � ��	�y�'I�9�U�
�H�
$��G�G�"�"�8�,��F�
�F�
"�
� �!<�!C�!C�K�!P�Q�Q��V�z�1��G�G� � �� �;��
�G�G�#�#�H�-��
��gs�0O+c	�8�URnURbP[R"URUUR
URUR
UR5S9 gURbg[SRUR55e)z!Replace this contents with other.r9�r@N)r>Nz8winner is OTHER, but file {!r} not in THIS or OTHER tree)rzryrrDrxr�rErcr�r$rx)r2�merge_hook_paramsrzs   r�_default_other_winner_merge�(Merge3Merger._default_other_winner_merge�s���$�-�-���'�'�3��&�&��������!�,�,�!%�!;�!;�%�0�0�"�
� �
�
(�
(�
4�!� �J�Q�Q�%�/�/���
rc���URS:XaURU5$UR5(a(URURUR
5 gg![Ra gf=f)z0Fallback merge logic after user installed hooks.rJrKrW)rMrYrN�
text_mergerzrwr�
BinaryFile)r2rXs  rr=�Merge3Merger.merge_contents�sv��
�#�#�w�.��3�3�4E�F�F�
�
,�
,�
.�
.�
.���� 1� :� :�<M�<S�<S�T� �)��	�$�$�
.�-�
.�s�&A � A7�6A7c��Uc/$URU5nUS:wa/$URU5$![Ra /s$f=f)z-Return the lines in a file, or an empty list.r)rj�get_file_linesr�r�)r2rr�rjs    rr��Merge3Merger.get_linessY���<��I�	-��9�9�T�?�D��v�~��	��&�&�t�,�,���(�(�	��I�	�s�1�A
�	A
c�^^^^�SSKJn UupEnTRTRU5nTRTRU5nTRTR
U5n	[RU5 [RU5 [RU	5 U"UU	UTR[RS9mSmTRSLaSmOSmUUUU4Sjn
0nU
"U5nTRRX�5 US	SLawTRRS
U45 TRR!U5n
TRR#U5nTR%X�X�X�4S9nURU5 gg)z)Perform a three-way text merge on a file.r)�Merge3)�
is_cherrypick�sequence_matchers.!START OF MERGE CONFLICT!I HOPE THIS IS UNIQUETs|||||||Nc3�&># �SUS'T(aTR(a
[5e[TRSSSTTTRS95nUH8nUR	T5(aSUS'URTS5v� M4Uv� M: g7f)	NF�text_conflictssTREEsMERGE-SOURCEs
BASE-REVISION)�name_a�name_b�	name_base�start_marker�base_markerr�Ts<<<<<<<)r�rr�merge_lines�
startswith�replace)�retvalrO�linerl�m3r2rks   ����r�iter_merge3�,Merge3Merger.text_merge.<locals>.iter_merge36s�����',�F�#�$��t�~�~�.�0�0�����"�*�.�!-� +�"�n�n�
��	�E����?�?�<�0�0�/3�F�+�,��,�,�|�X�>�>��J��s�BBrgr=)rO)�merge3rcr�r�r�r�textfile�check_text_linesr:�patiencediff�PatienceSequenceMatcherr�rxrHrtrrArBrG)r2rzrwrcrxryrcr�r�r�rsrp�merge3_iteratorrkrlrSrlrrrks`               @@@rr\�Merge3Merger.text_mergesi���!�,1�(�	�y��^�^�D�N�N�I�>�
��n�n�T�_�_�j�A���^�^�D�N�N�I�>�
��!�!�*�-��!�!�+�.��!�!�*�-�
�����/�/�)�A�A�
��O���>�>�T�!�"�K��K�	�	�*��%�f�-�������O�6��"�#�t�+����&�&���'B�C��7�7�%�%�h�/�D����,�,�X�6�I��-�-��Y�;�.S�.��J�
���h�'�,rc��URR5(a3[R"URUR
U5nUcUnU$gri)r�supports_content_filteringrPrQr�r7)r2r��filter_paths   rrE�"Merge3Merger._get_filter_tree_pathWsN���>�>�4�4�6�6�
$�6�6�����!2�!2�D��K��"�"����rc
�x�UupgnU(aUup�nOS=n	=p�SURXz4SURX�4/nU(dURSURXi45 URR	5(aUn
OSn
/nUH3unnnnUcM
URXUUX�U
5nURU5 M5 U$)z�Emit conflict files.
If this_lines, base_lines, or other_lines are omitted, they will be
determined automatically.  If set_version is true, the .OTHER, .THIS
or .BASE (in that order) will be created as versioned files.
N�OTHER�THIS�BASE)r�rrr�r}�_conflict_file)r2rkrwrlrO�no_baserxryrcr�r�r��datar:rS�suffixrr�rzs                   rrG�Merge3Merger._dump_conflictsfs���,1�(�	�y��27�/�J�Z�48�8�J�8��
�d�o�o�z�?�
�T�^�^�Y�;�
����K�K������G�H��>�>�4�4�6�6�(��#���
�)-�%�F�D�$�����.�.��T�4��@P����!�!�(�+�*.��rc	��US-U-nURRX5n[R"URUUUUUS9 U$)zEmit a single conflict file.�.)�chunksr:)rx�create_pathrrD)	r2rkrlr�rr�rOr:rzs	         rr��Merge3Merger._conflict_file�sQ���c�z�F�"���7�7�&�&�t�7���"�"��G�G�����-�
	
��rc��UupgnUup�nUS:XagU"U6nUS:XaU
cSnOSnUS:XaUS:wagURRU5S:wagUS:XaUn
OU
bUn
OUbUn
OU	bUn
W
bURRX�5 gg)z#Perform a merge on the execute bit.r?NrrrqrJr8r)rx�
final_kind�set_executability)r2rwrzrir�r��base_executable�other_executabler�rxryrcrM�
executabilitys              rr��Merge3Merger._merge_executable�s���=G�:��?�+0�(�	�y��)�#���:�&���Z���!��� ���V���z� 9���7�7���h�'�6�1���V��+�M��%� 0�
��&� /�
��&� /�
��$��G�G�%�%�m�>�%rc��[URR[U5UR-55Ulg)zBConvert all conflicts into a form that doesn't depend on trans_id.N)rrxr�rtr\)r2r�s  rr��Merge3Merger.cook_conflicts�s1�� $��G�G�"�"�4��#5��8K�8K�#K�L�!
��r)r�rtr�r�r�r:r\rr�r�r�r�r`rrxr7)	FFNNTFNNN)Tr�r4)*rrrrr?r=r>r@�
history_basedrCr9r&r;�requires_file_merge_planr/r8r�ryr�r�r�r{rbr
rkrrirjr�r�r�r�rYr=r�r\rErGr�r�r�rrrrrprp�sZ��<��M������M���"&���a�Q�7�J���$�����������=�~� �,+�\5�&4�lW�r>��������������(��(������
��
��.��.�`4A�lN�`�2*�(-�9(�v
��DQU�� ?�<
rrpc�>�\rSrSrSrSrSrSrSrSr	Sr
SrSrSr
g	)
�WeaveMergeri�z)Three-way tree merger, text weave merger.TFc�J�URRXRUS9$�N)r�)r�plan_file_merger��r2rcr�s   r�_generate_merge_plan� WeaveMerger._generate_merge_plan�s ���~�~�-�-�i���t�-�T�Trc�0�SSKJn UR(a
URnOSnUR	X5nS[
R;a�[U5nURR[5nURRU5S-nSU5nURRX`RRU5U5 U"USS5nURUR5up�U
(aUR!5nX�4$SnX�4$)	zrGenerate the merged lines.
There is no distinction between lines that are meant to contain <<<<<<<
and conflicts.
r)�PlanWeaveMergeNrRz.planc3�,# �UH
nSU-v� M g7f)s%11s|%sNr)�.0�ls  r�	<genexpr>�,WeaveMerger._merged_lines.<locals>.<genexpr>�s���5��1�
�Q���s�s
<<<<<<< TREE
s>>>>>>> MERGE-SOURCE
)�bzr.versionedfiler�r:r�r��debug�debug_flagsrrxr�r�rA�new_filerBrmr��base_from_plan)r2rcr�r��planrzrkr5�	textmergerO�	conflictsr�s            r�
_merged_lines�WeaveMerger._merged_lines�s���
	6��?�?��>�>�D��D��(�(��9���e�'�'�'���:�D��w�w�/�/��8�H��7�7�%�%�h�/�'�9�D�5��5�H��G�G���T�7�7�#7�#7��#A�8�L�"�4�):�<U�V�	�$�0�0����@����"�1�1�3�J�� � ��J�� � rc��Uup4nURU5upg[U5n[RU5 URRXa5 UbyURRSU45 URRU5nURRU5n	URX�X�SS4SS9n
U
RU5 gg)z�Perform a (weave) text merge for a given file and file-id.
If conflicts are encountered, .THIS and .OTHER files will be emitted,
and a conflict will be noted.
Nr=F)r�)r�rrvrwrxrHrtrrArBrG)r2rzrwrxryrcrOr�rkrlrSs           rr\�WeaveMerger.text_merge�s���
,1�(�	�y� �.�.�y�9����U���	�!�!�%�(������E�,��!����&�&���'B�C��7�7�%�%�h�/�D����,�,�X�6�I��-�-��Y�T�4�(@�%�.��J�
���h�'�"rrN)rrrrr?r>r@r9r�r�r�r�r\rrrrr�r��s2��3�����"'���M�#��U�!�4(rr�c��\rSrSrSrSrSrg)�	LCAMergeri�Tc�J�URRXRUS9$r�)r�plan_file_lca_merger�r�s   rr��LCAMerger._generate_merge_plan�s!���~�~�1�1�)�_�_�SW�1�X�XrrN)rrrrr�r�rrrrr�r��s��#��Yrr�c�(�\rSrSrSrSrSrSrSrg)�Diff3Mergeriz7Three-way merger using external diff3 for text merging.Fc���[R"X5n[US5nURU5nUHnUR	U5 M SSS5 U$!,(df   U$=f)N�wb)r�pathjoin�open�get_file�write)	r2�temp_dirrkrr��out_path�out_file�in_filerqs	         r�	dump_file�Diff3Merger.dump_files^���#�#�H�3��
�(�D�
!�X��m�m�D�)�G������t�$� �"���	"�
!���s�,A�
A(c��SSKnUupEn[R"SS9n[R"US5nURUSURU5n	URUSURU5n
URUSURU5nURRX�X�5nUS	;a[R"S
5e[US5n
URRX�5 SSS5 US:XaeURR!U5nURR#U5nUR%X�U5 UR&R)S
U45 SSS5 g!,(df   N�=f!,(df   g=f)z�Perform a diff3 merge using a specified file-id and trans-id.
If conflicts are encountered, .BASE, .THIS. and .OTHER conflict files
will be dumped, and a will be conflict noted.
rNzbzr-)�prefix�newrqr�rJ)rrzUnhandled diff3 exit code�rbrr=)�breezy.patch�tempfile�TemporaryDirectoryrr�r�rr�r��patch�diff3rr?r�rxrHrArBrGrtr)r2rzrwr�rxryrcr�r�rqr�rJ�status�frkrls                rr\�Diff3Merger.text_merge
s>��
	�+0�(�	�y�
�
(�
(��
7�8��'�'��%�8�H��>�>�(�F�D�N�N�I�N�D��>�>�(�F�D�N�N�I�N�D��N�N�8�W�d�o�o�z�R�E��\�\�'�'���D�F��V�#��o�o�&A�B�B��h��%�����#�#�A�0�&���{��w�w�)�)�(�3�� �G�G�0�0��:�	��$�$�T�)�<��#�#�*�*�O�X�+F�G�8�
7�&�%��8�
7�s%�B6E=�E,�0A3E=�,
E:	�6E=�=
FrN)	rrrrr?r�r�r\rrrrr�r�s��A�$���Hrr�c��\rSrSrSrSrSrg)�
PathNotInTreei&z=Merge-into failed because %(tree)s does not contain %(path)s.c�@�[RRXUS9 g)N)r�r)rr?r/)r2r�rs   rr/�PathNotInTree.__init__)s����� � ��t� �<rrN)rrrrrr/rrrrr�r�&s��N�D�=rr�c�8^�\rSrSrSrSU4SjjrSrSrU=r$)�MergeIntoMergeri-z�Merger that understands other_tree will be merged into a subdir.

This also changes the Merger api so that it uses real Branch, revision_id,
and RevisonTree objects, rather than using revision specs.
c�6>�URRR[R5n[
TU]URUUUS9 X@lXPlX l	UcUR5nU=UlUlSUl
SUl[UlSUlSUlSUl[)[*URURS9UlURS:wa2UR-URUR.UR5 gg)a�Create a new MergeIntoMerger object.

source_subpath in other_tree will be effectively copied to
target_subdir in this_tree.

:param this_tree: The tree that we will be merging into.
:param other_branch: The Branch we will be merging from.
:param other_tree: The RevisionTree object we want to merge.
:param target_subdir: The relative path where we want to merge
    other_tree into this_tree
:param source_subpath: The relative path specifying the subtree of
    other_tree to merge into this_tree.
)r`rr�r�NTF)�
target_subdir�source_subpathr%)r!r�r�r�r�rXr/�_target_subdir�_source_subpathr�r�r�r�r�r�rpr�r�r�r�_MergeTypeParameterizer�MergeIntoMergeTyperr`)	r2rr�r�r�r�r��null_ancestor_treerZs	        �rr/�MergeIntoMerger.__init__4s���0'�-�-�8�8�F�F��'�'�
��	���!�(�(��!�(�		�	
�,��-��(����%�5�5�7�L�/;�;���D�,� $��� ���&���������!%���1���-�-��/�/�
���
���2�%�
���d�/�/��1A�1A�4�CS�CS�T�&rc�P�URS:wag[RU5 g)Nr%)r�r�r�r1s rr��MergeIntoMerger.set_pendingks!�����2�%�����4� r)r�r�r�r�rr�r�r�r�r�r�ri)	rrrrr?r/r�rrprqs@rr�r�-s�����5U�n!�!rr�c�*�\rSrSrSrSrSrSrSrg)r�iqaqWrap a merge-type class to provide extra parameters.

This is hack used by MergeIntoMerger to pass some extra parameters to its
merge_type.  Merger.do_merge() sets up its own set of parameters to pass to
the 'merge_type' member.  It is difficult override do_merge without
re-writing the whole thing, so instead we create a wrapper which will pass
the extra parameters.
c��X lXlgri��
_extra_kwargs�_merge_type)r2r�rDs   rr/� _MergeTypeParameterizer.__init__{s��#��%�rc�\�URUR5 UR"U0UD6$ri)r(r�r�)r2�argsrDs   r�__call__� _MergeTypeParameterizer.__call__s*���
�
�d�(�(�)�����0��0�0rc�.�[URU5$ri)rAr�)r2rks  r�__getattr__�#_MergeTypeParameterizer.__getattr__�s���t�'�'��.�.rr�N)	rrrrr?r/r�r�rrrrr�r�qs���&�1�/rr�c�8^�\rSrSrSrU4SjrSrSrSrU=r	$)r�i�zAMerger that incorporates a tree (or part of a tree) into another.c�~>�URS5UlURS5Ul[TU]"U0UD6 g)a�Initialize the merger object.

:param args: See Merge3Merger.__init__'s args.
:param kwargs: See Merge3Merger.__init__'s keyword args, except for
    source_subpath and target_subdir.
:keyword source_subpath: The relative path specifying the subtree of
    other_tree to merge into this_tree.
:keyword target_subdir: The relative path where we want to merge
    other_tree into this_tree
r�r�N)r)r�r�rXr/)r2r�rDrZs   �rr/�MergeIntoMergeType.__init__�s:��� &�z�z�*:�;���$�j�j��9���
���$�)�&�)rc	��[RR5nUR5n[	U5n[U5H�unupEnUR
[S5U[U55 URRU5n[R"URU5n[R"X�RXGUR 5 M� SSS5 UR#5 g!,(df   N=f)Nr�)r�r�r��_entries_to_incorporaterr�r(r_rrxr�rr�r�r�new_by_entryr�r�)	r2r�r�r�rrlrTr0r�s	         rry�%MergeIntoMergeType._compute_transform�s���
�]�]�
.�
.�
0�H��2�2�4�G��7�m�G�4=�g�4F�0��0�e������(>� ?��c�'�l�S�"&�'�'�":�":�9�"E���'�'��(<�(<�g�F���&�&��'�'�5�4�?�?��	5G�1�	
�(�(�*�1�
0�s�CC9�9
Dc#�# �URRUR5nUc[URS5e[	URRUR/S95Sn[R"UR5nURRU5nUc[URS5e[R"UR5nUR5nXVlURRUR5 [R!U5UlXdS4v� UR&S:wagURR(RU5H2upxUR*n	X�R:XaURn	X�U4v� M4 g!["R$a N�f=f7f)z.Yields pairs of (inventory_entry, new_parent).NzSource treer�rzTarget treer%r�)r��path2idr�r�r�r�r�dirnamer�r�basename�copyrkr�r��generate_ids�gen_file_idrr�rj�root_inventoryrl)
r2�	subdir_id�subdir�parent_in_target�	target_id�name_in_target�merge_into_rootr�rrls
          rr��*MergeIntoMergeType._entries_to_incorporate�s�����O�O�+�+�D�,@�,@�A�	��� �� 4� 4�m�D�D���O�O�/�/��@T�@T�?U�/�V�
�
�
��#�?�?�4�+>�+>�?���N�N�*�*�+;�<�	����� 3� 3�]�C�C� �)�)�$�*=�*=�>�� �+�+�-��-��
	O��N�N�"�"�?�#:�#:�;�'3�&>�&>�~�&N�O�#��2�.�.��;�;�+�%���?�?�9�9�M�M��
�K�D����I��N�N�*�,�3�3�	��T�*�*�
��!���	��	�s+�C9G�<%F.�!B
G�.G�G�G�G)r�r�)
rrrrr?r/ryr�rrprqs@rr�r��s���K�*�"+�++�++rr�Fc�Z�U
c[R"S5e[UUUU
US9nXLlX\lX<lX�lXllX|lX�l	X�l
[USS5n
U
cURn
URXU
/5 URU
"5U5 UR5$)z�Primary interface for merging.

Typical use is probably::

    merge_inner(branch, branch.get_revision_tree(other_revision),
                branch.get_revision_tree(base_revision))
Nz7breezy.merge.merge_inner requires a this_tree parameter)rr�r�)rr?r�r�r�rrr�r�r�r�rAr�r�r�r8)r`r�r�rr�r�r�r�r�rrr�r9r�s              rr r �s���*���o�o�W�X�X�
�����'��F�'��"��$��0�� �� ��&��%���i�):�D�A�O���#�1�1��
�(�(�*��)K�L�
���_�.��<��?�?��rr�zMerge using external diff3.�lcazLCA-newness merge.ruzNative diff3-style merge.�weavezWeave-based merge.c��[$)zvMerge type registry was previously in breezy.option.

This method provides a backwards compatible way to retrieve it.
)�merge_type_registryrrr�get_merge_type_registryrs
��
�rc#�^^# �U4SjnU4SjnUVVs/sHupgUPM	 nnnUVVs/sHupgUPM	 n	nn[RSX�5n
U
R5nSnSn
UHSup�nXUHunnU"UU5v� M XUHunnU"UU5v� M UU-nUU-n
X�UH	nSU4v� M MU gs snnfs snnf7f)Nc� >�UT;aSU4$SU4$)N�killed-b�new-ar)r�text�ancestors_bs  �r�status_a�&_plan_annotate_merge.<locals>.status_a� ����{�"��t�#�#��D�=� rc� >�UT;aSU4$SU4$)N�killed-a�new-br)rr�ancestors_as  �r�status_b�&_plan_annotate_merge.<locals>.status_brrr�	unchanged)rxry�get_matching_blocks)�annotated_a�annotated_brrrr�ar.�plain_a�plain_b�matcher�blocks�a_cur�b_cur�ai�bir�rr�text_as  ``                r�_plan_annotate_merger*s�����!�!� +�+�{�V�a�q�{�G�+�*�+�{�V�a�q�{�G�+��2�2�4��J�G�
�
(�
(�
*�F�
�E�
�E��	���*��3�N�H�d��8�T�*�*�4�)��3�N�H�d��8�T�*�*�4��Q����Q�����'�F��v�%�%�(���
,��+�s�C
�C�C
�C�BC
c�N�\rSrSrSrSrSrSrSrSr	Sr
\S	5rS
r
g)�_PlanMergeBasei5c�~�XlX lX0lSUlSUl0UlX@lUR5 g)z�Contructor.

:param a_rev: Revision-id of one revision to merge
:param b_rev: Revision-id of the other revision to merge
:param vf: A VersionedFiles containing both revisions
:param key_prefix: A prefix for accessing keys in vf, typically
    (file_id,).
N)�a_rev�b_rev�vf�_last_lines�_last_lines_revision_id�_cached_matching_blocks�_key_prefix�_precache_tip_lines)r2r.r/r0�
key_prefixs     rr/�_PlanMergeBase.__init__6s=���
��
������'+��$�')��$�%��� � �"rc��URURUR/5nXRUlXRUlgri)r�r.r/�lines_a�lines_b)r2rOs  rr5�"_PlanMergeBase._precache_tip_linesHs9������
�
�D�J�J�7�8���Z�Z�(����Z�Z�(��rc�P�UVs/sHo RU4-PM nn0nURRUSS5H^nURS:Xa+[R
"URUR5eURS5XERS'M` U$s snf)zgGet lines for revisions from the backing VersionedFiles.

:raises RevisionNotPresent: on absent texts.
�	unorderedT�absentrOr�)r4r0�get_record_stream�storage_kindr�RevisionNotPresentr0�get_bytes_as)r2r*�rev�keysrQ�records      rr��_PlanMergeBase.get_linesMs���
8A�A�y��!�!�S�F�*�y��A����g�g�/�/��k�4�H�F��"�"�h�.��/�/��
�
�D�G�G�D�D�%+�%8�%8��%A�F�:�:�b�>�"�I��
��
Bs�B#c��URURUR5nURU5up#UR	URU5upEUR	URU5upgURXXVU5$)�WGenerate a 'plan' for merging the two revisions.

This involves comparing their texts and determining the cause of
differences.  If text A has a line and text B does not, then either the
line was added to text A, or it was deleted from B.  Once the causes
are combined, they are written out in the format described in
VersionedFile.plan_merge
)�_get_matching_blocksr.r/�
_unique_lines�_determine_status�
_iter_plan)r2r$�unique_a�unique_b�new_a�killed_b�new_b�killed_as        r�
plan_merge�_PlanMergeBase.plan_mergeZst���*�*�4�:�:�t�z�z�B��!�/�/��7����0�0����X�F����0�0����X�F������v�h�x�H�Hrc#��# �SnSnUH�up�n
[Xh5HJnX�;a/X�;aSURU4v� M"SURU4v� M7SURU4v� ML [Xy5HJnX�;a/X�;aSURU4v� M"SURU4v� M7SURU4v� ML [X�U
-5HnSURU4v� M X�-nX�-nM� g7f)	Nrzconflicted-arrzconflicted-brrr)�ranger9r:)
r2r$rOrPrQrR�last_i�last_j�i�j�n�a_index�b_indexs
             rrL�_PlanMergeBase._iter_planis��������G�A�!� ��+���#��*�,�d�l�l�7�.C�C�C�%�t�|�|�G�'<�<�<�$�d�l�l�7�&;�;�;�,�!��+���#��*�,�d�l�l�7�.C�C�C�%�t�|�|�G�'<�<�<�$�d�l�l�7�&;�;�;�,�!���E�?��!�4�<�<��#8�8�8�+��U�F��U�F�+�s�C4C6c�@�URRX45nUbU$URU:Xa"URnUR	U/5UnOUR	X/5nXanXbnXPlX l[
R
SXE5nUR5$)zhReturn a description of which sections of two revisions match.

See SequenceMatcher.get_matching_blocks
N)r3r�r2r1r�rxryr)r2�
left_revision�right_revision�cached�
left_lines�right_linesrOr#s        rrI�#_PlanMergeBase._get_matching_blocks�s���
�-�-�1�1�=�2Q�R�����M��'�'�=�8��)�)�J��.�.�.�)9�:�>�J�K��N�N�M�#B�C�E��-�J��/�K�&��'5�$��6�6�t�Z�U���*�*�,�,rc��SnSn/n/nUHBupgnUR[X&55 UR[X755 Xh-nXx-nMD XE4$)z�Analyse matching_blocks to determine which lines are unique.

:return: a tuple of (unique_left, unique_right), where the values are
    sets of line numbers of unique lines.
r)r�rV)	r2�matching_blocksrWrX�unique_left�unique_rightrYrZr[s	         rrJ�_PlanMergeBase._unique_lines�se����������&�G�A�!����u�V�/�0�����f� 0�1��U�F��U�F�	'�
�(�(rc#� # �[RSX5nSnUR5H^upEn[X55H	nXv� M [XUU-5H*nXnUSS:XaMUSS:XaSUS4v� M&Uv� M, XV-nM` g7f)a�Remove changes from new_plan that came from old_plan.

It is assumed that the difference between the old_plan and new_plan
is their choice of 'b' text.

All lines from new_plan that differ from old_plan are emitted
verbatim.  All lines from new_plan that match old_plan but are
not about the 'b' revision are emitted verbatim.

Lines that match and are about the 'b' revision are the lines we
don't want, so we convert 'killed-b' -> 'unchanged', and 'new-b'
is skipped entirely.
Nrrrrr)rxryrrV)	�old_plan�new_planr#rX�_irZr[�jj�	plan_lines	         r�_subtract_plans�_PlanMergeBase._subtract_plans�s�����6�6�t�X�P�����3�3�5�H�B�1��F�&���l�"�'��A�1�u�o��$�L�	��Q�<�7�*���q�\�Z�/�%�y��|�3�3�#�O�&��U�F�6�s�BB)	r3r4r1r2r.r/r9r:r0N)rrrrr/r5r�rSrLrIrJrbrqrrrrr,r,5s:��#�$)�
�
I��4-�()�"���rr,c�p^�\rSrSrSrU4SjrSrSrSr\	S5r
\	S5rS	rS
r
SrSrU=r$)
�
_PlanMergei�z3Plan an annotate merge using on-the-fly annotation.c�p>�[TU]XX45 URUR4-UlURUR
4-Ul[RUR5Ul
URRURUR45n[U5S:XalUR5UlURUR:XaUnOUn[R "SURURSU5 SUlgSUlUR%5 g)Nrz(found dominating revision for %s
%s > %sr�)rXr/r4r.�a_keyr/�b_key�
_mod_graph�Graphr0rV�headsrr)�	_head_keyr
r#�_weave�_build_weave)r2r.r/r0r6rzrJrZs       �rr/�_PlanMerge.__init__�s����
����r�6��%�%����
�5��
��%�%����
�5��
��%�%�d�g�g�.��
��
�
� � �$�*�*�d�j�j�!9�:���u�:��?�#�Y�Y�[�D�N��~�~����+������L�L�;�������r�"��	
��D�K�!�D�N����rc��grirr1s rr5�_PlanMerge._precache_tip_lines�s��rc��URUR4n0nURR"U6nU[R
1:XaSnUH+n[
URRXC55nXRU'M- [U5S:XaU$[U5S:XaSU[U5S'U$[U5S:�a�[R"SURURU5 Un[U5S:�a*URR"U6n[U5S:�aM*[U5S:XaSnO$[U5SnU[R
:XaSnURURX755 U$UnGMk)z,Find all the ancestors back to a unique lca.rrrr*z=More than 2 LCAs, falling back to all nodes for: %s, %s
=> %sN)rvrwrVrr�r��tupler!rrr
r#r(�_find_unique_parents)r2�
cur_ancestors�
parent_map�	next_lcas�rev_key�ordered_parents�cur_lcas�
unique_lcas        r�_find_recursive_lcas�_PlanMerge._find_recursive_lcas�s������T�Z�Z�0�
��
���
�
�+�+�]�;�I��]�8�8�9�9��	�
)��"'��
�
�(C�(C�G�(W�"X��&5�7�#�)��9�~��"��<��;�Y��1�$�13�
�4�	�?�1�-�.��6��5�Y��!�#����T��J�J��J�J�!�	�%���(�m�a�'�#�z�z�2�2�H�=�H��(�m�a�'��x�=�A�%�!%�J�!%�h���!2�J�!�]�%@�%@�@�
&*�
��!�!�$�";�";�I�"R�S����&�M�Urc��UcX[URRU55n[RU;aUR[R5 O][
5nUH.nURURRXR/55 M0 URRU5nSX2'URU5upgnUb#URU5 URXgU5 [RU5n	U	$)aEFind ancestors of tip that aren't ancestors of base.

:param tip_keys: Nodes that are interesting
:param base_key: Cull all ancestors of this node
:return: The parent map for all revisions between tip_keys and
    base_key. base_key will be included. References to nodes outside of
    the ancestor set will also be removed.
r)r�rV�
iter_ancestryr�r�r)r%r(�find_unique_ancestors�get_parent_map�_remove_external_references�remove�_prune_tailsrx�collapse_linear_regions)
r2�tip_keys�base_keyr��interesting�tip�culled_parent_map�	child_map�tails�
simple_maps
          rr��_PlanMerge._find_unique_parents	s������d�j�j�6�6�x�@�A�J��*�*�j�8����}�:�:�;���%�K����"�"�4�:�:�#C�#C�C��#T�U� ����2�2�;�?�J�#%�J� �.2�.N�.N��/
�+��e����L�L��"����/�E�B��7�7�8I�J�
��rc�4�0n0n/nUR5HvupEUVs/sHofU;dM
UPM nnU(dURU5 UH$nURU/5RU5 M& URU/5 XqU'Mx XU4$s snf)alRemove references that go outside of the parent map.

:param parent_map: Something returned from Graph.get_parent_map(keys)
:return: (filtered_parent_map, child_map, tails)
    filtered_parent_map is parent_map without external references
    child_map is the {parent_key: [child_keys]} mapping
    tails is a list of nodes that do not have any parents in the map
)�itemsr�
setdefault)	r��filtered_parent_mapr�r�r0�parent_keys�p�culled_parent_keys�
parent_keys	         rr��&_PlanMerge._remove_external_references@	s���!���	��� *� 0� 0� 2��C�-8�!L�[���O�!�[��!L�%����S�!�0�
��$�$�Z��4�;�;�C�@�1�
� � ��b�)�'9��$�!3�#�u�4�4��"Ms
�	B�Bc�
�U(a|UR5nURU5 URU5nUH:nXnURU5 [U5S:XdM)URU5 M< U(aM{gg)a�Remove tails from the parent map.

This will remove the supplied revisions until no more children have 0
parents.

:param parent_map: A dict of {child: [parents]}, this dictionary will
    be modified in place.
:param tails_to_remove: A list of tips that should be removed,
    this list will be consumed
:param child_map: The reverse dict of parent_map ({parent: [children]})
    this dict will be modified
:return: None, parent_map will be modified in place.
rN)r)r�rr)r�r��tails_to_remover��children�child�
child_parentss       rr��_PlanMerge._prune_tails]	sq���"�&�&�(�D��N�N�4� � �}�}�T�*�H�!�� *� 1�
��$�$�T�*��}�%��*�#�*�*�5�1�	"�	�orc���[U5nURUR5 URUR5 UR	UVs/sHo3SPM	 sn5nU$s snf)a
Return a dict of texts we are interested in.

Note that the input is in key tuples, but the output is in plain
revision ids.

:param parent_map: The output from _find_recursive_lcas
:return: A dict of {'revision_id':lines} as returned by
    _PlanMergeBase.get_lines()
r�)r%r&rvrwr�)r2r��all_revision_keys�k�	all_textss     r�_get_interesting_texts�!_PlanMerge._get_interesting_textsv	sb�� �
�O�����d�j�j�)����d�j�j�)��N�N�3D�#E�3D�a�b�E�3D�#E�F�	����$Fs�A(c��SSKJn SSKJn UR	SSS9UlUR
5nURU5nUR[R4-nURUR4X5'[U"X555HHupgp�Xu:XaM
X7n
USnU
Vs/sHo�SPM	 n
nUR
RX�XK5 MJ gs snf)Nr)r	)�
merge_sort�in_memory_weaveT)�
weave_name�allow_reservedr�)�bzrr	�tsortr��Weaver|r�r�r4r��CURRENT_REVISIONrvrw�reversed�	add_lines)r2r	r�r�r��tip_key�_seq_numr0�_depth�_eomr�r�r��
parent_idss              rr}�_PlanMerge._build_weave�	s����%��k�k�->�t�k�T����.�.�0�
��/�/�
�;�	��"�"�m�&D�&D�%F�F��#�z�z�4�:�:�6�
��+3�J�z�4S�+T�'�H�6��~��$�/�K��b�'�K�)4�5��A�B�%��J�5��K�K�!�!�+�9�;Q�R�,U��6s�&Cc�^�URb�URUR:XaSmOKURUR:wa/[SR	URUR55eSmURSnURU/5UnU4SjU5$URRURUR5$)rHrz#There was an invalid head: {} != {}rr�c3�,># �UH	nTU4v� M g7frir)r�rqr�s  �rr��(_PlanMerge.plan_merge.<locals>.<genexpr>�	s����3�U�T�T�4�L�U�s�)
r{rvrwr�r$r�r|rSr.r/)r2�head_revrOr�s   @rrS�_PlanMerge.plan_merge�	s�����>�>�%��~�~����+����>�>�T�Z�Z�/�(�=�D�D� �J�J�������
���~�~�b�)�H��N�N�H�:�.�x�8�E�3�U�3�3��{�{�%�%�d�j�j�$�*�*�=�=r)r{r|rvrwrV)rrrrr?r/r5r�r�rbr�r�r�r}rSrrprqs@rrtrt�sY���=� �4
�2�h"�H�5��5�8�2��2�0�$S�8>�>rrtc�$�\rSrSrSrSrSrSrg)�
_PlanLCAMergei�	alLeast Common Ancestor merge plan generator.

This merge algorithm differs from _PlanMerge in that:

1. comparisons are done against LCAs only
2. cases where a contested line is new versus one LCA but old versus
   another are marked as conflicts, by emitting the line as conflicted-a
   or conflicted-b.

This is faster, and hopefully produces more useful output.
c���[RXX#U5 URXA4-XB4-5n[5UlUHRnU[
R:XaURRU5 M4URRUS5 MT URH�n[
R"U5(a/nOURU/5Un[RSURU5n	[U	R55n
X�RX4'[RSUR U5n	[U	R55n
X�RX'4'M� g)Nr�)r,r/rr%r+r�r�r&rr�rxryr9rrr3r:)r2r.r/r0r6rVr+r�	lca_linesr#r$s           rr/�_PlanLCAMerge.__init__�	s.������U�
�C��~�~�j�8�3�Z�(�5J�K���E��	��C��m�1�1�1��	�	�
�
�c�"��	�	�
�
�c�"�g�&�	�
�9�9�C��$�$�S�)�)��	� �N�N�C�5�1�#�6�	�"�:�:��d�l�l�I��G��'�5�5�7�8�F�9?�(�(�%��6�"�:�:��d�l�l�I��G��'�5�5�7�8�F�9?�(�(�%��6�rc�4�[5n[5n[U5nURHgnURX5nURU5upxUR	URU55 UR	UR
U55 Mi X44$)a�Determines the status unique lines versus all lcas.

Basically, determines why the line is unique to this revision.

A line may be determined new, killed, or both.

If a line is determined new, that means it was not present in at least
one LCA, and is not present in the other merge revision.

If a line is determined killed, that means the line was present in
at least one LCA.

If a line is killed and new, this indicates that the two merge
revisions contain differing conflict resolutions.

:param revision_id: The id of the revision in which the lines are
    unique
:param unique_line_numbers: The line numbers of unique lines.
:return: a tuple of (new_this, killed_other)
)r%r+rIrJr(�intersection�
difference)	r2r��unique_line_numbersr��killedrr$�
unique_vs_lca�_ignoreds	         rrK�_PlanLCAMerge._determine_status�	s���*�e�����!�"5�6���9�9�C��.�.�{�@�F�&*�&8�&8��&@�#�M��J�J�*�7�7�
�F�G��M�M�-�8�8��G�H�	�
�{�r)r+N)rrrrr?r/rKrrrrr�r��	s��
�@�2rr�ri)1rr�r�globalsr%rrrrr	r
rrr�r
r�rrPr?rr$r.r&r5rArTrsr�rer�rpr�r�r�r�r�r�r�r �Registryrn�typer�registerrr*r,rtr�rrr�<module>r�s���"��$���I�
��"M�L�L�'�)��
�v����	
�
����
�<(�(�0'7�)�'7�T@3�]�@3�F(P�(P�VJ&�J&�Z��&"�#��F
�F
�R:(�,�:(�zY��Y�#H�,�#H�L=�F�O�O�=�A!�f�A!�H/�/�,L+��L+�f���������+�\�'�'��T�,�-?�(?�@�B�����W�k�3P�Q����U�I�/C�D����X�|�5P�Q����W�k�3G�H��&�DO�O�dt>��t>�nC�N�Cr

Youez - 2016 - github.com/yon3zu
LinuXploit