³ò ø$•Jc@s‹ddklZddkZddkZddkZddkZdefd„ƒYZd„Zd„Z de fd„ƒYZ d „Z dS( iÿÿÿÿ(t_NtCantReprocessAndShowBasecBseZRS((t__name__t __module__(((s(/sys/lib/python/mercurial/simplemerge.pyRscCs‰|d|djpt‚|d|djpt‚t|d|dƒ}t|d|dƒ}||jo||fSndSdS(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((s(/sys/lib/python/mercurial/simplemerge.pyt intersects  cCst||||jotSnxPtt||ƒt||ƒƒD])\}}||||jotSq?q?WtSdS(s?Compare a[astart:aend] == b[bstart:bend], without slicing. N(tFalsetziptxrangetTrue(tatastarttaendtbtbstarttbendtiatib((s(/sys/lib/python/mercurial/simplemerge.pyt compare_range2s"  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š||_||_||_|djoti|ƒ}n|djoti|ƒ}n|djoti|ƒ}n||_||_||_dS(N( tbasetexttatexttbtextRtmdifft splitnewlinestbaseRR(tselfRRRR RR((s(/sys/lib/python/mercurial/simplemerge.pyt__init__Bs        s<<<<<<>>>>>>c  csÒt|_d} t|iƒdjoF|ididƒo d} qk|ididƒo d} qkn|o|o tƒ‚n|o|d|}n|o|d|}n|o|o|d|}n|iƒ} |tjo|i| ƒ} nxÇ| D]¿} | d} | djo2xŸt | d| dƒD]} |i | Vq@Wq | d jp | d jo2xSt | d| dƒD]} |i| VqŒWq | d jo2xt | d| dƒD]} |i | VqËWq | d joÌt|_|| Vx+t | d | dƒD]} |i| VqW|dj o;|| Vx/t | d| dƒD]} |i | Vq`Wn|| Vx+t | d| dƒD]} |i | 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((s(/sys/lib/python/mercurial/simplemerge.pyt merge_linesPsd               ccs“xŒ|iƒD]~}|d}|djo6x^t|d|dƒD]}d|i|VqBWq |djp |djo>xt|d|dƒD]}|dd|i|Vq’Wq |d jo6xÃt|d|dƒD]}d |i|VqÝWq |d jowd Vx/t|d |dƒD]}d|i|Vq%WdVx/t|d|dƒD]}d|i|Vq\WdVq 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((s(/sys/lib/python/mercurial/simplemerge.pytmerge_annotatedˆs4       c cs x|iƒD] }|d}|djo!||i|d|d!fVq |djp |djo!||i|d|d!fVq |djo!||i|d|d!fVq |djoK||i|d|d!|i|d |d !|i|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((s(/sys/lib/python/mercurial/simplemerge.pyt merge_groups£s   !! ! ccsld}}}xW|iƒD]I\}}}}}} ||} | djpt‚| ||jpt‚| | |jpt‚||} ||} ||} | djpt‚| djpt‚| djpt‚| p| ot|i|||i||ƒ}t|i|||i||ƒ}t|i|||i||ƒ}|od||fVn}|o| od||fVn\|o| od||fVn;| o&| od||||||fVn tdƒ‚|}|}n|}| djo`||jpt‚||jpt‚||jpt‚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 descendents. 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!tizRRtzmatchtzendtamatchRtbmatchRtmatchlentlen_atlen_btlen_basetequal_atequal_bR%((s(/sys/lib/python/mercurial/simplemerge.pyR*ÅsP        c csQxJ|D]B}|ddjo |Vqn|\}}}}}}} |i||!} |i|| !} tidi| ƒdi| ƒƒ} |} |}xƒ| d D]w\}}}||7}||7}|i| |||ƒ}|dj o |Vnd|||fV||} ||}q W|i| ||| ƒ}|dj o |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*tregionttypeR>R?RRARRBta_regiontb_regiontmatchestnext_atnext_bt region_iat region_ibt region_lentreg((s(/sys/lib/python/mercurial/simplemerge.pyR+s4        cCs;||jp ||joddd||||fSndS(NR&(R(RRRTRSRU((s(/sys/lib/python/mercurial/simplemerge.pyRL9sc Csud}}ti|i|iƒ}ti|i|iƒ}t|ƒ}t|ƒ}g}xÊ||jo¼||jo¯||\}} } ||\} } } t||| f| | | fƒ}|o.|d}|d}||}|| jpt‚|| jpt‚||jpt‚| |jpt‚| ||}| || }||}||}|i||!|i ||!jp$t|i||!|i ||!f‚|i||!|i ||!jpt‚|i ||||||fƒn|| | | jo|d7}q[|d7}q[Wt|iƒ}t|i ƒ}t|i ƒ} |i ||||| | fƒ|S(sÛReturn a list of sync regions, where both descendents 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( RRJRRRR(R RR RRtappend(R!RRtamatchestbmatchesRDREtsltabaseRAtalentbbaseRBtblenR9tintbasetintendtintlentasubtbsubRR((s(/sys/lib/python/mercurial/simplemerge.pyR=>sH   #     $!( c Csâti|i|iƒ}ti|i|iƒ}g}x¥|o|o–|dd}||dd}|dd}||dd}t||f||fƒ}|o|i|ƒn||jo |d=q9|d=q9W|S(s8Return a list of ranges in base that are not conflicted.ii(RRJRRRR RX( R!tamtbmtuncta1ta2tb1tb2R9((s(/sys/lib/python/mercurial/simplemerge.pytfind_unconflicted{s   N(RRt__doc__RR"R R:R;R<R*R+RLt staticmethodR=Rl(((s(/sys/lib/python/mercurial/simplemerge.pyR=s$ 0  " U    =c sƇ‡fd†}|}|}ˆidgƒ}|o|idƒ}n|o|idƒ}n|otitdƒƒ‚n||ƒ} ||ƒ} ||ƒ} tii|ƒ}ˆidƒp@titii |ƒƒ} | tii |ƒddt ƒ} n t i } ˆidƒ }t| | | ƒ}x3|id |d |d |ƒD]}| i|ƒqTWˆidƒp| iƒn|io/ˆid ƒpˆitd ƒƒndSndS(Ncs›t|dƒ}|iƒ}|iƒti|ƒobtdƒ|}ˆidƒpti|ƒ‚q—ˆidƒpˆitdƒ|ƒq—n|S(NR s%s looks like a binary file.ttexttquiets warning: %s ( topentreadtclosetutiltbinaryRtgettAborttwarn(tfilenametfRotmsg(tuitopts(s(/sys/lib/python/mercurial/simplemerge.pytreadfile•s  tlabeliscan only specify two labels.tprinttwt atomictempt no_minimalR.R/R5Rps!warning: conflicts during merge. i(RvtpopRtRwRtostpathtrealpathtopenertdirnametbasenameRtsyststdoutRR:twritetrenameR'Rx(R|tlocalR totherR}R~R.R/tlabelst localtextRt othertextRˆtoutR5tm3tline((R|R}s(/sys/lib/python/mercurial/simplemerge.pyt simplemerge”s<    %  ( ti18nRRtRR‹R…t ExceptionRR RtobjectRR—(((s(/sys/lib/python/mercurial/simplemerge.pyss  ÿX