/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 bzrlib/_known_graph_py.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from __future__ import absolute_import
21
21
 
22
 
import collections
23
 
from . import (
 
22
from collections import deque
 
23
from bzrlib import (
24
24
    errors,
25
25
    revision,
26
26
    )
27
 
from .sixish import (
28
 
    viewitems,
29
 
    viewvalues,
30
 
    )
31
27
 
32
28
 
33
29
class _KnownGraphNode(object):
85
81
          child_keys,
86
82
        """
87
83
        nodes = self._nodes
88
 
        for key, parent_keys in viewitems(parent_map):
 
84
        for key, parent_keys in parent_map.iteritems():
89
85
            if key in nodes:
90
86
                node = nodes[key]
91
87
                node.parent_keys = parent_keys
101
97
                parent_node.child_keys.append(key)
102
98
 
103
99
    def _find_tails(self):
104
 
        return [node for node in viewvalues(self._nodes)
 
100
        return [node for node in self._nodes.itervalues()
105
101
                if not node.parent_keys]
106
102
 
107
103
    def _find_tips(self):
108
 
        return [node for node in viewvalues(self._nodes)
 
104
        return [node for node in self._nodes.itervalues()
109
105
                      if not node.child_keys]
110
106
 
111
107
    def _find_gdfo(self):
192
188
        # We use a deque rather than a simple list stack, to go for BFD rather
193
189
        # than DFD. So that if a longer path is possible, we walk it before we
194
190
        # get to the final child
195
 
        pending = collections.deque([node])
 
191
        pending = deque([node])
196
192
        while pending:
197
193
            node = pending.popleft()
198
194
            next_gdfo = node.gdfo + 1
238
234
        seen = set()
239
235
        pending = []
240
236
        min_gdfo = None
241
 
        for node in viewvalues(candidate_nodes):
 
237
        for node in candidate_nodes.values():
242
238
            if node.parent_keys:
243
239
                pending.extend(node.parent_keys)
244
240
            if min_gdfo is None or node.gdfo < min_gdfo:
265
261
 
266
262
        All parents must occur before all children.
267
263
        """
268
 
        for node in viewvalues(self._nodes):
 
264
        for node in self._nodes.itervalues():
269
265
            if node.gdfo is None:
270
266
                raise errors.GraphCycleError(self._nodes)
271
267
        pending = self._find_tails()
341
337
 
342
338
    def merge_sort(self, tip_key):
343
339
        """Compute the merge sorted graph output."""
344
 
        from breezy import tsort
 
340
        from bzrlib import tsort
345
341
        as_parent_map = dict((node.key, node.parent_keys)
346
 
                             for node in viewvalues(self._nodes)
 
342
                             for node in self._nodes.itervalues()
347
343
                              if node.parent_keys is not None)
348
344
        # We intentionally always generate revnos and never force the
349
345
        # mainline_revisions