-=[ Mr. Bumblebee ]=-
_Indonesia_

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

ó
ī:ļNc@@sŒdZddlmZddlmZmZmZddddgZ	d„Z
defd	„ƒYZded
„Zdefd„ƒYZdS(
sTopological sorting routines.i(tabsolute_import(terrorstgraphtrevisiont	topo_sortt
TopoSortert
merge_sorttMergeSortercC@stjt|ƒƒ}|jƒS(sŠTopological sort a graph.

    graph -- sequence of pairs of node->parents_list.

    The result is a list of node names, such that all parents come before their
    children.

    node identifiers can be any hashable object, and are typically strings.

    This function has the same purpose as the TopoSorter class, but uses a
    different algorithm to sort the graph. That means that while both return a
    list with parents before their child nodes, the exact ordering can be
    different.

    topo_sort is faster when the whole list is needed, while when iterating
    over a part of the list, TopoSorter.iter_topo_order should be used.
    (t
_mod_grapht
KnownGraphtdictR(Rtkg((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyR scB@s#eZd„Zd„Zd„ZRS(cC@st|ƒ|_dS(sTopological sorting of a graph.

        :param graph: sequence of pairs of node_name->parent_names_list.
                      i.e. [('C', ['B']), ('B', ['A']), ('A', [])]
                      For this input the output from the sort or
                      iter_topo_order routines will be:
                      'A', 'B', 'C'

        node identifiers can be any hashable object, and are typically strings.

        If you have a graph like [('a', ['b']), ('a', ['c'])] this will only use
        one of the two values for 'a'.

        The graph is sorted lazily: until you iterate or sort the input is
        not processed other than to create an internal representation.

        iteration or sorting may raise GraphCycleError if a cycle is present
        in the graph.
        N(R
t_graph(tselfR((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyt__init__8scC@st|jƒƒS(s|Sort the graph and return as a list.

        After calling this the sorter is empty and you must create a new one.
        (tlisttiter_topo_order(R
((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pytsortedOscc@s;|j}t|ƒ}g}g}tƒ}x
|r6|jƒ\}}|j|ƒ|jt|ƒƒxĖ|r2|d}|s©|jƒ}	|jƒ|j|	ƒ|	Vqh|jƒ}
|
|krĒqhn|
|krŁqhny|j|
ƒ}Wn tk
rtj	|ƒ‚nX|j|
ƒ|jt|ƒƒqhWq-WdS(sŸYield the nodes of the graph in a topological order.

        After finishing iteration the sorter is empty and you cannot continue
        iteration.
        i’’’’N(
RtsettpopitemtappendRtpoptaddtKeyErrorRtGraphCycleError(R
Rt	visitabletpending_node_stacktpending_parents_stacktcompleted_node_namest	node_nametparentstparents_to_visittpopped_nodetnext_node_name((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyR`s6			
	




(t__name__t
__module__RRR(((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyR6s		cC@st||||ƒjƒS(s§Topological sort a graph which groups merges.

    :param graph: sequence of pairs of node->parents_list.
    :param branch_tip: the tip of the branch to graph. Revisions not
                       reachable from branch_tip are not included in the
                       output.
    :param mainline_revisions: If not None this forces a mainline to be
                               used rather than synthesised from the graph.
                               This must be a valid path through some part
                               of the graph. If the mainline does not cover all
                               the revisions, output stops at the start of the
                               old revision listed in the mainline revisions
                               list.
                               The order for this parameter is oldest-first.
    :param generate_revno: Optional parameter controlling the generation of
        revision number sequences in the output. See the output description of
        the MergeSorter docstring for details.
    :result: See the MergeSorter docstring for details.

    Node identifiers can be any hashable object, and are typically strings.
    (RR(Rt
branch_tiptmainline_revisionstgenerate_revno((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyR¢scB@skeZdddddddddd	d
ddd
gZded„Zd„Zd„Zd„Zd„Z	RS(t_node_name_stackt_node_merge_depth_stackt_pending_parents_stackt_first_child_stackt_left_subtree_pushed_stackt_generate_revnoRt_mainline_revisionst_stop_revisiont_original_grapht_revnost_revno_to_branch_countt_completed_node_namest_scheduled_nodesc
C@sĶ||_t|ƒ|_|dkr9g|_d|_nt|ƒ|_|jd|_xšt|jdƒD]…\}}|j|}|dkr—qln|j|}|s°qln|d|krĘqln|j|j|ƒ|j|j	d|ƒqlWt|jj
ƒƒ|_td„|jDƒƒ|_i|_
g|_g|_g|_g|_tƒ|_g|_g|_|dk	rÉ|tjkrÉ|tjfkrÉ|jj|ƒ}	|j|d|	ƒndS(sNMerge-aware topological sorting of a graph.

        :param graph: sequence of pairs of node_name->parent_names_list.
                      i.e. [('C', ['B']), ('B', ['A']), ('A', [])]
                      For this input the output from the sort or
                      iter_topo_order routines will be:
                      'A', 'B', 'C'
        :param branch_tip: the tip of the branch to graph. Revisions not
                       reachable from branch_tip are not included in the
                       output.
        :param mainline_revisions: If not None this forces a mainline to be
                               used rather than synthesised from the graph.
                               This must be a valid path through some part
                               of the graph. If the mainline does not cover all
                               the revisions, output stops at the start of the
                               old revision listed in the mainline revisions
                               list.
                               The order for this parameter is oldest-first.
        :param generate_revno: Optional parameter controlling the generation of
            revision number sequences in the output. See the output description
            for more details.

        The result is a list sorted so that all parents come before
        their children. Each element of the list is a tuple containing:
        (sequence_number, node_name, merge_depth, end_of_merge)
         * sequence_number: The sequence of this row in the output. Useful for
           GUIs.
         * node_name: The node name: opaque text to the merge routine.
         * merge_depth: How many levels of merging deep this node has been
           found.
         * revno_sequence: When requested this field provides a sequence of
             revision numbers for all revisions. The format is:
             (REVNO, BRANCHNUM, BRANCHREVNO). BRANCHNUM is the number of the
             branch that the revno is on. From left to right the REVNO numbers
             are the sequence numbers within that branch of the revision.
             For instance, the graph {A:[], B:['A'], C:['A', 'B']} will get
             the following revno_sequences assigned: A:(1,), B:(1,1,1), C:(2,).
             This should be read as 'A is the first commit in the trunk',
             'B is the first commit on the first branch made from A', 'C is the
             second commit in the trunk'.
         * end_of_merge: When True the next node is part of a different merge.


        node identifiers can be any hashable object, and are typically strings.

        If you have a graph like [('a', ['b']), ('a', ['c'])] this will only use
        one of the two values for 'a'.

        The graph is sorted lazily: until you iterate or sort the input is
        not processed other than to create an internal representation.

        iteration or sorting may raise GraphCycleError if a cycle is present
        in the graph.

        Background information on the design:
        -------------------------------------
        definition: the end of any cluster or 'merge' occurs when:
            1 - the next revision has a lower merge depth than we do.
              i.e.
              A 0
              B  1
              C   2
              D  1
              E 0
              C, D are the ends of clusters, E might be but we need more data.
            2 - or the next revision at our merge depth is not our left most
              ancestor.
              This is required to handle multiple-merges in one commit.
              i.e.
              A 0    [F, B, E]
              B  1   [D, C]
              C   2  [D]
              D  1   [F]
              E  1   [F]
              F 0
              C is the end of a cluster due to rule 1.
              D is not the end of a cluster from rule 1, but is from rule 2: E
                is not its left most ancestor
              E is the end of a cluster due to rule 1
              F might be but we need more data.

        we show connecting lines to a parent when:
         - The parent is the start of a merge within this cluster.
           That is, the merge was not done to the mainline before this cluster
           was merged to the mainline.
           This can be detected thus:
            * The parent has a higher merge depth and is the next revision in
              the list.

          The next revision in the list constraint is needed for this case:
          A 0   [D, B]
          B  1  [C, F]   # we do not want to show a line to F which is depth 2
                           but not a merge
          C  1  [H]      # note that this is a long line to show back to the
                           ancestor - see the end of merge rules.
          D 0   [G, E]
          E  1  [G, F]
          F   2 [G]
          G  1  [H]
          H 0
         - Part of this merges 'branch':
          The parent has the same merge depth and is our left most parent and we
           are not the end of the cluster.
          A 0   [C, B] lines: [B, C]
          B  1  [E, C] lines: [C]
          C 0   [D]    lines: [D]
          D 0   [F, E] lines: [E, F]
          E  1  [F]    lines: [F]
          F 0
         - The end of this merge/cluster:
          we can ONLY have multiple parents at the end of a cluster if this
          branch was previously merged into the 'mainline'.
          - if we have one and only one parent, show it
            Note that this may be to a greater merge depth - for instance if
            this branch continued from a deeply nested branch to add something
            to it.
          - if we have more than one parent - show the second oldest (older ==
            further down the list) parent with
            an equal or lower merge depth
             XXXX revisit when awake. ddaa asks about the relevance of each one
             - maybe more than one parent is relevant
        iics@s!|]}|dtgfVqdS(N(tNonetTrue(t.0R((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pys	<genexpr>vsN(R,R
RR4R-R.Rt	enumeratetremovetinserttitemsR/R0R1R'R(R)R*RR2R3R+t
_mod_revisiont
NULL_REVISIONRt
_push_node(
R
RR$R%R&tindexRtparenttgraph_parent_idsR((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyRĪsD|		 

						
		cC@st|jƒƒS(s|Sort the graph and return as a list.

        After calling this the sorter is empty and you must create a new one.
        (RR(R
((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyR£scc@sĖ|j}|j}|j}|j}|j}|j}|jj}|j|j|j|j|j	j|j
d„}|j|j|j	j|j|j|j|j
|jj|j|j
d„
}	x|rĪ|d}
|
są|	ƒqĄxč|drŹ|ds|djdƒ}t}t|d<n|djƒ}t}||krEqćny||ƒ}
Wn5tk
rŒ||jkrćtj|ƒ‚qqćnXd}|r¢d}nd}|d|}||||
ƒPqćWqĄWd}|j}|j}|j}xŌ|rĘ|jƒ\}}}||krdSt|ƒs3t}nX|dd|krPt}n;|dd|kr…|dd||kr…t}nt}|rØ|||||fVn||||fV|d7}qóWdS(sŸYield the nodes of the graph in a topological order.

        After finishing iteration the sorter is empty and you cannot continue
        iteration.
        c	S@sš||ƒ||ƒ|tƒ|t|ƒƒd}	|rcy||d}	Wqctk
r_qcXn|	dk	r†|	d}
t|	d<nd}
||
ƒdS(sAdd node_name to the pending node stack.

            Names in this stack will get emitted into the output as they are popped
            off the stack.

            This inlines a lot of self._variable.append functions as local
            variables.
            iiN(tFalseRR4R(Rtmerge_depthRtnode_name_stack_appendtnode_merge_depth_stack_appendt left_subtree_pushed_stack_appendtpending_parents_stack_appendtfirst_child_stack_appendtrevnostparent_infotfirst_child((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyt	push_node»s





c
S@sS|ƒ}
|ƒ}|ƒ}|ƒ|ƒ||
}
d}|
rly||
dd}Wqltk
rhqlXn|dk	rą|sÄ|d}|	j|dƒ}|d7}||	|<|d|df}q$|d |ddf}nD|	jddƒ}|d7}|rd|df}nd}||	d<|||
d<||
ƒ||
||fƒ|
S(scPop the top node off the stack

            The node is appended to the sorted output.
            iii’’’’N(i(R4Rtget(tnode_name_stack_poptnode_merge_depth_stack_poptfirst_child_stack_poptleft_subtree_pushed_stack_poptpending_parents_stack_poptoriginal_graphRHtcompleted_node_names_addtscheduled_nodes_appendtrevno_to_branch_countRRBRJRtparent_revnot
base_revnotbranch_counttrevnot
root_count((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pytpop_nodeįs<			







i’’’’iiN(R'R(R)R+R2R3RRRR*R0R/RR1R5RARRRR.R,tlen(R
tnode_name_stacktnode_merge_depth_stackRtleft_subtree_pushed_stackRtscheduled_nodest	graph_popRKR[RR!tis_left_subtreeRtnext_merge_depthtsequence_numbert
stop_revisionR&RRRRBRYtend_of_merge((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyRŖs’							 		6	




	
								
	cC@s»|jj|ƒ|jj|ƒ|jjtƒ|jjt|ƒƒd}|r~y|j|d}Wq~t	k
rzq~Xn|dk	r”|d}t|d<nd}|j
j|ƒdS(s™Add node_name to the pending node stack.

        Names in this stack will get emitted into the output as they are popped
        off the stack.
        iiN(R'RR(R+RAR)RR4R0RR*(R
RRBRRIRJ((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyR=zs


c
C@s²|jjƒ}|jjƒ}|jjƒ}|jjƒ|jjƒ|j|}d}|ry|j|dd}Wqt	k
rŒqXn|dk	r
|sī|d}|j
j|dƒ}|d7}||j
|<|d|df}qi|d |ddf}n_|j
jddƒ}	|j
jddƒ}	|	d7}	|	rVd|	df}nd}|	|j
d<||j|d<|jj
|ƒ|jj|||j|dfƒ|S(s[Pop the top node off the stack

        The node is appended to the sorted output.
        iii’’’’N(i(R'RR(R*R+R)R/R4R0RR1RLR2RR3R(
R
RRBRJRRVRWRXRYRZ((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyt	_pop_node–s>








$N(
R"R#t	__slots__R4RARRRR=Rg(((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyR¼s(	Ō		Š	N(t__doc__t
__future__RtbzrlibRRRRR;t__all__RtobjectRR4RARR(((s0/usr/lib/python2.7/dist-packages/bzrlib/tsort.pyt<module>s	l

Copyright © 2017 || Recoded By Mr.Bumblebee