-=[ Mr. Bumblebee ]=-
_Indonesia_

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

ó
¦îNc@@sˆddlmZddlZddlmZmZmZmZmZdZ	de
fd„ƒYZde
fd„ƒYZd	e
fd
„ƒYZ
de
fd„ƒYZd
e
fd„ƒYZde
fd„ƒYZde
fd„ƒYZde
fd„ƒYZd„Zd„Zde
fd„ƒYZdddddddgZyddlmZWn0ek
rƒZejeƒddlmZnXdS(i(tabsolute_importN(tdebugterrorstosutilstrevisionttraceitDictParentsProvidercB@s)eZdZd„Zd„Zd„ZRS(s%A parents provider for Graph objects.cC@s
||_dS(N(tancestry(tselfR((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt__init__9scC@sd|jS(NsDictParentsProvider(%r)(R(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt__repr__<scC@s<|j}tg|D]"}||kr|||f^qƒS(s)See StackedParentsProvider.get_parent_map(Rtdict(RtkeysRtk((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytget_parent_mapDs	(t__name__t
__module__t__doc__R	R
R(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR6s		tStackedParentsProvidercB@s)eZdZd„Zd„Zd„ZRS(s’A parents provider which stacks (or unions) multiple providers.

    The providers are queries in the order of the provided parent_providers.
    cC@s
||_dS(N(t_parent_providers(Rtparent_providers((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR	PscC@sd|jj|jfS(Ns%s(%r)(t	__class__RR(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR
SscC@sÏi}t|ƒ}xe|jD]Z}t|ddƒ}|dkrFqn||ƒ}|j|ƒ|j|ƒ|sPqqW|s„|SxD|jD]9}|j|ƒ}|j|ƒ|j|ƒ|sŽPqŽqŽW|S(såGet a mapping of keys => parents

        A dictionary is returned with an entry for each key present in this
        source. If this source doesn't have information about a key, it should
        not include an entry.

        [NULL_REVISION] is used as the parent of the first user-committed
        revision.  Its parent list is empty.

        :param keys: An iterable returning keys to check (eg revision_ids)
        :return: A dictionary mapping each key to its parents
        tget_cached_parent_mapN(tsetRtgetattrtNonetupdatetdifference_updateR(RRtfoundt	remainingtparents_providert
get_cachedt	new_found((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRVs*
		



(RRRR	R
R(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRJs		tCachingParentsProvidercB@s_eZdZd	d	d„Zd„Zed„Zd„Zd„Z	d„Z
d„Zd„ZRS(
s–A parents provider which will cache the revision => parents as a dict.

    This is useful for providers which have an expensive look up.

    Either a ParentsProvider or a get_parent_map-like callback may be
    supplied.  If it provides extra un-asked-for parents, they will be cached,
    but filtered out of get_parent_map.

    The cache is enabled by default, but may be disabled and re-enabled.
    cC@sJ||_|dkr'|jj|_n	||_d|_|jtƒdS(sýConstructor.

        :param parent_provider: The ParentProvider to use.  It or
            get_parent_map must be supplied.
        :param get_parent_map: The get_parent_map callback to use.  It or
            parent_provider must be supplied.
        N(t_real_providerRRt_get_parent_mapt_cachetenable_cachetTrue(Rtparent_providerR((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR	‰s			cC@sd|jj|jfS(Ns%s(%r)(RRR"(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR
™scC@s@|jdk	rtdƒ‚ni|_||_tƒ|_dS(s
Enable cache.s#Cache enabled when already enabled.N(R$RtAssertionErrort
_cache_missesRtmissing_keys(Rtcache_misses((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR%œs
		cC@s"d|_d|_tƒ|_dS(sDisable and clear the cache.N(RR$R)RR*(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt
disable_cache¤s		cC@s |jdkrdSt|jƒS(s(Return any cached get_parent_map values.N(R$RR(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytget_cached_mapªscC@sL|j}|dkriStg|D]"}||kr#|||f^q#ƒS(s¿Return items from the cache.

        This returns the same info as get_parent_map, but explicitly does not
        invoke the supplied ParentsProvider to search for uncached values.
        N(R$RR(RRtcachetkey((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR°s	c@sô|j‰ˆdkr'|j|ƒ‰nŠt‡fd†|Dƒƒ}|j|jƒ|r±|j|ƒ}ˆj|ƒ|jr±x-|D]"}||kr…|j|ƒq…q…Wq±ni}x6|D].}ˆj	|ƒ}|dk	r¾|||<q¾q¾W|S(s*See StackedParentsProvider.get_parent_map.c3@s!|]}|ˆkr|VqdS(N((t.0R/(R.(s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pys	<genexpr>ÁsN(
R$RR#RRR*RR)tnote_missing_keytget(RRtneeded_revisionst
parent_mapR/tresulttvalue((R.s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR»s$	
	

cC@s |jr|jj|ƒndS(sNote that key is a missing key.N(R)R*tadd(RR/((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR1Òs	N(
RRRRR	R
R&R%R,R-RRR1(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR!~s
					t CallableToParentsProviderAdaptercB@s)eZdZd„Zd„Zd„ZRS(s¼A parents provider that adapts any callable to the parents provider API.

    i.e. it accepts calls to self.get_parent_map and relays them to the
    callable it was constructed with.
    cC@s
||_dS(N(tcallable(Rt
a_callable((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR	ßscC@sd|jj|jfS(Ns%s(%r)(RRR9(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR
âscC@s
|j|ƒS(N(R9(RR((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRås(RRRR	R
R(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR8Øs		tGraphcB@s"eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„Zd„Zdd„Zd„Zd„Zd„Z d„Z!d„Z"RS( s­Provide incremental access to revision graphs.

    This is the generic implementation; it is intended to be subclassed to
    specialize it for other repository types.
    cC@s[t|ddƒdk	r'|j|_nt|ddƒdk	rN|j|_n||_dS(sŸConstruct a Graph that uses several graphs as its input

        This should not normally be invoked directly, because there may be
        specialized implementations for particular repository types.  See
        Repository.get_graph().

        :param parents_provider: An object providing a get_parent_map call
            conforming to the behavior of
            StackedParentsProvider.get_parent_map.
        tget_parentsRN(RRR<Rt_parents_provider(RR((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR	ðs
cC@sd|jS(Ns	Graph(%r)(R=(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR
scG@s%|j|ƒ\}}}|j|ƒS(sÌDetermine the lowest common ancestors of the provided revisions

        A lowest common ancestor is a common ancestor none of whose
        descendants are common ancestors.  In graphs, unlike trees, there may
        be multiple lowest common ancestors.

        This algorithm has two phases.  Phase 1 identifies border ancestors,
        and phase 2 filters border ancestors to determine lowest common
        ancestors.

        In phase 1, border ancestors are identified, using a breadth-first
        search starting at the bottom of the graph.  Searches are stopped
        whenever a node or one of its descendants is determined to be common

        In phase 2, the border ancestors are filtered to find the least
        common ancestors.  This is done by searching the ancestries of each
        border ancestor.

        Phase 2 is perfomed on the principle that a border ancestor that is
        not an ancestor of any other border ancestor is a least common
        ancestor.

        Searches are stopped when they find a node that is determined to be a
        common ancestor of all border ancestors, because this shows that it
        cannot be a descendant of any border ancestor.

        The scaling of this operation should be proportional to:

        1. The number of uncommon ancestors
        2. The number of border ancestors
        3. The length of the shortest path between a border ancestor and an
           ancestor of all border ancestors.
        (t_find_border_ancestorstheads(Rt	revisionst
border_commontcommontsides((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_lcas"cC@sd|j||gƒ\}}}|j||ƒ|dj}|dj}|j|ƒ|j|ƒfS(s4Determine the graph difference between two revisionsii(R>t_search_for_extra_commontseent
difference(Rt
left_revisiontright_revisiontborderRBt	searcherstlefttright((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_difference,s

cC@sP|j|j||ƒƒ}tt|ƒƒ}|j|gƒ}t|ƒ|jS(s:Find descendants of old_key that are ancestors of new_key.(t
get_child_mapt_find_descendant_ancestorsR;Rt_make_breadth_first_searchertlistRF(Rtold_keytnew_keyt	child_maptgraphtsearcher((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_descendants5s
cC@s‰|j|gƒ}|j|gƒ}xO|D]G}|jj|ƒ}|j|ƒ|j|jƒƒ}|j|ƒq+W|jj|jƒS(s=Find ancestors of new_key that may be descendants of old_key.(RQRFtintersectiontstop_searching_anytfind_seen_ancestorststepRG(RRSRTtstoptdescendantsR@told_stopt	seen_stop((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRP>s

cC@si|jj|ƒ}i}xJt|jƒƒD]6\}}x'|D]}|j|gƒj|ƒq>Wq+W|S(sïGet a mapping from parents to children of the specified keys.

        This is simply the inversion of get_parent_map.  Only supplied keys
        will be discovered as children.
        :return: a dict of key:child_list for keys.
        (R=Rtsortedtitemst
setdefaulttappend(RRR4tparent_childtchildtparentstparent((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyROIs
!cC@slt|ƒ}|}d}tj}d||<t|jƒƒ}i}x||kr_|||<|d7}t|gƒ}	|	j|ƒ|j|	ƒ}
|
j|dƒ}|s¾t
j||ƒ‚n|d}g}x…|D]}}
|
j|
dƒ}|sùqÕn|d}||
d}||kr)|||S||kr;qÕn|||<|j|ƒqÕW|}qFW|||S(s“Find the left-hand distance to the NULL_REVISION.

        (This can also be considered the revno of a branch at
        target_revision_id.)

        :param target_revision_id: A revision_id which we would like to know
            the revno for.
        :param known_revision_ids: [(revision_id, revno)] A list of known
            revno, revision_id tuples. We'll use this to seed the search.
        iiN(
RRt
NULL_REVISIONRRRRRRR2RRtGhostRevisionsHaveNoRevnoRd(Rttarget_revision_idtknown_revision_idstknown_revnostcur_tipt	num_stepsRitsearching_known_tipstunknown_searchedt	to_searchR4Rgtnext_known_tipstrevision_idtnextt
next_revno((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_distance_to_nullWsB	



	




cC@s˜i}g}g}xU|D]M}y#|j||j||ƒfƒWqtjk
re|j|ƒqXqWx!|D]}|j|dfƒqqWt|ƒS(s™Find the distance to null for all the keys in keys.

        :param keys: keys to lookup.
        :return: A dict key->distance for all of keys.
        iÿÿÿÿ(RdRwRRjR(RRR5RmtghostsR/((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_lefthand_distancesŒs

c	C@sÅ||krtƒS|j|g|ƒ\}}|jj|jƒ}|sM|S|j|||ƒ\}}|j||||ƒ|j|jƒ}dtjkrÁtj	dt
|ƒt
|ƒƒn|S(srFind the unique ancestors for a revision versus others.

        This returns the ancestry of unique_revision, excluding all revisions
        in the ancestry of common_revisions. If unique_revision is in the
        ancestry, then the empty set will be returned.

        :param unique_revision: The revision_id whose ancestry we are
            interested in.
            (XXX: Would this API be better if we allowed multiple revisions on
            to be searched here?)
        :param common_revisions: Revision_ids of ancestries to exclude.
        :return: A set of revisions in the ancestry of unique_revision
        RVs%Found %d truly unique nodes out of %d(Rt_find_initial_unique_nodesRFRGt_make_unique_searcherst_refine_unique_nodesRtdebug_flagsRtmuttertlen(	Rtunique_revisiontcommon_revisionstunique_searchertcommon_searchertunique_nodestall_unique_searchertunique_tip_searchersttrue_unique_nodes((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_unique_ancestors¡s 	
	c	C@sÙ|j|ƒ}|jƒ|j|ƒ}x¤|jrÎt|jƒƒ}t|jƒƒ}|j|jƒ}|j|j|jƒƒ|r+|j|ƒ}|j|j|ƒƒ|j	|ƒ|j
|ƒq+q+W||fS(süSteps 1-3 of find_unique_ancestors.

        Find the maximal set of unique nodes. Some of these might actually
        still be common, but we are sure that there are no other unique nodes.

        :return: (unique_searcher, common_searcher)
        (RQRut_next_queryRR\RYRFRR[RZtstart_searching(	Rtunique_revisionsRR‚Rƒtnext_unique_nodestnext_common_nodestunique_are_common_nodest	ancestors((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRzØs"	
	
c
C@s½|j||j|ƒƒ}t|ƒdkrEg}|j|ƒ}nµg}xe|D]]}|j|gƒ}|j|j|ƒƒ|j|ƒ}	||	_|	jƒ|j|	ƒqRWd}x>|D]6}	|dkrät
|	jƒ}qÀ|j|	jƒ}qÀW|j|ƒ}
|rm|
jƒ|j
|j|ƒƒ}d}x3|D](}	|t|	j
|	j|ƒƒƒ7}q>Wndtjkr³tjdt|ƒt|ƒ|t|ƒt|ƒƒn|
|fS(sCreate a searcher for all the unique search tips (step 4).

        As a side effect, the common_searcher will stop searching any nodes
        that are ancestors of the unique searcher tips.

        :return: (all_unique_searcher, unique_tip_searchers)
        iiRVsuFor %d unique nodes, created %d + 1 unique searchers (%d stopped search tips, %d common ancestors (%d stopped common)N(t_remove_simple_descendantsRRR[RRQt_labelR\RdRRRFRYRZRR}RR~(
RR„R‚Rƒtunique_tipsR†tancestor_all_uniquettiptrevs_to_searchRWR…tstopped_commont
total_stopped((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR{ÿsH		
	

	

	c	C@sÇt|jƒƒ}tƒ}xŸ|D]—}t|jƒƒ}|j|j|ƒƒ|j|j|ƒƒx6|D].}||kr…qmn|j|j|ƒƒqmW|j|ƒ|j|ƒq"W||fS(sStep all the searchers(RR\RR[RŠ(	RRƒR†R‚tnewly_seen_commontnewly_seen_uniqueRWRutalt_searcher((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt!_step_unique_and_common_searchers;s	


c
C@s¼|jƒ}x|D]}|j|jƒqW|j|jƒ|r¸tjƒ}|jƒ}|j|ƒdtjkr¸tjƒ|}	t	j
d|	t|ƒt|jƒ|jƒq¸n|S(sŸFind nodes that are common to all unique_tip_searchers.

        If it is time, step the all_unique_searcher, and add its nodes to the
        result.
        RVsKall_unique_searcher step() took %.3fsfor %d nodes (%d total), iteration: %s(
tcopytintersection_updateRFttimetclockR\RRR}RR~Rt_iterations(
RR†R…R™tstep_all_uniquetcommon_to_all_unique_nodesRWttstarttnodesttdelta((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt _find_nodes_common_to_all_uniqueMs


	c
C@sei}x–|D]Ž}|j|ƒ}t|jƒ}|sndtjkr›tjd|j|jt	|ƒƒq›q
||krŠ|g||<q
||j
|ƒq
Wg}x¹|jƒD]«}t	|ƒdkrÞ|j
|dƒq²|d}	x%|dD]}|	jj
|jƒqóWdtjkrPtjdt	|ƒt	|	jƒt	|	jƒƒn|j
|	ƒq²W|S(sWCombine searchers that are searching the same tips.

        When two searchers are searching the same tips, we can stop one of the
        searchers. We also know that the maximal set of common ancestors is the
        intersection of the two original searchers.

        :return: A list of searchers that are searching unique nodes.
        RVs@Unique searcher %s was stopped. (%s iterations) %d nodes stoppediisQCombining %d searchers into a single searcher searching %d nodes with %d ancestry(RZt	frozensetR‰RR}RR~R‘R RRdt
itervaluesRFR(
RR†R¢tunique_search_tipsRWtstoppedtwill_search_settnext_unique_searchersRKt
next_searcher((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt_collapse_unique_searchersis6
	
		c
C@s&d}x|jr!|j|||ƒ\}}|j||||dkƒ}|dt}|r{|j|jj|ƒƒn|r´|j|j|ƒƒ|j	|ƒ|j|ƒn|j
||ƒ}	t|ƒt|	ƒkrdtj
krtjdt|ƒt|	ƒ|jƒqn|	}q	WdS(sŽSteps 5-8 of find_unique_ancestors.

        This function returns when common_searcher has stopped searching for
        more nodes.
        iiRVs4Collapsed %d unique searchers => %d at %s iterationsN(R‰R›R¦tSTEP_UNIQUE_SEARCHER_EVERYRZRFRYRR[RŠR®RRR}RR~R (
RR‚R…R†Rƒtstep_all_unique_counterR˜R™R¢R¬((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR|žs6		

			cC@sCi}x6|j|ƒD]%\}}|dk	r|||<qqW|S(s¯Get a map of key:parent_list for revisions.

        This implementation delegates to get_parents, for old parent_providers
        that do not supply get_parent_map.
        N(R<R(RR@R5trevRg((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRÒs
cC@s
t||ƒS(N(t_BreadthFirstSearcher(RR@((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRQÞscC@sd|kr!tjd|ƒ‚ntƒ}g|D]}|j|gƒ^q1}|}tƒ}x­trtƒ}x0|D](}|jƒ}	|	rx|j|	ƒqxqxWtƒ}
xk|D]c}||krÙ|
j|ƒq´nx;|D]}||j	kràPqàqàW|j|ƒ|
j|ƒq´W|
rvx$|D]}|
j|j
|
ƒƒq(Wx|D]}|j|
ƒqOW|j|
ƒntƒ}x9|D]1}t|j
ƒ}
|
|kr†|j|
ƒq†q†Wt|ƒdkrb|jƒ}|j|ƒ}|rtd||fƒ‚nPqbqbW|||fS(sWFind common ancestors with at least one uncommon descendant.

        Border ancestors are identified using a breadth-first
        search starting at the bottom of the graph.  Searches are stopped
        whenever a node or one of its descendants is determined to be common.

        This will scale with the number of uncommon ancestors.

        As well as the border ancestors, a set of seen common ancestors and a
        list of sets of seen ancestors for each input revision is returned.
        This allows calculation of graph difference from the results of this
        operation.
        ismSomehow we ended up converging without actually marking them as in common.
Start_nodes: %s
uncommon_nodes: %sN(RRtInvalidRevisionIdRRQR&R\RR7RFR[RŠR§R‰RtpopRGR((RR@tcommon_ancestorstrRKtactive_searcherstborder_ancestorst
newly_seenRWt
new_ancestorst
new_commonRtunique_search_setsR«R¤tuncommon_nodes((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR>ásT	"			
	





	
c
@s}t|ƒ}tj|krD|jtjƒ|sDttjgƒSnt|ƒdkrZ|St‡fd†|Dƒƒ}t|ƒ}x|jƒD]}|jƒqWˆjgƒ}xÄt|ƒdkrxtƒ}y|jƒWnt	k
rñnXxn|j
ƒD]`}y||}Wntk
r)qÿnXy|j|jƒƒWqÿt	k
r^||=qÿqÿXqÿWtƒ}	xù|D]ñ}
|
|kr²|j|
ƒ||
=|
|kr²||
=q²n|
|j
kr÷t|
gƒ}x‘|jƒD]}|j|ƒqÝWqsxj|jƒD]}|
|j
krPqqW|	j|
ƒx3|jƒD]%}|j|
gƒ}|j|ƒq;WqsW|j|	ƒqµW|S(saReturn the heads from amongst keys.

        This is done by searching the ancestries of each key.  Any key that is
        reachable from another key is not returned; all the others are.

        This operation scales with the relative depth between any two keys. If
        any two keys are completely disconnected all ancestry of both sides
        will be retrieved.

        :param keys: An iterable of keys.
        :return: A set of the heads. Note that as a set there is no ordering
            information. Callers will need to filter their input to create
            order if they need it.
        ic3@s'|]}|ˆj|gƒfVqdS(N(RQ(R0tc(R(s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pys	<genexpr>Bsi(RRRitremoveRRR¨RuRQt
StopIterationRtKeyErrorRRFRZR7R[RŠ(
RRtcandidate_headsRKR·RWt
common_walkerRt	candidateR»tancestortancestor_settseen_ancestors((Rs0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR?+sb
	


	



c
C@s/t|ƒdkrt|ƒSt|ƒ}|g}g}tƒ}xè|r*|r*|jƒ}|j|ƒ||kr½|j|ƒ|j|ƒt|ƒdkrC|j|jƒƒPqCqCn|j|gƒj|dƒ}|sçqCnx=t
|ƒD]/}	|	|kr|j|	ƒn|j|	ƒqôWqCW|S(s¶Find the order that each revision was merged into tip.

        This basically just walks backwards with a stack, and walks left-first
        until it finds a node to stop.
        iN(RRRRR´R7RdR¿RR2Rtreversed(
Rttip_revision_idtlca_revision_idstlooking_fortstackRR]Rut
parent_idst	parent_id((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_merge_order„s0
			


cC@sR|j||ƒ}|j|ƒ}d}x$|D]}||krD|S|}q.WdS(sFind the first lefthand ancestor of tip_key that merged merged_key.

        We do this by first finding the descendants of merged_key, then
        walking through the lefthand ancestry of tip_key until we find a key
        that doesn't descend from merged_key.  Its child is the key that
        merged merged_key.

        :return: The first lefthand ancestor of tip_key to merge merged_key.
            merged_key if it is a lefthand ancestor of tip_key.
            None if no ancestor of tip_key merged merged_key.
        N(RXtiter_lefthand_ancestryR(Rt
merged_keyttip_keyR^tcandidate_iteratortlast_candidateRÄ((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_lefthand_merger³s
cC@sž||g}d}x…tr™|d7}|j|Œ}t|ƒdkri|jƒ}|rb||fS|Snt|ƒdkrtj||ƒ‚n|}qWdS(s‚Find a unique LCA.

        Find lowest common ancestors.  If there is no unique  common
        ancestor, find the lowest common ancestors of those ancestors.

        Iteration stops when a unique lowest common ancestor is found.
        The graph origin is necessarily a unique lowest common ancestor.

        Note that None is not an acceptable substitute for NULL_REVISION.
        in the input for this method.

        :param count_steps: If True, the return value will be a tuple of
            (unique_lca, steps) where steps is the number of times that
            find_lca was run.  If False, only unique_lca is returned.
        iiN(R&RDRR´RtNoCommonAncestor(RRHRItcount_stepsR@tstepstlcaR5((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytfind_unique_lcaÇs	

c#@s¹t|ƒ}tƒ‰x|r´ˆj|ƒ|j|ƒ}tƒ}x:|jƒD],}|V|j‡fd†|dDƒƒqPW|j|ƒ}x|D]}|dfVq–W|}qWdS(sÕIterate the ancestry of this revision.

        :param revision_ids: Nodes to start the search
        :return: Yield tuples mapping a revision_id to its parents for the
            ancestry of revision_id.
            Ghosts will be returned with None as their parents, and nodes
            with no parents will have NULL_REVISION as their only parent. (As
            defined by get_parent_map.)
            There will also be a node for (NULL_REVISION, ())
        c3@s!|]}|ˆkr|VqdS(N((R0tp(t	processed(s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pys	<genexpr>úsiN(RRRt	iteritemsRGR(Rtrevision_idstpendingtnext_maptnext_pendingtitemRxtghost((RÜs0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt
iter_ancestryçs		
	%
c#@s|dkrd}n|‰‡‡fd†}xKtrzˆ|krFdS|ˆƒ}ˆVt|ƒdkrmdS|d‰q0WdS(Nc@sEyˆjj|gƒ|SWn#tk
r@tjˆˆƒ‚nXdS(N(R=RRÁRtRevisionNotPresent(R/(tnext_keyR(s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR<s
i((RR&R(Rt	start_keyt	stop_keysR<Rg((RæRs0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRÐs		cC@s2ddlm}|j|j|ƒƒ}|jƒS(sIterate through the input revisions in topological order.

        This sorting only ensures that parents come before their children.
        An ancestor may sort after a descendant if the relationship is not
        visible in the supplied list of revisions.
        i(ttsort(tbzrlibRét
TopoSorterRtiter_topo_order(RR@Rétsorter((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRìscC@s"t|gƒ|j||gƒkS(sýDetermine whether a revision is an ancestor of another.

        We answer this using heads() as heads() has the logic to perform the
        smallest number of parent lookups to determine the ancestral
        relationship between N revisions.
        (RR?(Rtcandidate_ancestortcandidate_descendant((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytis_ancestorscC@s:|dks|j||ƒo9|dkp9|j||ƒS(sšDetermine whether a revision is between two others.

        returns true if and only if:
        lower_bound_revid <= revid <= upper_bound_revid
        N(RRð(Rtrevidtlower_bound_revidtupper_bound_revid((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt
is_between(scC@sÀt|ƒdkr!tdƒ‚n|}|d}|d}|jj|jƒ}|sZdSt|ƒ}|j||j|ƒƒ}t|ƒ}g}	xv|D]n}
|
|jkr¸|}n|}|j|
gƒ}|sâ|
g}n|j|ƒ}
|
jƒ|	j	|
ƒqšWd}x>|	D]6}
|dkr=t|
jƒ}q|j|
jƒ}qWt
jd||ƒxStr»tƒ}x!|D]}
|j|
jƒƒqWtƒ}x!|	D]}
|j|
jƒƒq¬Wtƒ}x?|D]7}x.|	D]}
||
jkræPqæqæW|j|ƒqÙW|r˜x$|D]}
|j|
j|ƒƒq!Wx|D]}
|
j|ƒqHW|j|ƒ}|r˜x|D]}
|
j|ƒq{Wq˜n|r–x$|	D]}
|j|
j|ƒƒq¥Wx$|D]}
|j|
j|ƒƒqÌWx|	D]}
|
j|ƒqóWx|D]}
|
j|ƒqW|j|ƒg}tƒ}xF|	D]>}
t|
jƒ}||krK|j|ƒ|j	|
ƒqKqKW|}	nx|D]}
|
jrPqqWdSqiWdS(sbMake sure that unique nodes are genuinely unique.

        After _find_border_ancestors, all nodes marked "common" are indeed
        common. Some of the nodes considered unique are not, due to history
        shortcuts stopping the searches early.

        We know that we have searched enough when all common search tips are
        descended from all unique (uncommon) nodes because we know that a node
        cannot be an ancestor of its own ancestor.

        :param common: A set of common nodes
        :param searchers: The searchers returned from _find_border_ancestors
        :return: None
        is/Algorithm not yet implemented for > 2 searchersiiNs3Started %s unique searchers for %s unique revisions(RtNotImplementedErrorRFtsymmetric_differenceRRR[RQR\RdRRRYRR~R&RR7RŠRZR§R‰(RRBRKtcommon_searcherst
left_searchertright_searchertuniquettotal_uniquet
simple_uniquetunique_searchersRttparent_searcherR•RWR“R˜R™tnew_common_uniqueRtstop_searching_commonR¬R¼R«((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRE3s 

	
	

	
		
	
	



	





	

	
	cC@sm|jƒ}xZ|jƒD]L\}}|dkr7qnx+|D]#}||kr>|j|ƒPq>q>WqW|S(sMremove revisions which are children of other ones in the set

        This doesn't do any graph searching, it just checks the immediate
        parent_map to find if there are any children which can be removed.

        :param revisions: A set of revision_ids
        :return: A set of revision_ids with the children removed
        N(RœRÝRtdiscard(RR@R4tsimple_ancestorsRRÍRÎ((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRÇs	

N(#RRRR	R
RDRNRXRPRORwRyRˆRzR{R›R¦R®R|RRQR>R?RÏRÕtFalseRÚRäRRÐRìRðRôRER(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR;és>			(							5		7	'	<			5	4			J	Y	/				
		”t
HeadsCachecB@s eZdZd„Zd„ZRS(s)A cache of results for graph heads calls.cC@s||_i|_dS(N(RVt_heads(RRV((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR	ós	cC@s_t|ƒ}yt|j|ƒSWn7tk
rZ|jj|ƒ}||j|<t|ƒSXdS(s Return the heads of keys.

        This matches the API of Graph.heads(), specifically the return value is
        a set which can be mutated, and ordering of the input is not preserved
        in the output.

        :see also: Graph.heads.
        :param keys: The keys to calculate heads for.
        :return: A set containing the heads, which may be mutated without
            affecting future lookups.
        N(R§RRRÁRVR?(RRR?((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR?÷s

(RRRR	R?(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRðs	tFrozenHeadsCachecB@s)eZdZd„Zd„Zd„ZRS(s;Cache heads() calls, assuming the caller won't modify them.cC@s||_i|_dS(N(RVR(RRV((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR	s	cC@sYt|ƒ}y|j|SWn7tk
rTt|jj|ƒƒ}||j|<|SXdS(s-Return the heads of keys.

        Similar to Graph.heads(). The main difference is that the return value
        is a frozen set which cannot be mutated.

        :see also: Graph.heads.
        :param keys: The keys to calculate heads for.
        :return: A frozenset containing the heads.
        N(R§RRÁRVR?(RRR?((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR?s


cC@st|ƒ|jt|ƒ<dS(sStore a known value.N(R§R(RRR?((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR.%s(RRRR	R?R.(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRs		R²cB@sƒeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„Zd
„ZRS(sôParallel search breadth-first the ancestry of revisions.

    This class implements the iterator protocol, but additionally
    1. provides a set of seen ancestors, and
    2. allows some ancestries to be unsearched, via stop_searching_any
    cC@syd|_t|ƒ|_tƒ|_t|jƒ|_tƒ|_||_d|_tƒ|_tƒ|_	i|_
dS(Nitnext_with_ghosts(R RR‰RFt
_started_keyst
_stopped_keysR=t
_returningt_current_presentt_current_ghostst_current_parents(RR@R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR	2s			cC@sN|jrd}nd}d|t|jƒf}d|j|t|jƒfS(Nt	searchingtstartings%s=%rs1_BreadthFirstSearcher(iterations=%d, %s, seen=%r)(R RRR‰RF(Rtprefixtsearch((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR
>s		cC@sŒ|jdkrO|j|jƒ\}}}}|jj|ƒ|j|ƒ}n	|j}|jj|ƒ}|jj|ƒ}|j||fS(svGet the current state of this searcher.

        :return: Tuple with started keys, excludes and included keys
        Ru(	R
t	_do_queryR‰RFRtunionR	RGR(RRRxRuRgt
next_querytexcludest
included_keys((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt	get_stateGs	cC@s>ddlm}|jƒ\}}}|||t|ƒ|ƒS(sGet a SearchResult for the current state of this searcher.

        :return: A SearchResult for this search so far. The SearchResult is
            static - the search can be advanced and the search result will not
            be invalidated or altered.
        i(tSearchResult(tbzrlib.vf_searchRRR(RRtstarted_keysRR((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt_get_result]scC@s'y|jƒSWntk
r"dSXdS(N((RuRÀ(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR\is
cC@so|jdkr*d|_|jd7_n
|jƒt|jƒdkrUtƒ‚n|jj|jƒ|jS(sJReturn the next ancestors of this revision.

        Ancestors are returned in the order they are seen in a breadth-first
        traversal.  No ancestor will be returned more than once. Ancestors are
        returned before their parentage is queried, so ghosts and missing
        revisions (including the start revisions) are included in the result.
        This can save a round trip in LCA style calculation by allowing
        convergence to be detected without reading the data for the revision
        the convergence occurs on.

        :return: A set of revision_ids.
        Ruii(R
R t_advanceRR‰RÀRFR(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRuos
	
cC@s`|jdkr%d|_|jƒnt|jƒdkrFtƒ‚n|jƒ|j|jfS(s­Return the next found ancestors, with ghosts split out.

        Ancestors are returned in the order they are seen in a breadth-first
        traversal.  No ancestor will be returned more than once. Ancestors are
        returned only after asking for their parents, which allows us to detect
        which revisions are ghosts and which are not.

        :return: A tuple with (present ancestors, ghost ancestors) sets.
        Ri(R
RRR‰RÀRR(R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR‰s
	

cC@se|jd7_|j|jƒ\}}}}||_||_||_||_|jj|ƒdS(s«Advance the search.

        Updates self.seen, self._next_query, self._current_present,
        self._current_ghosts, self._current_parents and self._iterations.
        iN(R RR‰RRR
R	R(RRRxRuRg((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRœs				cC@sËtƒ}tƒ}|j}|j|ƒ|jj|ƒ}|j|ƒxg|jƒD]Y\}}|dkrrqTng|D]}||kry|^qy}	|	rT|j|	ƒqTqTW||}
||
||fS(sQuery for revisions.

        Adds revisions to the seen set.

        :param revisions: Revisions to query.
        :return: A tuple: (set(found_revisions), set(ghost_revisions),
           set(parents_of_found_revisions), dict(found_revisions:parents)).
        N(RRFRR=RRÝR(RR@tfound_revisionstparents_of_foundRFR4trev_idRgRÛtnew_found_parentstghost_revisions((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR¬s				

%
cC@s|S(N((R((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt__iter__ÈscC@sã|j}t|ƒj|ƒ}t|ƒ}|jdkrE|j}nd}|j|ƒ|jj}xx|rÞ||ƒ}g}x!|jƒD]}	|j	|	ƒqŒW|j|ƒj
|ƒ}
|j|
ƒ|
j|ƒ|
}qgW|S(sFind ancestors of these revisions that have already been seen.

        This function generally makes the assumption that querying for the
        parents of a node that has already been queried is reasonably cheap.
        (eg, not a round trip to a remote host).
        Ru((RFRRYR
R‰RR=RR¨textendRGR(RR@tall_seenRßRÇtnot_searched_yetRR4tall_parentsRÍRá((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR[Ës$	
	


cC@s³t|ƒ}|jdkrE|jj|ƒ}|jj|ƒ|_nJ|jj|ƒ}|j|jj|ƒƒ}|jj|ƒ|jj|ƒi}xO|D]G}x>|j	|D]/}||krÒd||<n||cd7<q³WqŸWxP|j	j
ƒD]?}x6|D].}y||cd8<Wqtk
r4qXqWqúWtƒ}x6|j
ƒD](\}	}
|
dkrS|j|	ƒqSqSW|jj|ƒ|jj|ƒ|jj|ƒ|S(s1
        Remove any of the specified revisions from the search list.

        None of the specified revisions are required to be present in the
        search list.

        It is okay to call stop_searching_any() for revisions which were seen
        in previous iterations. It is the callers responsibility to call
        find_seen_ancestors() to make sure that current search tips that are
        ancestors of those revisions are also stopped.  All explicitly stopped
        revisions will be excluded from the search result's get_keys(), though.
        Ruii(R§R
R‰RYRGRRRRR
R¨RÁRRÝR7R	R(RR@Rªtstopped_presenttstop_rev_referencesR±RÎRgtstop_parentsRtrefs((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRZñs:



	cC@sÙt|ƒ}|jj|ƒ|j|jƒ}|jdkr`|jj|ƒ|jj|ƒnu|j|ƒ\}}}}|jj|ƒ|j	j|ƒ|j
j|ƒ|jj|ƒ|jj|ƒ||fSdS(sWAdd revisions to the search.

        The parents of revisions will be returned from the next call to next()
        or next_with_ghosts(). If next_with_ghosts was the most recently used
        next* call then the return value is the result of looking up the
        ghost/not ghost status of revisions. (A tuple (present, ghosted)).
        RuN(R§RRRGRFR
R‰RR	RRR
(RR@t
new_revisionstrevsRxtqueryRg((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRŠ$s(RRRR	R
RRR\RuRRRR"R[RZRŠ(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR²*s												&	3cC@sii}x\|jƒD]N\}}x?|D]7}||krH|f||<q&|||f||<q&WqW|S(sCGiven a map from child => parents, create a map of parent=>children(RÝ(R4RURfRgRÛ((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytinvert_parent_map=s
cC@s_i}xT|jƒD]F\}}|j|gƒx'|D]}|j|gƒj|ƒq6WqWt|ƒ}tƒ}t|ƒ}xÚ|D]Ò}||}t|ƒdkr…||d}	t|	ƒdkrÍq…n||}
t|
ƒdkrïq…n|j|
ddƒ}t|ƒdkrq…n|||
d<|
||d<||=||=|j|ƒq…q…W|S(s!Collapse regions of the graph that are 'linear'.

    For example::

      A:[B], B:[C]

    can be collapsed by removing B and getting::

      A:[C]

    :param parent_map: A dictionary mapping children to their parents
    :return: Another dictionary with 'linear' chains collapsed
    iiN(	RÝRcRdRRRR2RR7(R4tchildrenRfRgRÛt
orig_childrentremovedR5tnodetparent_childrent
node_childrent
child_parents((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pytcollapse_linear_regionsLs4'
!	


tGraphThunkIdsToKeyscB@s;eZdZd„Zd„Zd„Zd„Zd„ZRS(s7Forwards calls about 'ids' to be about keys internally.cC@s
||_dS(N(t_graph(RRV((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR	˜scC@s#g|jjƒD]\}|^qS(N(R8t	topo_sort(RR¶((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR9›scC@sOg|D]}|f^q}|jj|ƒ}tg|D]}|d^q8ƒS(sSee Graph.heads()i(R8R?R(Rtidstitas_keyst	head_keysth((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR?žscC@s:|jj|fƒ}x|D]}|jd|_qW|S(Ni(R8t
merge_sortR/(Rttip_revisionR¤R2((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR?¤s
cC@s0|jj|fg|D]}|f^qƒdS(N(R8tadd_node(RRRgRÛ((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyRAªs(RRRR	R9R?R?RA(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyR7•s				(t
KnownGraph(t
__future__RRžRêRRRRRR¯tobjectRRR!R8R;RRR²R.R6R7t	_counterstbzrlib._known_graph_pyxRBtImportErrortetfailed_to_load_extensiontbzrlib._known_graph_py(((s0/usr/lib/python2.7/dist-packages/bzrlib/graph.pyt<module>s2(4Zÿÿÿÿÿ		I


Copyright © 2017 || Recoded By Mr.Bumblebee