/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tsort.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
        """
84
84
        return list(self.iter_topo_order())
85
85
 
86
 
# Useful if fiddling with this code.
87
 
# cross check
 
86
###        Useful if fiddling with this code.
 
87
###        # cross check
88
88
###        sorted_names = list(self.iter_topo_order())
89
 
# for index in range(len(sorted_names)):
 
89
###        for index in range(len(sorted_names)):
90
90
###            rev = sorted_names[index]
91
 
# for left_index in range(index):
92
 
# if rev in self.original_graph[sorted_names[left_index]]:
93
 
# print "revision in parent list of earlier revision"
 
91
###            for left_index in range(index):
 
92
###                if rev in self.original_graph[sorted_names[left_index]]:
 
93
###                    print "revision in parent list of earlier revision"
94
94
###                    import pdb;pdb.set_trace()
95
95
 
96
96
    def iter_topo_order(self):
182
182
    Node identifiers can be any hashable object, and are typically strings.
183
183
    """
184
184
    return MergeSorter(graph, branch_tip, mainline_revisions,
185
 
                       generate_revno).sorted()
 
185
        generate_revno).sorted()
186
186
 
187
187
 
188
188
class MergeSorter(object):
201
201
                 '_revno_to_branch_count',
202
202
                 '_completed_node_names',
203
203
                 '_scheduled_nodes',
204
 
                 ]
 
204
                ]
205
205
 
206
206
    def __init__(self, graph, branch_tip, mainline_revisions=None,
207
 
                 generate_revno=False):
 
207
        generate_revno=False):
208
208
        """Merge-aware topological sorting of a graph.
209
209
 
210
210
        :param graph: sequence of pairs of node_name->parent_names_list.
410
410
        self._left_subtree_pushed_stack = []
411
411
 
412
412
        # seed the search with the tip of the branch
413
 
        if (branch_tip is not None
414
 
            and branch_tip != _mod_revision.NULL_REVISION
415
 
                and branch_tip != (_mod_revision.NULL_REVISION,)):
 
413
        if (branch_tip is not None and
 
414
            branch_tip != _mod_revision.NULL_REVISION and
 
415
            branch_tip != (_mod_revision.NULL_REVISION,)):
416
416
            parents = self._graph.pop(branch_tip)
417
417
            self._push_node(branch_tip, 0, parents)
418
418
 
488
488
                     completed_node_names_add=self._completed_node_names.add,
489
489
                     scheduled_nodes_append=scheduled_nodes.append,
490
490
                     revno_to_branch_count=self._revno_to_branch_count,
491
 
                     ):
 
491
                    ):
492
492
            """Pop the top node off the stack
493
493
 
494
494
            The node is appended to the sorted output.
540
540
            scheduled_nodes_append((node_name, merge_depth, revno))
541
541
            return node_name
542
542
 
 
543
 
543
544
        while node_name_stack:
544
545
            # loop until this call completes.
545
546
            parents_to_visit = pending_parents_stack[-1]
617
618
            elif scheduled_nodes[-1][1] < merge_depth:
618
619
                # the next node is to our left
619
620
                end_of_merge = True
620
 
            elif (scheduled_nodes[-1][1] == merge_depth
621
 
                  and (scheduled_nodes[-1][0] not in
622
 
                       original_graph[node_name])):
 
621
            elif (scheduled_nodes[-1][1] == merge_depth and
 
622
                  (scheduled_nodes[-1][0] not in
 
623
                   original_graph[node_name])):
623
624
                # the next node was part of a multiple-merge.
624
625
                end_of_merge = True
625
626
            else:
708
709
        # store the revno for this node for future reference
709
710
        self._revnos[node_name][0] = revno
710
711
        self._completed_node_names.add(node_name)
711
 
        self._scheduled_nodes.append(
712
 
            (node_name, merge_depth, self._revnos[node_name][0]))
 
712
        self._scheduled_nodes.append((node_name, merge_depth, self._revnos[node_name][0]))
713
713
        return node_name