-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/merge.pyc


zyOc@@sddlmZddlZddlmZeedddlmZmZm	Z	m
Z
ddlmZm
Z
edZde	jfd	YZd
efdYZdefd
YZdefdYZdefdYZdefdYZdefdYZeZdefdYZdefdYZdefdYZdefdYZdejfdYZd efd!YZ d"efd#YZ!d$efd%YZ"e#e#eee#e#eeeeed&Z$e
j%Z&e&j'd'ed(e&j'd)ed*e&j'd+ed,e&j'd-ed.d/Z(d0Z)d1efd2YZ*d3e*fd4YZ+d5e*fd6YZ,dS(7i(tabsolute_importN(tlazy_imports{
from bzrlib import (
    branch as _mod_branch,
    cleanup,
    conflicts as _mod_conflicts,
    debug,
    generate_ids,
    graph as _mod_graph,
    merge3,
    osutils,
    patiencediff,
    revision as _mod_revision,
    textfile,
    trace,
    transform,
    tree as _mod_tree,
    tsort,
    ui,
    versionedfile,
    workingtree,
    )
from bzrlib.i18n import gettext
(t
decoratorsterrorsthookstregistry(t
deprecated_intdeprecated_methodc
C@sU|jtjt}|j|j|j|j||dtd|d|dS(Ntignore_zerotinteresting_idst	this_tree(	tlock_tree_writetcleanuptOperationWithCleanupstmerge_innertadd_cleanuptunlockt
run_simpletbranchtTrue(t	from_treetto_treeR	t	operation((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyttransform_tree:s

t
MergeHookscB@seZdZRS(cC@sStjj|dd|jddd|jddd
|jd
dddS(Nsbzrlib.mergesMerger.hookstmerge_file_contentsCalled with a bzrlib.merge.Merger object to create a per file merge object when starting a merge. Should return either None or a subclass of ``bzrlib.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.iit	pre_mergesGCalled before a merge. Receives a Merger object as the single argument.it
post_mergescCalled after a merge. Receives a Merger object as the single argument. The return value is ignored.(ii(ii(ii(RtHookst__init__tadd_hook(tself((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRDs				(t__name__t
__module__R(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRBstAbstractPerFileMergercB@s eZdZdZdZRS(sPerFileMerger objects are used by plugins extending merge for bzrlib.

    See ``bzrlib.plugins.news_merge.news_merge`` for an example concrete class.
    
    :ivar merger: The Merge3Merger performing the merge.
    cC@s
||_dS(s+Create a PerFileMerger for use with merger.N(tmerger(RR#((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRdscC@sdS(sAttempt to merge the contents of a single file.
        
        :param merge_params: A bzrlib.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.
        snot applicableN(snot applicableN(tNone(Rtmerge_params((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytmerge_contentshs	(R R!t__doc__RR&(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR"\s	t
PerFileMergercB@s;eZdZdZdZdZdZdZRS(sMerge 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.
    cC@st|jdS(sReturn 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.
        N(tNotImplementedErrortfile_matches(Rtparams((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR*{scC@stj|j|jS(sLookup the filename (i.e. basename, not path), given a Tree (e.g.
        self.merger.this_tree) and a MergeFileHookParams.
        (tosutilstbasenametid2pathtfile_id(RR+ttree((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytget_filenamescC@s|j|jS(sCalculate the path to the file in a tree.

        :param params: A MergeFileHookParams describing the file to merge
        :param tree: a Tree, e.g. self.merger.this_tree.
        (R.R/(RR+R0((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytget_filepathscC@s=|jdks,|js,|j|r0dS|j|S(s$Merge the contents of a single file.tothertnot_applicableN(R4N(twinnert
is_file_mergeR*R$tmerge_matching(RR+((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR&s

cC@st|jdS(sMerge 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.
        N(R)R7(RR+((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR7s(R R!R'R*R1R2R&R7(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR(ts					
tConfigurableFileMergercB@s>eZdZdZdZdZdZdZdZ	RS(sfMerge 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 ``bzrlib.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.
    cC@sett|j|d|_|jjp.g|_|jj|_|jdkratdndS(Nsname_prefix must be set.(	tsuperR8RR$taffected_filest	__class__t
default_filestname_prefixt
ValueError(RR#((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs	cC@s|j}|dkrg|jjj}|jd}|j|}|dkr[|j}n||_n|r|j||jj	}||krt
SntS(sCheck whether the file should call the merge hook.

        <name_prefix>_merge_files configuration variable is a list of files
        that should use the hook.
        t_merge_filesN(R:R$R#tthis_brancht
get_configR=tget_user_option_as_listR<R2R
RtFalse(RR+R:tconfigt
config_keytfilepath((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR*s	
cC@s
|j|S(N(t
merge_text(RR+((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR7scC@st|jdS(sMerge 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
        ``bzrlib.merge.AbstractPerFileMerger.merge_contents``.
        N(R)RG(RR+((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRGsN(
R R!R'R$R=R<RR*R7RG(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR8s			tMergeFileHookParamscB@sVeZdZdZdZejdZejdZejdZ	RS(sObject holding parameters passed to merge_file_content hooks.

    There are some fields hooks can access:

    :ivar file_id: the file ID of the file being merged
    :ivar trans_id: the transform ID for the merge of this file
    :ivar this_kind: kind of file_id in 'this' tree
    :ivar other_kind: kind of file_id in 'other' tree
    :ivar winner: one of 'this', 'other', 'conflict'
    cC@s:||_||_||_||_||_||_dS(N(t_mergerR/ttrans_idt	this_kindt
other_kindR5(RR#R/RJRKRLR5((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs					cC@s|jdko|jdkS(s1True if this_kind and other_kind are both 'file'.tfile(RKRL(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR6scC@s|jj|jj|jS(s,The lines of the 'base' version of the file.(RIt	get_linest	base_treeR/(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt
base_linesscC@s|jj|jj|jS(s,The lines of the 'this' version of the file.(RIRNR
R/(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt
this_lines
scC@s|jj|jj|jS(s-The lines of the 'other' version of the file.(RIRNt
other_treeR/(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytother_liness(
R R!R'RR6RtcachedpropertyRPRQRS(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRHs
			tMergercB@sReZeZddddddddZdZedZdZ	dZ
ee
e	ZdZdZ
ee
eZedddZed	Zedddddd
ZddZddZd
ZdZdZddZdZdZdZdZdZdZdZ dZ!RS(tdownc		C@stj|||_tj|j|_d|_||_	d|_
d|_||_d|_
||_t|_t|_d|_d|_t|_t|_|dk	rtjdnd|_||_||_i|_||_d|_d|_d|_d|_ dS(Ns2pb parameter to Merger() is deprecated and ignored(!tobjectRR@t
_mod_revisiontensure_nullt
last_revisiont
this_basisR$tthis_rev_idR
tthis_revision_treetthis_basis_treeRRtother_branchRORCRtbackup_filesR	tinteresting_filest	show_baset	reprocesstwarningstwarntpptrecursetchange_reportert
_cached_treest_revision_grapht_base_is_ancestort_base_is_other_ancestort_is_criss_crosst
_lca_trees(	RR@RRROR
tpbRhRgtrevision_graph((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs8
																						cC@s[xT|D]L}|dkrqny|j}Wntk
rEqnX||j|<qWdS(s0Cache any tree in trees if it has a revision_id.N(R$tget_revision_idtAttributeErrorRi(Rttreest
maybe_treetrev_id((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytcache_trees_with_revision_ids9s

cC@s.|jdkr'|jjj|_n|jS(N(RjR$R@t
repositoryt	get_graph(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRpDscC@s
||_dS(N(Rk(Rtvalue((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_set_base_is_ancestorJscC@s7|jdkr0|jj|j|j|_n|jS(N(RkR$Rptis_ancestortbase_rev_idR[(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_get_base_is_ancestorMs	cC@s
||_dS(N(Rl(RRy((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_set_base_is_other_ancestorUscC@sJ|jdkrC|jdkr"tS|jj|j|j|_n|jS(N(RlR$tother_basisRRpR{R|(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_get_base_is_other_ancestorXs	cC@sa|dkr|j}nt|j||||}|jj|_d|_|j|_|S(sUReturn 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 pb: A progress indicator
        :param base_tree: The basis to use for the merge.  If unspecified,
            other_tree.basis_tree() will be used.
        N(	R$t
basis_treeRURRORqR|tother_rev_idR(R0RRRoROR#((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytfrom_uncommittedcs
	c	C@s|j|jj|j|jj\}}}|jjj}|dk	r|tjkr|j||jj	rd}qt
jdn|j||||d|}||fS(sReturn a Merger for a bundle or merge directive.

        :param tree: The tree to merge changes into
        :param mergeable: A merge directive or bundle
        :param pb: A progress indicator
        sPerforming cherrypickRpN(
tinstall_revisionsRRwtget_merge_requestRxR$RXt
NULL_REVISIONR{RZttracetwarningtfrom_revision_ids(	tklassR0t	mergeableRotbase_revision_idtother_revision_idtverifiedRpR#((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytfrom_mergeableus		c	C@s|dkr|j}nt|d|d|d|}|dkrN|j}n|j|||dkrw|jn%|dkr|}n|j|||S(s-Return a Merger for revision-ids.

        :param pb: A progress indicator
        :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.
        R
RoRpN(R$RRUtset_other_revisiont	find_basetset_base_revision(	RoR0R3tbaseR_tbase_branchRpttree_branchR#((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs	
	cC@s||jkrv|dkr'|j}ny|jj|}Wn&tjk
re|jj|}nX||j|<n|j|S(N(RiR$R@R
t
revision_treeRtNoSuchRevisionInTreeRw(Rtrevision_idRR0((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRscC@s|\}}|dkr;tjj|d}|j|fStjj||d}|dkro|j}n|j|}t	j
|}||j||fS(Nii(R$tworkingtreetWorkingTreetopen_containingRt_mod_branchtBranchRZt
get_rev_idRXRYR(Rttreespectpossible_transportstlocationtrevnoR0RR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt	_get_trees
	cC@s
||_dS(N(Ra(Rt	file_list((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytset_interesting_filesscC@s5|js#|js#|jdkr'dS|jdS(N(tbase_is_ancestortbase_is_other_ancestorRR$t_add_parent(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytset_pendingscC@s|jj|jg}g}tj|jj}xk|D]c}y|j|}Wntjk
rpd}nX|j
|j|j|j
||fq;W|j|dtdS(Ntallow_leftmost_as_ghost(R
tget_parent_idsRRR
tset_parent_treesRRtNoSuchRevisionR$t	lock_readRRtappendRR(Rtnew_parentstnew_parent_treesRRR0((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs


cC@s;|j||\|_|_|ddkrtj|jj|_tj|jrptj	|jn|j|_
nw|ddk	r|jj|d|_|j|_
n?d|_|jj|_
|j
dkrtj	|jn|jdk	r|j|j
|j<n|j|j|j|j
dS(sSet 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.
        iiN(RR_RRRXRYRZRtis_nullRt	NoCommitsRR$RRit_maybe_fetchR@(Rtother_revisionR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt	set_others$		cC@sJ||_||_|j||j|j|j||_||_dS(sSet '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(RR_RR@RRRR(RRR_((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs
		cC@s>||_||_|j||j||j||_dS(sSet '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|RRR@RRO(RRR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR	s		cC@s,|jj|js(|j||ndS(N(Rwthas_same_locationtfetch(RtsourcettargetR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRscC@stj|jtj|jg}tj|kr`tj|_|j|j|_t|_	n+|j
j|d|d}t|_	t|dkrtj|_nt|dkrt
|d|_nt|_	t|dkr
|j
j|d|d|_n|j
j||_|j
j|d|}|jtjkr]|d|_n|jtjkr~tjn|j	rvtjdtjd||j|krtjd|jnt|}|j|jtd|jjj|D}|jj||j|kr>||j|_n|j|j|_g|D]}||^qZ|_n|j|j|_t|_ t|_!tjd|jdS(	NiiisBWarning: criss-cross merge encountered.  See bzr help criss-cross.sCriss-cross lcas: %rs6Unable to find unique lca. Fallback %r as best option.cs@s!|]}|j|fVqdS(N(Rq(t.0tt((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pys	<genexpr>CssBase revid: %r("RXRYR[RRR|RRORCRmRptfind_lcatlentlistRtfind_unique_lcatfind_merge_orderRtUnrelatedBranchesRRtmuttertsettaddtdictR@Rwtrevision_treesRitupdatetpopRnRR(Rt	revisionstlcastsorted_lca_keystinteresting_revision_idstinteresting_treestkey((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRsZ						
		 		cC@stjd|ddgkr,|jn|j|\}|_|ddkrf|j|_n>|ddkrtj	|_ntj
|j|d|_|j||j
|jdS(sSet the base revision to use for the merge.

        :param base_revision: A 2-list containing a path and revision number.
        s-doing merge() with no base_revision specifiediiN(RRR$RRRORZR|RXRRYRRR@(Rt
base_revisionR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytset_baseSs

cC@si|jd6|jd6|jd6|jd6|jd6|jd6|jd6td6}|jjro|j	|d	<n|jj
r|j|d
<n"|jrtj
d|jn|jjr|j|d<n"|jrtj
d
|jnt|jdtr|jrtjn|jjrA|jp7|j|d<n|jrot|jdtro|j|d<n|jddd|j|S(Ntworking_treeR
RRR	RaR@R_tdo_mergeRORcs6Conflict reduction is not supported for merge type %s.Rbs5Showing base is not supported for this merge type. %stsupports_reverse_cherrypickt
cherrypicktsupports_lca_treest	lca_treesRoRh(R
RRR	RaR@R_RCt
merge_typet
requires_baseROtsupports_reprocessRcRtBzrErrortsupports_show_baseRbtgetattrRRtCannotReverseCherrypicktsupports_cherrypickRRmRnR$Rh(Rtkwargs((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytmake_mergerfs@





			

c
C@sz|j}|jdk	r1|jj|jnxtjdD]}||q?W|jxtjdD]}||qkW|jdkrvx|j	j
D]\}}|j	j||}|jj
||}||jkrqnt|jd|}|j|_|jj||}|j|||jj
|}	|jjj|	|_|	|_|jqWn|S(NRRRVR
(RR_R$tupdate_referencesR@RURRRgR
titer_referencestget_nested_treeRRtget_reference_revisionRZRRtreference_parentRRORwRR|(
RtmergethooktrelpathR/tsub_treeRt	sub_mergeR_R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_do_merge_tos2
			cC@stj|j}|jj|j|jj|jdk	rd|jj	|j|jjn|j
dk	r|j
j	|j|j
jn|j}t|j
dkr|jrtjrtjtdqn tjtdt|j
t|j
S(Nis!All changes applied successfully.s%d conflicts encountered.(RR
RR
RRRROR$RRRRRtcooked_conflictsRRtis_quiettnotetgettext(RRR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs 


N("R R!RRR$RRvtpropertyRpRzR}RR~RRtstaticmethodRtclassmethodRRRRRRRRRRRRRRRR(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRUsD								 							;		"	t_InventoryNoneEntrycB@s8eZdZdZdZdZdZdZdZ	dZ
RS(sThis 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
    N(R R!R'R$t
executabletkindtnamet	parent_idtrevisiontsymlink_targett	text_sha1(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRstMerge3Mergerc
B@seZdZeZeZeZeZeZ	eZ
idd6dd6dd6ZeZd$eed$d$d$d$eed$d$d$dZdZdZd	Zd
ZdZdZd
ZdZdZedZedZedZedZedZedZeedZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'd$d$d$eedZ(d$d$d Z)d!Z*d"Z+d#Z,RS(%s1Three-way merger that uses the merge3 text mergeritthisiR3tconflictcC@s"tj||dk	r4|dk	r4tdn|dkrL|j}n||_||_||_||_||_	||_
||_||_g|_
g|_||_||_||_|
|_|
|_|r|jn|	dk	rtjdn|dk	rtjdndS(sQInitialize 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 interesting_ids: The file_ids of files that should be
            participate in the merge.  May not be combined with
            interesting_files.
        :param: reprocess If True, perform conflict-reduction processing.
        :param show_base: If True, show the base revision in text conflicts.
            (incompatible with reprocess)
        :param pb: ignored
        :param pp: A ProgressPhase object
        :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.  May not
            be combined with interesting_ids.  If neither interesting_files nor
            interesting_ids is 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.
        s3specify either interesting_ids or interesting_filess)pp argument to Merge3Merger is deprecateds)pb argument to Merge3Merger is deprecatedN(RWRR$R>RR	RaRR
RORRR@R_t_raw_conflictsRRcRbRnRhRRRdRe(RRR
RORRR	RcRbRoRfRhRaRRRR@R_((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs6"
															
cC@stj|j}|jj|j|jj|jj|j|jj|j	j|j|j	j|j
j|j|j
j|jdS(N(RR
t	_do_mergeRRRRR
RRORRtrun(RR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs



cC@stj|jd|_|j|jj|j|jjdt	}|j
|y|jj|jWnt
jk
rnXdS(Ntno_conflicts(t	transformt
TreeTransformRR$tttRtfinalizet_compute_transformtapplyRtwrite_modifiedt
add_conflictsRRtUnsupportedOperation(RRtresults((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR$s

cC@s\tj|j}|jj|j|jj|jj|j|jj|jS(N(	RR
t_make_preview_transformRORRRRRR(RR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytmake_preview_transform/s

cC@s&tj|j|_|j|jS(N(RtTransformPreviewRRR(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR
7s
cC@sn|jdkr'|j}|j}n|j}|j}tjd}g|D]}||^qP|g}g|D]}|dk	rv|^qv|_t	j
j}zxt|D]\}\}	}
}}}
|j
td|t||j|	||d||
r!|j|	}nd}|j|	|
|d|qWWd|jX|jj|jdS(NRsPreparing file mergetresolvert
unmodified(RnR$t	_entries3t
_three_wayt_entries_lcat_lca_multi_wayRURtactive_hookstuit
ui_factorytnested_progress_bart	enumerateRRRt_merge_namest_do_merge_contentst_merge_executabletfinishedRtfixup_new_rootst_finish_computing_transform(RtentriesRt	factoriestfactoryRRtchild_pbtnumR/tchangedtparents3tnames3texecutable3tfile_status((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR<s.	
&(%	
c@stjj}z%tjj|fd}Wd|jXjdk	rddl	m
}|jjjjnj
|x$jD]}tjt|qWdS(soFinalize the transform and report the changes.

        This is the second half of _compute_transform.
        c@stj||jS(N(Rt
conflict_passRR(Rtc(R(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt<lambda>csNi(tdelta(RRRRtresolve_conflictsRRRhR$tbzrlibR.treport_changestiter_changestcook_conflictsRRRtunicode(RR$tfs_conflictsR.R((Rs0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR [s
c	C@s4g}|jj|jd|jd|jg}td|jj|jD}x|D]\}}}}}}	}
}|jdk	r||jkrq\n|j	|}|dk	r|j
}
|j}|j}nd}
d}d}||f}|	|
f}||f}|j
|||||fq\W|S(sGather 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.
        tspecific_filestextra_treescs@s$|]\}}|j|fVqdS(N(R/(Rtpte((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pys	<genexpr>{sN(RRR2RORaR
Rtiter_entries_by_dirR	R$tgetRRRR(Rtresulttiteratortthis_entriesR/tpathsR&t	versionedtparentstnamesRRtentryt	this_nametthis_parenttthis_executableR'R(R)((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRns2				"		


 c(	@s|jd
k	rL|j|jg}|j|j|jj|j|}n	|j}g}t	j
|j|j}|jj}|jj}x|jD]\}}}	|d
krt
}n|d
k	r|krqn|j}
|
d
k	rCt}x9|	D]1\}}
|
d
k	r|
j|
krt}PqqW|rCqqCng}x=|	D]5\}}|d
krx|jt
qP|j|qPW|jr|}nt
}|jr|}nt
}g}g}g}g}xN|D]F}|j|j|j|j|j|j|j|jqW|j|j|f|j|j}|j|j|f|j|j}|j|j|f|j|j}t}|dkrE|jdkr|dkr|dkrqnt}qE|jd
ks|jdkrfd}|||j}gt||jD]\}
}||
|^q<}|||j}|||j}|j||f||dt} |j|j|f|j|j}!|dkr|dkr| dkr|!dkrqn| dkrBt}qBqE|jdkrfd}"|"||j}#gt||jD]\}
}|"|
|^qW}$|"||j}%|"||j}&|j|#|$f|&|%}'|dkr|dkr|'dkrqn|'dkrBt}qBqE|jdkr/t}|dkrB|dkrBqqBqEtd	|jn|j||j|f|j|jf|j|f|j|jf|j|f|j|jffqW|S(sGather 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, parents, names, executable)], where:

            * file_id: Simple file_id of the entry
            * changed: Boolean, True if the kind or contents changed else False
            * 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)
        Rt	directoryRMc@s |jdkrdS|jS(NRM(RR$t
get_file_sha1(tieR0(R/(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytget_sha1stallow_overriding_lcatsymlinkc@s |jdkrdS|jS(NRL(RR$tget_symlink_target(RIR0(R/(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt
get_targetsstree-referencesunhandled kind: %sN(RaR$R
ROtextendRnRRt	paths2idsR	t	_mod_treetMultiWalkertroot_inventorytiter_allt_none_entryRRCRRthas_idRRRRRtziptAssertionError((Rtlookup_treesR	R<twalkertbase_inventorytthis_inventorytpathtother_iet
lca_valuesRt
is_unmodifiedtlca_pathRItlca_entriestlca_ietbase_ietthis_iet	lca_kindstlca_parent_idst	lca_namestlca_executabletkind_winnertparent_id_winnertname_winnertcontent_changedRJt	base_sha1R0t	lca_sha1st	this_sha1t
other_sha1tsha1_winnertexec_winnerRNtbase_targettlca_targetstthis_targettother_targett
target_winner((R/s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs				


	1	1		cC@si}xo|jD]d}|jj|jj|}|dkrFqn|jj|}|dkrjqn|||<qW|jj|dS(N(tmodified_pathsRtpath2idRR$RHtset_merge_modified(RRtmodified_hashesR]R/thash((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR	9scC@s|dkrdS|jS(s9Determine the parent for a file_id (used as a key method)N(R$R(RCR/((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytparentEscC@s|dkrdS|jS(s7Determine the name for a file_id (used as a key method)N(R$R(RCR/((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRLscC@s |j|sdS|j|S(s?Determine the sha1 of the file contents (used as a key method).N(RVR$RH(R0R/((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt
contents_sha1SscC@s9|j|sdS|j|dkr,tS|j|S(s@Determine the executability of a file-id (used as a key method).RMN(RVR$RRCt
is_executable(R0R/((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRZs
cC@s |j|sdS|j|S(s7Determine the kind of a file-id (used as a key method).N(RVR$R(R0R/((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRcscC@s>||krdS|||fkr&dS||kr6dSdSdS(NRRR3((RR3R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRjsc	C@s||krdS|\}}g|D]}||kr#|^q#}t|dkrftj|||St|}t|dkrtj|j||S|r||kr||krdSdSq||krdSndS(sConsider 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.
        RiiRR3(RRRRR(	tbasesR3RRKtbase_valtlca_valstlca_valtfiltered_lca_valstunique_lca_vals((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRzs$
c
@sfd}||j}||j}||j}|||f}g}g}xW|D]O}	|	dkr|jd|jdq^|j|	j|j|	jq^W|j||d|jS(Nc@s+y|jSWntjk
r&dSXdS(N(RSRtNoSuchIdR$(R0(R/(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt	get_entrysR(	R
RRROR$RRRRR(
RR/Rt
this_entrytother_entryt
base_entryR!RBRARC((R/s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytmerge_namess

cC@s|\}}}|\}}	}
||}||}|dkro|dkrWd}n|dkrod}qon|dkr|dkrdS|dks|dkr|jj|}
|jjd|
||
||	|fn|jj|sdS||j|}||j|}|dk	s-|dk	r|dkr|dk	r||j|dkrztd||j|nt	j
}n|jj|}|jj|||jj|ndS(s,Perform a merge on file_id names and parentsRR3NRs
path conflictts$File looks like a root, but named %s(R$Rttrans_id_file_idRRRRRVt
winner_idxRXRtROOT_PARENTtadjust_path(RR/RARBRt	base_namet
other_nameRDtbase_parenttother_parentRERlRkRJRRtparent_trans_id((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs<	c@sfd}||j}||j}|jr||j}g|jD]}||^qO}|j||f||dt}n9||krd}n$||j}|j|||}|dkrdS|jj}	t	||	|d|d|}
|j
}d}x3|D]+}
|
j|
\}}|dkrPqqWt}d}|dkrd}|jj
|	}|jj|	}t}t}|
jdkr+|jj}|jj|}|dk	r|t}|jj|	tj|j|	|jd|jt}q|nQ|
jdkr||jj}|jj|}|dk	r|t}t}q|n|s|
jdk	r|jj|	n|j||d	t}|jjd
|fqn|dkr|jj||	n|dkrl|jj||	|jjd
|	f|jj
|	}|jj|	}|j||nG|dkr|jj|	d}n"|dkrntd|f|jjr|dkr|jj|	n|s|jj|	n|S(s%Performs a merge on file_id contents.c@sn|jsdS|j}|dkr@|j}n$|dkr^|j}nd}||fS(NRMRL(NN(RVR$RRHRM(R0Rtcontents(R/(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt
contents_pairsRKRRiR4tmodifiedtfilter_tree_pathtset_versionscontents conflicttsuccesst
conflicteds
text conflicttdeletetdeletedtdonesunknown hook_status: %rN( RORRRnR
RRCRRRRHRR&R$t
final_nametfinal_parentRKR.RzRtversion_fileRtcreate_from_treet_get_filter_tree_pathRLtunversion_filet_dump_conflictsRRtcreate_fileRXRVtdelete_contents(RR/Rt	base_pairt
other_pairt	this_pairR0t	lca_pairsR5RJR+Rthook_statusRtlinest	keep_thisR<RRt	duplicatetinhibit_content_conflictt	dupe_pathtthis_idtother_idt
file_group((R/s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs	"		
		cC@s|j}|j}|jj|rStj|j||j|d|j|dS|j	j|ridSt
d|fdS(s!Replace this contents with other.RRRs9winner is OTHER, but file_id %r not in THIS or OTHER treeN(sdoneN(sdeleteN(R/RJRRRVRRRRR$R
RX(Rtmerge_hook_paramsR/RJ((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_default_other_winner_mergeis		cC@sf|jdkr|j|S|jr^y|j|j|jWntjk
rYdSXdSdSdS(s0Fallback merge logic after user installed hooks.R3R4RN(snot_applicableN(sdoneN(snot_applicableN(	R5RR6t
text_mergeR/RJRt
BinaryFileR$(RR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR&{s
cC@s$|j|r|j|SgSdS(s-Return the lines in a file, or an empty list.N(RVtget_file_lines(RR0R/((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRNs
c@sqjj|rBjj|dkrBjj|}ng}jj|}jj|}tj|||djddj	t
krdnd
fd}i}||}jj
|||dt
krmjjd	|fjj|}	jj|}
j|	|
||||}|j|nd
S(s+Perform a three-way text merge on a file_idRMt
is_cherrypicks!START OF MERGE CONFLICT!sI HOPE THIS IS UNIQUEt|ic
3@s~t|d<xmjdddddddd	d
jD]8}|jrqt|d<|jd
Vq>|Vq>WdS(Nttext_conflictstname_atTREEtname_bsMERGE-SOURCEt	name_bases
BASE-REVISIONtstart_markertbase_markerRct<is<<<<<<<(RCtmerge_linesRct
startswithRtreplace(tretvaltline(Rtm3RR(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytiter_merge3s

Rs
text conflictNs|||||||(RORVRRNRRR
tmerge3tMerge3RRbRR$RRRRRRR(RR/RJRPRSRQRRtmerge3_iteratorRRR((RRRRs0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs0
	
	cC@sN|jjrJy|jj|SWqJtjk
rF|jj|SXndS(N(R
tsupports_content_filteringR.RRRRR$(RR/((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRsc		C@s'd|j|fd|j|fg}	|sF|	jd|j|fn|j}
|
jry|
j|}Wqtjk
rd}qXnd}t	}g}
x|	D]x\}}}|j
|r|j|||||||}|
j||r|r|jj
||t}qqqW|
S(sEmit 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.
        tOTHERtTHIStBASEN(RRR
RRORR.RRR$RCRVt_conflict_fileRRR(RRRR/RQRPRSRtno_basetdatatwtRR@RtsuffixR0RRJ((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs,	


c	C@sF|d|}|jj||}tj|j||||||S(sEmit a single conflict file.t.(Rtcreate_pathRR(	RRRR0R/RRRRJ((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs
cC@sWg|j|j|jfD]}|j||^q}|j|||d|jdS(s#Perform a merge on the execute bit.RN(RORRR
RRR(RR/R*RR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytmerge_executables	.cC@sI|\}}}|dkrdS||}|dkrd|j|j|dkr[d}qdd}n|dkr|dkrdS|jj|}	|jj|	dkrdS|dkr|}
nN|jj|r|}
n3|jj|r|}
n|j|r|}
n|
dk	rE|jj|}	|jj	|
|	ndS(s#Perform a merge on the execute bit.RNRRR3RRM(
RRRR$RRt
final_kindRVR
tbase_tree_has_idtset_executability(RR/RR*Rtbase_executabletother_executableRFR5RJt
executability((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs0						c	C@st}tj||j}tj|j}xQ|jD]F}|d}|dkrS|d\}}}	}
}}|	dks|
dkrd}
n-|j|jj|	}t	j
||
}
|dks|dkrd}nK||jjkrd}n|j|jj|}t	j
||}t
jjdd|
d|d|}n |d	krx4|dD](}|jj|}|dk	rjPqjqjW|j|}x2dD]*}|j|r|t| }PqqWt
jj|d|d|}|j|nk|d
kr`|d}|j|}|jj|}t
jj|d|d|}ntd|f|j|q:Wg|_xB|D]:}|jdkr|j|krqn|jj|qW|jjdt
jjdS(sAConvert all conflicts into a form that doesn't depend on trans_idis
path conflictis	<deleted>RR]t
conflict_pathR/scontents conflicts.BASEs.THISs.OTHERs
text conflictsbad conflict type: %rRN(s.BASEs.THISs.OTHER(RRR3Rt
FinalPathsRR$tget_pathRR,tpathjoinRRtget_root_idt_mod_conflictstConflictR#t
final_file_idtendswithRRRXRRt
typestringR/tsorttsort_key(RR5tcontent_conflict_file_idsRtfpRt
conflict_typeRJR/RERDRRt	this_pathtparent_patht
other_pathR,R]R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR3'sf	
				

	
N(-R R!R'RRRRRCt
history_basedRRRRR$RRRRR
RR RRR	RR~RRRRRRRRRRR&RNRRRRRRR3(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs\			>							$			1		-	z				-	
	%		 tWeaveMergercB@sAeZdZeZeZeZeZdZ	dZ
dZRS(s)Three-way tree merger, text weave merger.cC@s|jj||jd|S(NR(R
tplan_file_mergeRR(RR/R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_generate_merge_planuscC@s|jr|j}nd}|j||}dtjkrt|}|jj|}|jj	|d}d|D}|jj
||jj||ntj
|dd}|j|j\}}	|	r|j}
nd}
||
fS(sGenerate the merged lines.
        There is no distinction between lines that are meant to contain <<<<<<<
        and conflicts.
        Rs.plancs@s|]}d|VqdS(s%11s|%sN((Rtl((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pys	<genexpr>ss
<<<<<<< TREE
s>>>>>>> MERGE-SOURCE
N(RROR$Rtdebugtdebug_flagsRRRRtnew_fileRt
versionedfiletPlanWeaveMergeRRctbase_from_plan(RR/RtplanRJRRt	textmergeRt	conflictsRP((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt
_merged_linesys"	%	cC@s|j|\}}t|}tj||jj|||dk	r|jjd|f|jj	|}|jj
|}|j|||dtd|}|j|ndS(sPerform 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.
        s
text conflictRRPN(
RRttextfiletcheck_text_linesRRR$RRRRRRC(RR/RJRRPRRR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs
	(R R!R'RRRCRRRRRR(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRns		t	LCAMergercB@seZdZRS(cC@s|jj||jd|S(NR(R
tplan_file_lca_mergeRR(RR/R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs(R R!R(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRstDiff3MergercB@s eZdZdZdZRS(s6Three-way merger using external diff3 for text mergingc	C@sdtj||}t|d}z1|j|}x|D]}|j|q:WWd|jX|S(Ntwb(R,Rtopentget_filetwritetclose(	Rttemp_dirRR0R/tout_pathtout_filetin_fileR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt	dump_files
c
C@scddl}tjdd}z0tj|d}|j|d|j|}|j|d|j|}|j|d|j|}|jj	||||}	|	d
krt
jd
nt|d}
z|j
j|
|Wd|
jX|	d	krM|j
j|}|j
j|}|j||||jjd|fnWdtj|XdS(sPerform 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.
        iNtprefixsbzr-tnewRRR3isUnhandled diff3 exit codetrbs
text conflict(ii(tbzrlib.patchR,tmkdtempRRR
RORRtpatchtdiff3RRR	RRRRRRRRtrmtree(
RR/RJR0R
RRRR3tstatustfRR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs((R R!R'RR(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs	t
PathNotInTreecB@seZdZdZRS(s=Merge-into failed because %(tree)s does not contain %(path)s.cC@s tjj|d|d|dS(NR]R0(RRR(RR]R0((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs(R R!t_fmtR(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRstMergeIntoMergercB@s#eZdZddZdZRS(sMerger 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	C@s|jjjtj}tt|jd|jd|d|d|||_||_	||_
|dkr||j}n||_
|_t|_t|_t|_t|_t|_d|_ttd|jd|j	|_|j	dkr|j|j
|j|jndS(	sECreate 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@R
RRROt
target_subdirtsource_subpathRN(RRwRRXRR9RRt_target_subdirt_source_subpathR_R$RqRRRRR`RRRCRbRcR	t_MergeTypeParameterizertMergeIntoMergeTypeRR@(RR
R_RRRR Rtnull_ancestor_tree((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs2												cC@s$|jdkrdStj|dS(NR(R"RUR(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRsN(R R!R'R$RR(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs-R#cB@s)eZdZdZdZdZRS(sWrap 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.
    cK@s||_||_dS(N(t
_extra_kwargst_merge_type(RRR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR&s	cO@s |j|j|j||S(N(RR&R'(RtargsR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt__call__*scC@st|j|S(N(RR'(RR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt__getattr__.s(R R!R'RR)R*(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR#s		R$cB@s)eZdZdZdZdZRS(sAMerger that incorporates a tree (or part of a tree) into another.cO@sA|jd|_|jd|_tt|j||dS(sInitialize 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 RN(RR"R!R9R$R(RR(R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR5s
cC@stjj}z|j}t|}xot|D]a\}\}}|jtd|t||j	j
|}tj|j	|||j
}q7WWd|jX|jdS(NsPreparing file merge(RRRt_entries_to_incorporateRRRRRRRRtnew_by_entryRRRR (RR$R!R%RCRRRJ((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRFscc@sP|jj}|j|j}|dkr?t|jdn||}tj|j}|j	j|}|dkrt|jdntj
|j}|j}||_|j	j
|jrtj||_n||fV|jdkrdSxL|j|D];\}}	|	j}
|
|jkr=|j}
n|	|
fVq
WdS(s.Yields pairs of (inventory_entry, new_parent).sSource treesTarget treeRGN(RRRSRzR"R$RR,tdirnameR!R
R-tcopyRRVR/tgenerate_idstgen_file_idRR:R(Rt	other_invt	subdir_idtsubdirtparent_in_targett	target_idtname_in_targettmerge_into_roottignored_pathRCR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR+Ts,
			(R R!R'RRR+(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR$2s		c
C@s|dkrtjdnt|||d|d|d|
}||_||_||_||_|
r|rtdn|
|_	n||_
||_|	|_|	|_
t|dd}|dkr|j}n|j|||g|j|||jS(sPrimary interface for merging.

    Typical use is probably::

        merge_inner(branch, branch.get_revision_tree(other_revision),
                    branch.get_revision_tree(base_revision))
    s7bzrlib.merge.merge_inner requires a this_tree parameterR
RoRhs0Only supply interesting_ids or interesting_filesRqN(R$RRRUR`RR	RR>RaRbRcRRRRZRvRR(R@RRRORR`RR	RbRcRRaR
RoRhR#Rq((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR{s,								RsMerge using external diff3.tlcasLCA-newness merge.RsNative diff3-style merge.tweavesWeave-based merge.cC@stS(s}Merge type registry was previously in bzrlib.option

    This method provides a backwards compatible way to retrieve it.
    (tmerge_type_registry(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytget_merge_type_registrysc#@s6fd}fd}g|D]\}}|^q%}g|D]\}}|^qD}	tjd||	}
|
j}d}d}
x|D]\}}}x)|||!D]\}}|||VqWx)||
|!D]\}}|||VqW||}||}
x |||!D]}d|fVqWqWdS(Nc@s$|krd|fSd|fSdS(Nskilled-bsnew-a((Rttext(tancestors_b(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytstatus_as
c@s$|krd|fSd|fSdS(Nskilled-asnew-b((RR=(tancestors_a(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pytstatus_bs
it	unchanged(tpatiencedifftPatienceSequenceMatcherR$tget_matching_blocks(tannotated_atannotated_bR@R>R?RAtaRtplain_atplain_btmatchertblocksta_curtb_curtaitbiRRR=ttext_a((R@R>s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_plan_annotate_merges"

t_PlanMergeBasecB@sVeZdZdZdZdZdZdZdZe	dZ
RS(cC@sM||_||_||_d|_d|_i|_||_|jdS(s/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(	ta_revtb_revtvfR$t_last_linest_last_lines_revision_idt_cached_matching_blockst_key_prefixt_precache_tip_lines(RRTRURVt
key_prefix((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs								cC@s?|j|j|jg}||j|_||j|_dS(N(RNRTRUtlines_atlines_b(RR((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR[scC@sg|D]}|j|f^q}i}xm|jj|dtD]S}|jdkrrtj|j|jntj	|j
d||jd<qBW|S(swGet lines for revisions from the backing VersionedFiles.

        :raises RevisionNotPresent: on absent texts.
        t	unorderedtabsenttchunkedi(RZRVtget_record_streamRtstorage_kindRtRevisionNotPresentRR,tchunks_to_linestget_bytes_as(RRtrevtkeysR<trecord((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRNs#!cC@s||j|j|j}|j|\}}|j|j|\}}|j|j|\}}|j|||||S(sGenerate 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
        (t_get_matching_blocksRTRUt
_unique_linest_determine_statust
_iter_plan(RRLtunique_atunique_btnew_atkilled_btnew_btkilled_a((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt
plan_merges
	c
c@sJd}d}x7|D]/\}}	}
xkt||D]Z}||krz||kred|j|fVqd|j|fVq2d|j|fVq2Wxkt||	D]Z}||kr||krd|j|fVqd|j|fVqd|j|fVqWx-t|||
D]}d|j|fVqW||
}|	|
}qWdS(	Nisconflicted-asnew-askilled-bsconflicted-bsnew-bskilled-aRB(trangeR]R^(
RRLRpRqRrRstlast_itlast_jtitjtnta_indextb_index((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRms&
cC@s|jj||f}|dk	r(|S|j|krY|j}|j|g|}n)|j||g}||}||}||_||_tjd||}|jS(sxReturn a description of which sections of two revisions match.

        See SequenceMatcher.get_matching_blocks
        N(	RYR;R$RXRWRNRCRDRE(Rt
left_revisiontright_revisiontcachedt
left_linestright_linesRRK((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRj,s	

			c	C@s|d}d}g}g}xW|D]O\}}}|jt|||jt||||}||}qW||fS(sAnalyse 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.
        i(RORu(	Rtmatching_blocksRvRwtunique_lefttunique_rightRxRyRz((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRkBs
c	c@stjd||}d}x|jD]\}}}x t||D]}||VqGWx_t|||D]J}||}|ddkrqn|ddkrd|dfVqn|VqnW||}q(WdS(s'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.
        isnew-bskilled-bRBiN(RCRDR$RERu(	told_plantnew_planRKRwRxRyRztjjt	plan_line((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_subtract_plansSs	

	(R R!RR[RNRtRmRjRkRR(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRSs							t
_PlanMergecB@skeZdZdZdZdZdZedZedZ	dZ
dZd	ZRS(
s2Plan an annotate merge using on-the-fly annotationcC@stt|j|||||j|jf|_|j|jf|_tj	|j
|_|jj|j|jf}t
|dkr|j|_|j|jkr|}n|}tjd|j
|jd|d|_nd|_|jdS(Nis(found dominating revision for %s
%s > %si(R9RRRZRTta_keyRUtb_keyt
_mod_graphtGraphRVtgraphtheadsRRt	_head_keyRRR$t_weavet_build_weave(RRTRURVR\RR3((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRvs		cC@sdS(N((R((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR[scC@s|j|jf}i}xxtr|jj|}|ttjgkrTd}nx3|D]+}t|jj	||}|||<q[Wt
|dkrPnt
|dkrd|t|d<Pnt
|dkrtj
d|j|j||}x(t
|dkr(|jj|}qWt
|dkrDd}n(t|d}|tjkrld}n|j|j||Pn|}qW|S(s+Find all the ancestors back to a unique lcaiiis=More than 2 LCAs, falling back to all nodes for: %s, %s
=> %s((N(RRRRRRRXRttupleRRRRRR$Rt_find_unique_parents(Rt
cur_ancestorst
parent_mapt	next_lcastrev_keytordered_parentstcur_lcast
unique_lca((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_find_recursive_lcass>		
			

c
C@s|dkrIt|jj|}tj|kr|jtjqnUt}x-|D]%}|j|jj	||gqYW|jj
|}d||<|j|\}}}|dk	r|j||j
|||ntj|}	|	S(suFind 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.
        N((R$RRt
iter_ancestryRXRRRRtfind_unique_ancestorstget_parent_mapt_remove_external_referencestremovet_prune_tailsRtcollapse_linear_regions(
Rttip_keystbase_keyRtinterestingttiptculled_parent_mapt	child_mapttailst
simple_map((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs"	


c	C@si}i}g}x|jD]\}}g|D]}||kr2|^q2}|sf|j|nx'|D]}|j|gj|qmW|j|g|||<qW|||fS(sRemove 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
        (t	iteritemsRt
setdefault(	Rtfiltered_parent_mapRRRtparent_keysR8tculled_parent_keyst
parent_key((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRs%
cC@sx||r~|j}|j||j|}xG|D]?}||}|j|t|dkr8|j|q8q8WqWdS(sRemove 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.
        iN(RRRR(RRttails_to_removetnexttchildrentchildt
child_parents((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR	s	



cC@sVt|}|j|j|j|j|jg|D]}|d^q9}|S(s=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()
        i(RRRRRN(RRtall_revision_keystkt	all_texts((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt_get_interesting_texts	s

&c
C@sddlm}|jdddt|_|j}|j|}|jtj	f}|j
|jf||<xtt
j||D]o\}}}}||krqn||}	|d}
g|	D]}|d^q}|jj|
|||
qWdS(Ni(R:t
weave_nametin_memory_weavetallow_reservedi(R0R:tWeaveRRRRRZRXtCURRENT_REVISIONRRtreversedttsortt
merge_sortt	add_lines(
RR:RRttip_keytseq_numRtdepthteomRRRt
parent_ids((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyR/	s 	

c@s|jdk	r|j|jkr*dn7|j|jkr[td|j|jfnd|jd}|j|g|}fd|DS|jj|j|j	S(sGenerate 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
        snew-as#There was an invalid head: %s != %ssnew-bic3@s|]}|fVqdS(N((RR(R(s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pys	<genexpr>_	sN(
RR$RRRXRNRRtRTRU(Rthead_revR((Rs0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRtL	s		
(
R R!R'RR[RRRRRRRRt(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRss			3	$		t
_PlanLCAMergecB@s eZdZdZdZRS(s\
    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.
    cC@sLtj||||||j||f||f}t|_xD|D]<}|tjkrt|jj|qL|jj|dqLWx|jD]}tj|rg}n|j	|g|}t
jd|j
|}	t|	j}
|
|j||f<t
jd|j|}	t|	j}
|
|j||f<qWdS(Ni(RSRRRRRXRRRRNRCRDR$R]RRERYR^(RRTRURVR\RRR9t	lca_linesRKRL((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRo	s& 
			c	C@st}t}t|}xd|jD]Y}|j||}|j|\}}|j|j||j|j|q(W||fS(sDetermines 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)
        (RRRjRkRtintersectiont
difference(	RRtunique_line_numbersRtkilledR9RLt
unique_vs_lcat_ignored((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRl	s		(R R!R'RRl(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyRc	s
	(-t
__future__RRdtbzrlib.lazy_importRtglobalsR0RRRRtbzrlib.symbol_versioningRRR$RRRRWR"R(R8RHRURRURRRRRRRR#R$RCRtRegistryR;tregisterR<RRRSRR(((s0/usr/lib/python2.7/dist-packages/bzrlib/merge.pyt<module>sh	"5C)	:+;I"		"

Copyright © 2017 || Recoded By Mr.Bumblebee