~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_known_graph_py.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-07-09 00:44:25 UTC
  • mfrom: (4454.3.79 1.17-rework-annotate)
  • Revision ID: pqm@pqm.ubuntu.com-20090709004425-6tukiuklys5y02m5
(jam) Rework the internals of annotate to use a class object (fixes
        bug #387952)

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        - ghosts will have a parent_keys = None,
64
64
        - all nodes found will also have .child_keys populated with all known
65
65
          child_keys,
66
 
        - self._tails will list all the nodes without parents.
67
66
        """
68
 
        tails = self._tails = set()
69
67
        nodes = self._nodes
70
68
        for key, parent_keys in parent_map.iteritems():
71
69
            if key in nodes:
72
70
                node = nodes[key]
73
71
                node.parent_keys = parent_keys
74
 
                if parent_keys:
75
 
                    # This node has been added before being seen in parent_map
76
 
                    # (see below)
77
 
                    tails.remove(node)
78
72
            else:
79
73
                node = _KnownGraphNode(key, parent_keys)
80
74
                nodes[key] = node
84
78
                except KeyError:
85
79
                    parent_node = _KnownGraphNode(parent_key, None)
86
80
                    nodes[parent_key] = parent_node
87
 
                    # Potentially a tail, if we're wrong we'll remove it later
88
 
                    # (see above)
89
 
                    tails.add(parent_node)
90
81
                parent_node.child_keys.append(key)
91
82
 
 
83
    def _find_tails(self):
 
84
        return [node for node in self._nodes.itervalues()
 
85
                if not node.parent_keys]
 
86
 
92
87
    def _find_gdfo(self):
93
88
        nodes = self._nodes
94
89
        known_parent_gdfos = {}
95
90
        pending = []
96
91
 
97
 
        for node in self._tails:
 
92
        for node in self._find_tails():
98
93
            node.gdfo = 1
99
94
            pending.append(node)
100
95
 
144
139
            # No or only one candidate
145
140
            return frozenset(candidate_nodes)
146
141
        heads_key = frozenset(candidate_nodes)
147
 
        if heads_key != frozenset(keys):
148
 
            # Mention duplicates
149
 
            note('%s != %s', heads_key, frozenset(keys))
150
142
        # Do we have a cached result ?
151
143
        try:
152
144
            heads = self._known_heads[heads_key]