-=[ Mr. Bumblebee ]=-
_Indonesia_

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

σ
ξ:οNc@@s‚dZddlmZddlmZddlmZmZdefd„ƒYZ	defd„ƒYZ
d	efd
„ƒYZdS(sKImplementation of Graph algorithms when we have already loaded everything.
i(tabsolute_import(tdeque(terrorstrevisiont_KnownGraphNodecB@s&eZdZdZd„Zd„ZRS(s.Represents a single object in the known graph.tkeytparent_keyst
child_keystgdfocC@s(||_||_g|_d|_dS(N(RRRtNoneR(tselfRR((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyt__init__"s			cC@s)d|jj|j|j|j|jfS(Ns%s(%s  gdfo:%s par:%s child:%s)(t	__class__t__name__RRRR(R
((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyt__repr__)s(skeysparent_keyss
child_keyssgdfo(R
t
__module__t__doc__t	__slots__RR(((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyRs	t_MergeSortNodecB@seZdZdZd„ZRS(s5Information about a specific node in the merge graph.Rtmerge_depthtrevnotend_of_mergecC@s(||_||_||_||_dS(N(RRRR(R
RRRR((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyR4s			(skeysmerge_depthsrevnosend_of_merge(R
RRRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyR/st
KnownGraphcB@s}eZdZed„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd	„Zd
„Z
d„Zd„ZRS(
s=This is a class which assumes we already know the full graph.cC@s6i|_i|_||_|j|ƒ|jƒdS(snCreate a new KnownGraph instance.

        :param parent_map: A dictionary mapping key => parent_keys
        N(t_nodest_known_headstdo_cachet_initialize_nodest
_find_gdfo(R
t
parent_mapR((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyR>s
			
cC@sΑ|j}x±|jƒD]£\}}||krD||}||_nt||ƒ}|||<xY|D]Q}y||}Wn*tk
r€t|dƒ}|||<nX|jj|ƒqdWqWdS(sPopulate self._nodes.

        After this has finished:
        - self._nodes will have an entry for every entry in parent_map.
        - ghosts will have a parent_keys = None,
        - all nodes found will also have .child_keys populated with all known
          child_keys,
        N(Rt	iteritemsRRtKeyErrorR	Rtappend(R
RtnodesRRtnodet
parent_keytparent_node((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyRJs		



cC@s)g|jjƒD]}|js|^qS(N(Rt
itervaluesR(R
R!((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyt_find_tailscscC@s)g|jjƒD]}|js|^qS(N(RR$R(R
R!((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyt
_find_tipsgsc	C@s#|j}i}g}x*|jƒD]}d|_|j|ƒq"WxΪ|r|jƒ}xΑ|jD]Ά}||}||kr”||d}t}nd}t}|jdksΕ|jd|jkrΨ|jd|_n|t	|j
ƒkr
|j|ƒ|r||=qqa|||<qaWqEWdS(Ni(RR%RRtpopRtTruetFalseR	tlenR(	R
R tknown_parent_gdfostpendingR!t	child_keytchildt
known_gdfotpresent((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyRks,			
	%

c
C@sΉ|j}||krŽ||}|jdkrG||_|jjƒq§t|ƒ}t|jƒ}||krrdStd|||fƒ‚nt||ƒ}|||<d}x}|D]u}y||}Wn3tk
rύt|dƒ}d|_	|||<nX||j	kr|j	}n|j
j|ƒq΄W|d|_	t|gƒ}	xi|	r΄|	j
ƒ}|j	d}
xC|j
D]8}||}|j	|
kru|
|_	|	j|ƒququWqLWdS(srAdd a new node to the graph.

        If this fills in a ghost, then the gdfos of all children will be
        updated accordingly.
        
        :param key: The node being added. If this is a duplicate, this is a
            no-op.
        :param parent_keys: The parents of the given node.
        :return: None (should we return if this was a ghost, etc?)
        Ns>Parent key mismatch, existing node %s has parents of %s not %sii(RRR	Rtcleartlistt
ValueErrorRRRRRRtpopleft(
R
RRR R!texisting_parent_keystparent_gdfoR"R#R,t	next_gdfoR-R.((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pytadd_nodeŠsF	
	


	
		

	c@sΌt‡fd†|Dƒƒ}tj|krT|jtjƒ|sTttjgƒSnt|ƒdkrpt|ƒSt|ƒ}yˆj|}|SWntk
r€nXtƒ}g}d}xW|j
ƒD]I}|jrι|j|jƒn|dks|j
|krΗ|j
}qΗqΗWˆj}	xp|r|jƒ}
|
|krDq n|j|
ƒ|	|
}|j
|krpq n|jr |j|jƒq q W|j|ƒ}ˆjrΈ|ˆj|<n|S(s+Return 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. It
        uses gdfo to avoid walking all ancestry.

        :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.
        c3@s"|]}|ˆj|fVqdS(N(R(t.0R(R
(s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pys	<genexpr>ΩsiN(tdictRt
NULL_REVISIONR't	frozensetR*RRtsetR	tvaluesRtextendRRtaddt
differenceR(R
tkeystcandidate_nodest	heads_keytheadstseenR,tmin_gdfoR!R tnode_key((R
s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyREΛsH


				

		cC@sx;|jjƒD]*}|jdkrtj|jƒ‚qqW|jƒ}|j}|j}g}|j}t	j
|jdƒ}x”|r|ƒ}|jdk	r±||jƒnx_|j
D]T}|j|}	||d}
|
t|	jƒkr||	ƒ||=q»|
||<q»WqƒW|S(sdReturn the nodes in topological order.

        All parents must occur before all children.
        iiN(RR$RR	RtGraphCycleErrorR%R'RR:tfromkeysRRRR*(R
R!R,tpending_poptpending_appendt
topo_orderttopo_order_appendtnum_seen_parentsR-t
child_nodetseen_parents((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyt	topo_sorts*					


cC@s}|jƒ}i}xd|D]\}|jjtksFt|jƒdkrOd}n
|jd}|j|gƒj|ƒqWtj|j	dƒ}g}xβt
|ƒD]Τ}t
||dd„dtƒ}x¬|rt|jƒ}|j
dkrπqΙn|j|jƒxnt
|j
dtƒD]W}|j	|}	||d}
|
t|	jƒkrc|j|	ƒ||=q|
||<qWqΙWq‘W|S(sΨReturn a reverse topological ordering which is 'stable'.

        There are a few constraints:
          1) Reverse topological (all children before all parents)
          2) Grouped by prefix
          3) 'stable' sorting, so that we get the same result, independent of
             machine, or extra data.
        To do this, we use the same basic algorithm as topo_sort, but when we
        aren't sure what node to access next, we sort them lexicographically.
        itiRcS@s|jS(N(R(tn((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyt<lambda>>streverseN(R&RRtstrR*t
setdefaultRR:RJRtsortedR(R'RR	R(R
ttipstprefix_tipsR!tprefixtnum_seen_childrentresultR,R"R#t
seen_children((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pytgc_sort%s2
'	
		


c	C@s|ddlm}td„|jjƒDƒƒ}g|j||dddtƒD]*\}}}}}t||||ƒ^qNS(s&Compute the merge sorted graph output.i(ttsortcs@s0|]&}|jdk	r|j|jfVqdS(N(RR	R(R9R!((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pys	<genexpr>Ustmainline_revisionstgenerate_revnoN(	tbzrlibRaR:RR$t
merge_sortR	R(R(	R
ttip_keyRat
as_parent_mapt_RRRR((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyReRs	cC@s|j|jS(s/Get the parents for a key
        
        Returns a list containg the parents keys. If the key is a ghost,
        None is returned. A KeyError will be raised if the key is not in
        the graph.
        
        :param keys: Key to check (eg revision_id)
        :return: A list of parents
        (RR(R
R((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pytget_parent_keysas
cC@s|j|jS(sGet the children for a key
        
        Returns a list containg the children keys. A KeyError will be raised
        if the key is not in the graph.
        
        :param keys: Key to check (eg revision_id)
        :return: A list of children
        (RR(R
R((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pytget_child_keysms	(R
RRR(RRR%R&RR8RERRR`ReRiRj(((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyR;s					A	8	"	-		N(Rt
__future__RtcollectionsRRdRRtobjectRRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/_known_graph_py.pyt<module>s

Copyright © 2017 || Recoded By Mr.Bumblebee