Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Pc@s�ddlmZddlZddlZddlZddlZddlZdefd��YZd�Z	d�Z
defd��YZd	�Z
dS(
i�(t_NtCantReprocessAndShowBasecBseZRS((t__name__t
__module__(((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyRscCs�|d|dkst�|d|dks4t�t|d|d�}t|d|d�}||krx||fSdSdS(sGiven two ranges return the range where they intersect or None.

    >>> intersect((0, 10), (0, 6))
    (0, 6)
    >>> intersect((0, 10), (5, 15))
    (5, 10)
    >>> intersect((0, 10), (10, 15))
    >>> intersect((0, 9), (10, 15))
    >>> intersect((0, 9), (7, 15))
    (7, 9)
    iiN(tAssertionErrortmaxtmintNone(tratrbtsatsb((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyt	intersects
cCsj||||krtSxKtt||�t||��D]$\}}||||kr:tSq:WtSdS(s?Compare a[astart:aend] == b[bstart:bend], without slicing.
    N(tFalsetziptxrangetTrue(tatastarttaendtbtbstarttbendtiatib((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyt
compare_range0s.t
Merge3Textc	Bs�eZdZd
d
d
d�Zd
d
d
dddd
ed�Zd�Zd�Zd�Z	d	�Z
d
�Zee�Zd�Z
d�ZRS(s�3-way merge of texts.

    Given strings BASE, OTHER, THIS, tries to produce a combined text
    incorporating the changes from both BASE->OTHER and BASE->THIS.cCs�||_||_||_|dkr9tj|�}n|dkrWtj|�}n|dkrutj|�}n||_||_||_dS(N(	tbasetexttatexttbtextRtmdifft
splitnewlinestbaseRR(tselfRRRR RR((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyt__init__@s					s<<<<<<<s=======s>>>>>>>c	cs�t|_d}	t|j�dkre|jdjd�rCd}	qe|jdjd�red}	qen|rz|rzt�n|r�|d|}n|r�|d|}n|r�|r�|d|}n|j�}
|tkr�j|
�}
nx�|
D]�}|d}|dkrCx�t	|d|d�D]}
|j
|
Vq*Wq�d	ks[|d
kr�xLt	|d|d�D]}
|j|
VqsWq�dkr�xt	|d|d�D]}
|j|
Vq�Wq�dkr�t|_||	Vx+t	|d
|d�D]}
|j|
Vq�dk	r[||	Vx.t	|d|d�D]}
|j
|
VqBWn||	Vx+t	|d|d�D]}
|j|
Vq|W||	Vq�|��q�S(s'Return merge in cvs-like form.
        s
is
s
t t	unchangediiRtsameRtconflictiiiiN(R
t	conflictstlenRtendswithRt
merge_regionsRtreprocess_merge_regionstrangeR RRt
ValueError(R!tname_atname_bt	name_basetstart_markert
mid_markert
end_markertbase_markert	reprocesstnewlineR*tttwhatti((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pytmerge_linesNsV			

				ccs�x�|j�D]u}|d}|dkr^xVt|d|d�D]}d|j|VqAWq
|dksv|dkr�x	t|d|d�D]}|dd|j|Vq�Wq
|d	kr�t|d|d�D]}d
|j|Vq�Wq
|dkrvdVx/t|d
|d�D]}d|j|VqWdVx/t|d|d�D]}d|j|VqTWdVq
t|��q
WdS(shReturn merge with conflicts, showing origin of lines.

        Most useful for debugging merge.
        iR$iisu | RR%s | Rsb | R&s<<<<
iisA | s----
iisB | s>>>>
N(R*R,R RRR-(R!R7R8R9((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pytmerge_annotated�s(
c	csx|j�D]}|d}|dkrI||j|d|d!fVq
|dksa|dkr�||j|d|d!fVq
|dkr�||j|d|d!fVq
|dkr||j|d|d!|j|d	|d
!|j|d|d!fVq
t|��q
Wd
S(s�Yield sequence of line groups.  Each one is a tuple:

        'unchanged', lines
             Lines unchanged from base

        'a', lines
             Lines taken from a

        'same', lines
             Lines taken from a (and equal to b)

        'b', lines
             Lines taken from b

        'conflict', base_lines, a_lines, b_lines
             Lines from base were changed to either a or b and conflict.
        iR$iiRR%RR&iiiiN(R*R RRR-(R!R7R8((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pytmerge_groups�s
   ccsPd}}}x;|j�D]-}|\}}}}}	}
||}|dksUt�|||kskt�||
|	ks�t�||}|	|}
||}|dks�t�|
dks�t�|dks�t�|s�
r�t|j|||j||�}t|j||	|j||�}t|j|||j||	�}|r[d||fVns|ry|ryd||	fVnU|r�|r�d||fVn7|r�|r�d||||||	fVntd��|}|	}n|}|dkr||kst�||	kst�||ks%t�d||fV|}|}|
}qqWdS(	spReturn sequences of matching and conflicting regions.

        This returns tuples, where the first value says what kind we
        have:

        'unchanged', start, end
             Take a region of base[start:end]

        'same', astart, aend
             b and a are different from base but give the same result

        'a', start, end
             Non-clashing insertion from a[start:end]

        Method is as follows:

        The two sequences align only on regions which match the base
        and both descendants.  These are found by doing a two-way diff
        of each one against the base, and then finding the
        intersections between those regions.  These "sync regions"
        are by definition unchanged in both and easily dealt with.

        The regions in between can be in any of three cases:
        conflicted, or changed on only one side.
        iR%RRR&s#can't handle a=b=base but unmatchedR$N(tfind_sync_regionsRRRR R(R!tizRRtregiontzmatchtzendtamatchRtbmatchRtmatchlentlen_atlen_btlen_basetequal_atequal_bR%((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyR*�sP





	ccsKxD|D]<}|ddkr(|Vqn|\}}}}}}}	|j||!}
|j||	!}tjdj|
�dj|��}|}
|}x�|d D]u\}}}||7}||7}|j|
|||�}|dk	r�Vnd|||fV||}
||}q�W|j|
|||	�}|dk	r|VqqWdS(s�Where there are conflict regions, remove the agreed lines.

        Lines where both A and B have made the same changes are
        eliminated.
        iR&ti�R%N(RRRtget_matching_blockstjointmismatch_regionR(R!R*R?ttypeR>R@RRBRRCta_regiontb_regiontmatchestnext_atnext_bt	region_iat	region_ibt
region_lentreg((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyR+s0


	
cCs5||ks||kr1ddd||||fSdS(NR&(R(RRRTRSRU((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyRM8scCsed}}tj|j|j�}tj|j|j�}t|�}t|�}g}x�||kr||kr||\}}	}
||\}}}
t|||
f|||
f�}|r�d}|d}||}||
ks��||
kst�||kst�||ks(t�|	||}|||}||}||}|j||!|j	||!ks�t|j||!|j	||!f��|j||!|j
||!ks�t�|j||||||f�n||
||
kr|d7}q[|d7}q[Wt|j�}t|j	�}t|j
�}|j||||||f�|S(s�Return a list of sync regions, where both descendants match the base.

        Generates a list of (base1, base2, a1, a2, b1, b2).  There is
        always a zero-length sync region at the end of all the files.
        ii(RRKRRRR(RRR RRtappend(R!RRtamatchestbmatchesRERFtsltabaseRBtalentbbaseRCtblenR9tintbasetintendtintlentasubtbsubRR((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyR==sH
#




##&
c	Cs�tj|j|j�}tj|j|j�}g}x�|r�|r�|dd}||dd}|dd}||dd}t||f||f�}|r�|j|�n||kr�|d=q9|d=q9W|S(s8Return a list of ranges in base that are not conflicted.ii(RRKRRRRRX(	R!tamtbmtuncta1ta2tb1tb2R9((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pytfind_unconflictedzs
N(RRt__doc__RR"R
R:R;R<R*R+RMtstaticmethodR=Rl(((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyR;s$0		"	V			=cs���fd�}|}|}�jdg�}|rH|jd�}n|r`|jd�}n|r~tjtd���ny(||�}	||�}
||�}Wntjk
r�dSXtjj|�}�jd�stj	tjj
|��}|tjj|�ddt�}
n	t
j}
�jd	�}t|
|	|�}x3|jd
|d|d|�D]}|
j|�qhW�jd�s�|
j�n|jr��jd
�s��jtd��ndSdS(Ncs�t|d�}|j�}|j�tj|�r�td�|}�jd�sm�jtd�|�n�jd�s�tj|��q�n|S(NR	s%s looks like a binary file.tquietswarning: %s
ttext(	topentreadtclosetutiltbinaryRtgettwarntAbort(tfilenametfRptmsg(toptstui(s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pytreadfile�s
tlabeliscan only specify two labels.itprinttwt
atomictempt
no_minimalR.R/R5Ros!warning: conflicts during merge.
(RvtpopRtRxRtostpathtrealpathtscmutiltopenertdirnametbasenameRtsyststdoutRR:twriteRsR'Rw(R}tlocalR totherR|R~R.R/tlabelst	localtextRt	othertextR�toutR5tm3tline((R|R}s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pytsimplemerge�s@$	

	(ti18nRR�RtRR�R�t	ExceptionRRRtobjectRR�(((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyt<module>s$		

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].