-=[ Mr. Bumblebee ]=-
_Indonesia_

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


Nc@@sddlmZddlmZddlZddlmZdddgZdZd	Zd
Z	dZ
dejfd
YZdS(i(tabsolute_import(tbisectN(tmuttertPatienceSequenceMatchertunified_difftunified_diff_filescC@s}i}xGtt|D]3}||}||krBd||<q|||<qWdgt|}i}xpt|D]b\}}|j|}|dk	rv||krd|||<||=q|||<|||<qvqvWdgt|}	g}
g}d}xt|D]\}
}|dkr,qn|
rQ|
d|krQt|
}n\|
r|
||kr|t|
dks|
|d|kr|d7}nt|
|}|dkr||d|	|
<n|t|
kr||
|<|
||<q|
j||j|
qWt|dkr+gSg}|d}x1|dk	rn|j|||f|	|}q>W|j|S(s3Find the longest common subset for unique lines.

    :param a: An indexable object (such as string or list of strings)
    :param b: Another indexable object (such as string or list of strings)
    :return: A list of tuples, one for each line which is matched.
            [(line_in_a, line_in_b), ...]

    This only matches lines which are unique on both sides.
    This helps prevent common lines from over influencing match
    results.
    The longest common subset uses the Patience Sorting algorithm:
    http://en.wikipedia.org/wiki/Patience_sorting
    iiiN(txrangetlentNonet	enumeratetgetRtappendtreverse(tatbtindextitlinetbtoatindex2tpostnexttbackpointerststackstlaststktbpostapostresult((s;/usr/lib/python2.7/dist-packages/bzrlib/_patiencediff_py.pyt
unique_lcs_pysZ



,





cC@s|dkrtddSt|}||ks>||krBdS|d}	|d}
xt|||!|||!D]\}}||7}||7}|	d|ks|
d|krt|||	d|
d||||dn|}	|}
|j||fqtWt||krEt|||	d|
d||||dnw||||krxW||kr||kr||||kr|j||f|d7}|d7}q\Wt||||||||dn||d||dkr|d}
|d}xL|
|krW||krW||
d||dkrW|
d8}
|d8}qWt|||	d|
d|
|||dx6t||
D]!}|j|
|||fqWndS(sFind all of the matching text in the lines of a and b.

    :param a: A sequence
    :param b: Another sequence
    :param alo: The start location of a to check, typically 0
    :param ahi: The start location of b to check, typically 0
    :param ahi: The maximum length of a to check, typically len(a)
    :param bhi: The maximum length of b to check, typically len(b)
    :param answer: The return array. Will be filled with tuples
                   indicating [(line_in_a, line_in_b)]
    :param maxrecursion: The maximum depth to recurse.
                         Must be a positive integer.
    :return: None, the return value is in the parameter answer, which
             should be a list

    ismax recursion depth reachedNi(RRRtrecurse_matches_pyRR(R
Rtalotblotahitbhitanswertmaxrecursiont	oldlengtht
last_a_post
last_b_posRRtnahitnbhiR((s;/usr/lib/python2.7/dist-packages/bzrlib/_patiencediff_py.pyRksJ


*

 /


7
cC@sg}d}}d}x|D]|\}}|dk	rb|||krb|||krb|d7}q|dk	r|j|||fn|}|}d}qW|dkr|j|||fn|S(sFind sequences of lines.

    Given a sequence of [(line_in_a, line_in_b),]
    find regions where they both increment at the same time
    iiN(RR(tmatchesR#tstart_atstart_btlengthti_ati_b((s;/usr/lib/python2.7/dist-packages/bzrlib/_patiencediff_py.pyt_collapse_sequencess 


cC@std}d}xa|D]Y\}}}||kr=tdn||krXtdn||}||}qWdS(NisNon increasing matches for asNon increasing matches for b(t
ValueError(R#tnext_atnext_bR
Rt	match_len((s;/usr/lib/python2.7/dist-packages/bzrlib/_patiencediff_py.pyt_check_consistencys
tPatienceSequenceMatcher_pycB@s/eZdZeZddddZdZRS(s8Compare a pair of sequences using longest common subset.tcC@s8|dk	rtdntjj||||dS(Ns8Currently we do not support isjunk for sequence matching(RtNotImplementedErrortdifflibtSequenceMatchert__init__(tselftisjunkR
R((s;/usr/lib/python2.7/dist-packages/bzrlib/_patiencediff_py.pyR;sc	C@s|jdk	r|jSg}t|j|jddt|jt|j|dt||_|jjt|jt|jdftj	rt
|jn|jS(sReturn list of triples describing matching subsequences.

        Each triple is of the form (i, j, n), and means that
        a[i:i+n] == b[j:j+n].  The triples are monotonically increasing in
        i and in j.

        The last triple is a dummy, (len(a), len(b), 0), and is the only
        triple with n==0.

        >>> s = PatienceSequenceMatcher(None, "abxcd", "abcd")
        >>> s.get_matching_blocks()
        [(0, 0, 2), (3, 2, 2), (5, 4, 0)]
        ii
N(tmatching_blocksRRR
RRR0RR6t_do_check_consistencyR5(R<R*((s;/usr/lib/python2.7/dist-packages/bzrlib/_patiencediff_py.pytget_matching_blockss"+	N(t__name__t
__module__t__doc__tTrueR?RR;R@(((s;/usr/lib/python2.7/dist-packages/bzrlib/_patiencediff_py.pyR6s(
t
__future__RRR9tbzrlib.traceRt__all__RRR0R5R:R6(((s;/usr/lib/python2.7/dist-packages/bzrlib/_patiencediff_py.pyt<module>s	N	>		

Copyright © 2017 || Recoded By Mr.Bumblebee