-=[ Mr. Bumblebee ]=-
_Indonesia_

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


:Nc@@sldZddlmZddlmZeedddlmZmZm	Z	de
fdYZdS(	s8Functionality for doing annotations in the 'optimal' wayi(tabsolute_import(tlazy_imports
from bzrlib import (
    annotate, # Must be lazy to avoid circular importing
    graph as _mod_graph,
    patiencediff,
    )
(terrorstosutilstuit	AnnotatorcB@seZdZdZdZdZddZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZRS(s)Class that drives performing annotations.cC@sC||_i|_i|_i|_i|_d|_i|_dS(s,Create a new Annotator from a VersionedFile.N(t_vft_parent_mapt_text_cachet_num_needed_childrent_annotations_cachetNonet_heads_providert_ann_tuple_cache(tselftvf((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt__init__'s						cC@sGx@|D]8}||jkr2|j|cd7<qd|j|<qWdS(Ni(R	(Rtkeytparent_keyst
parent_key((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt_update_needed_children2s
c	C@s|j}d|j|<t}t}t|g}xR|rg}i}x|D]}||jkr||jkr|j|q||jkr|j||j|||<qqS|j||j|qSWt}|j|jj	|xu|j
D]g\}}|dkr2d}d||<n|j|||jg|D]}||krO|^qOqW|j|d|_
q:W||fS(sDetermine the texts we need to get from the backing vf.

        :return: (vf_keys_needed, ann_keys_needed)
            vf_keys_needed  These are keys that we need to get from the vf
            ann_keys_needed Texts which we have in self._text_cache but we
                            don't have annotations for. We need to yield these
                            in the proper order so that we can get proper
                            annotations.
        iN(((RR	tsetRtaddR
tappendtupdateRtget_parent_mapt	iteritemsRRR(	RRt
parent_maptvf_keys_neededtann_keys_neededtneeded_keyst
parent_lookuptnext_parent_mapR((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt_get_needed_keys9s:
	
			


	


cc@sH|j|\}}|dk	r=|jddt|n|jj|dt}xt|D]\}}|dk	r|jddt|n|jdkrt	j
|j|jn|j}tj
|jd}	t|	}
|	|j|<||	|
fVqbWx5|D]-}|j|}	t|	}
||	|
fVqWdS(sGet the texts we need to properly annotate key.

        :param key: A Key that is present in self._vf
        :return: Yield (this_key, text, num_lines)
            'text' is an opaque object that just has to work with whatever
            matcher object we are using. Currently it is always 'lines' but
            future improvements may change this to a simple text string.
        sgetting streamittopologicalt
extractingtabsenttchunkedN(R!RRtlenRtget_record_streamtTruet	enumeratetstorage_kindRtRevisionNotPresentRRtchunks_to_linestget_bytes_asR(RRtpbtkeystann_keyststreamtidxtrecordtthis_keytlinest	num_lines((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt_get_needed_textsis$		


cC@sE|j|}|j|}tjd||}|j}||fS(sGet the list of annotations for the parent, and the matching lines.

        :param text: The opaque value given by _get_needed_texts
        :param parent_key: The key for the parent text
        :return: (parent_annotations, matching_blocks)
            parent_annotations is a list as long as the number of lines in
                parent
            matching_blocks is a list of (parent_idx, text_idx, len) tuples
                indicating which lines match between the two texts
        N(RR
tpatiencedifftPatienceSequenceMatcherRtget_matching_blocks(RRttextRtparent_linestparent_annotationstmatchertmatching_blocks((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt#_get_parent_annotations_and_matchess

	c
C@sU|j|||\}}x3|D]+\}}}	||||	!||||	+q"WdS(s2Reannotate this text relative to its first parent.N(R@(
RRtannotationsR5RR=R?t
parent_idxt	lines_idxt	match_len((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt_update_from_first_parentscC@sN|j|||\}}d}d}	d}
x|D]\}}}
||||
!}||||
!}||krwq4nxt|
D]}||}||}||}||krqn||kr|||<qn||kr||	kr|
||<qt|}|j|tt|}|||<|}|}	|}
qWq4WdS(s;Reannotate this text relative to a second (or more) parent.N(R@RtxrangeRRttupletsorted(RRRAR5tthis_annotationRR=R?tlast_anntlast_parenttlast_resRBRCRDtann_subtpar_subR2tanntpar_anntann_idxtnew_ann((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt_update_from_other_parentss8






cC@si||j|<xU|D]M}|j|}|d8}|dkrT|j|=|j|=n||j|<qWdS(Nii(R
R	R(RRRRARtnum((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt_record_annotations





cC@s|f}|g|}|j|}|rt|j||||dx.|dD]}|j|||||qNWn|j|||dS(Nii(RRERSRU(RRR;R6RIRARtparent((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt
_annotate_ones	

cC@s0||j|<tj||j|<d|_dS(sAdd a specific text to the graph.

        This is used to add a text which is not otherwise present in the
        versioned file. (eg. a WorkingTree injecting 'current:' into the
        graph to annotate the edited content.)

        :param key: The key to use to request this text be annotated
        :param parent_keys: The parents of this text
        :param text: A string containing the content of the text
        N(RRtsplit_linesRRR(RRRR;((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pytadd_special_texts
cC@stjj}z@x9|j|d|D]"\}}}|j|||q(WWd|jXy|j|}Wn&tk
rtj	||j
nX||j|fS(skReturn annotated fulltext for the given key.

        :param key: A tuple defining the text to annotate
        :return: ([annotations], [lines])
            annotations is a list of tuples of keys, one for each line in lines
                        each key is a possible source for the given line.
            lines the text of "key" as a list of lines
        R.N(Rt
ui_factorytnested_progress_barR7RWtfinishedR
tKeyErrorRR+RR(RRR.ttext_keyR;R6RA((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pytannotates	%
cC@s.|jdkr'tj|j|_n|jS(N(RRt
_mod_grapht
KnownGraphR(R((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt_get_heads_providerscC@st|dkrt|d}nQt|}|j}x6|D].}||f||ff}||d}q>W|S(Ni(RRHtitertnext(Rt	the_headstlinet
tiebreakertheadt	next_headt
possible_headtannotated_lines((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt_resolve_annotation_ties
cC@stj}|j|\}}g}|jj}|j}xt||D]\}}	t|dkrw|d}
nH||}t|dkrx'|D]}
PqWn|j||	|}
||
|	fqLW|S(sDetermine the single-best-revision to source for each line.

        This is meant as a compatibility thunk to how annotate() used to work.
        :return: [(ann_key, line)]
            A list of tuples with a single annotation key for each line.
        ii(R_t_break_annotation_tieRbtheadsRtzipR&Rl(RRtcustom_tiebreakerRAR5toutRnRt
annotationRfRhRe((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt
annotate_flat"s 		

	N(t__name__t
__module__t__doc__RRR!RR7R@RERSRURWRYR_RbRlRs(((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyR$s			0			0		
				
N(Rvt
__future__Rtbzrlib.lazy_importRtglobalstbzrlibRRRtobjectR(((s8/usr/lib/python2.7/dist-packages/bzrlib/_annotator_py.pyt<module>s	

Copyright © 2017 || Recoded By Mr.Bumblebee