ó €ˆtPc@s—ddlmZddlZddlZddlZddlZddlZdefd„ƒYZd„Z d„Z de fd„ƒ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 „Z e e ƒZ d „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<<<<<<>>>>>>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ö| d krÉxt | d| dƒD]} |j | Vq°Wqö| d kržt|_|| Vx+t | d | dƒD]} |j| VqÿW|dk r[|| Vx.t | d| dƒD]} |j | VqBWn|| Vx+t | d| dƒD]} |j | Vq|W|| Vqöt | ƒ‚qöWdS(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_markert base_markert reprocesstnewlineR*tttwhatti((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyt merge_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ôxÀt|d|dƒD]}d |j|Vq×Wq |d krvd 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‚| | | kst‚||} | |} ||}| 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òt‚|| 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    =c sч‡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.pyt simplemerge“s@   $    (ti18nRRˆRtRRŒR…t ExceptionRR RtobjectRR—(((s9/sys/lib/python2.7/site-packages/mercurial/simplemerge.pyts$  ÿY