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

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from __future__ import absolute_import
21
21
 
22
 
try:
23
 
    from collections.abc import deque
24
 
except ImportError:  # python < 3.7
25
 
    from collections import deque
 
22
import collections
26
23
from . import (
27
24
    errors,
28
25
    revision,
109
106
 
110
107
    def _find_tips(self):
111
108
        return [node for node in viewvalues(self._nodes)
112
 
                if not node.child_keys]
 
109
                      if not node.child_keys]
113
110
 
114
111
    def _find_gdfo(self):
115
112
        nodes = self._nodes
147
144
 
148
145
        If this fills in a ghost, then the gdfos of all children will be
149
146
        updated accordingly.
150
 
 
 
147
        
151
148
        :param key: The node being added. If this is a duplicate, this is a
152
149
            no-op.
153
150
        :param parent_keys: The parents of the given node.
166
163
                parent_keys = list(parent_keys)
167
164
                existing_parent_keys = list(node.parent_keys)
168
165
                if parent_keys == existing_parent_keys:
169
 
                    return  # Identical content
 
166
                    return # Identical content
170
167
                else:
171
 
                    raise ValueError(
172
 
                        'Parent key mismatch, existing node %s'
 
168
                    raise ValueError('Parent key mismatch, existing node %s'
173
169
                        ' has parents of %s not %s'
174
170
                        % (key, existing_parent_keys, parent_keys))
175
171
        else:
196
192
        # We use a deque rather than a simple list stack, to go for BFD rather
197
193
        # than DFD. So that if a longer path is possible, we walk it before we
198
194
        # get to the final child
199
 
        pending = deque([node])
 
195
        pending = collections.deque([node])
200
196
        while pending:
201
197
            node = pending.popleft()
202
198
            next_gdfo = node.gdfo + 1
323
319
 
324
320
        result = []
325
321
        for prefix in sorted(prefix_tips):
326
 
            pending = sorted(prefix_tips[prefix], key=lambda n: n.key,
 
322
            pending = sorted(prefix_tips[prefix], key=lambda n:n.key,
327
323
                             reverse=True)
328
324
            while pending:
329
325
                node = pending.pop()
348
344
        from breezy import tsort
349
345
        as_parent_map = dict((node.key, node.parent_keys)
350
346
                             for node in viewvalues(self._nodes)
351
 
                             if node.parent_keys is not None)
 
347
                              if node.parent_keys is not None)
352
348
        # We intentionally always generate revnos and never force the
353
349
        # mainline_revisions
354
350
        # Strip the sequence_number that merge_sort generates
355
351
        return [_MergeSortNode(key, merge_depth, revno, end_of_merge)
356
352
                for _, key, merge_depth, revno, end_of_merge
357
 
                in tsort.merge_sort(as_parent_map, tip_key,
358
 
                                    mainline_revisions=None,
359
 
                                    generate_revno=True)]
360
 
 
 
353
                 in tsort.merge_sort(as_parent_map, tip_key,
 
354
                                     mainline_revisions=None,
 
355
                                     generate_revno=True)]
 
356
    
361
357
    def get_parent_keys(self, key):
362
358
        """Get the parents for a key
363
 
 
 
359
        
364
360
        Returns a list containg the parents keys. If the key is a ghost,
365
361
        None is returned. A KeyError will be raised if the key is not in
366
362
        the graph.
367
 
 
 
363
        
368
364
        :param keys: Key to check (eg revision_id)
369
365
        :return: A list of parents
370
366
        """
372
368
 
373
369
    def get_child_keys(self, key):
374
370
        """Get the children for a key
375
 
 
 
371
        
376
372
        Returns a list containg the children keys. A KeyError will be raised
377
373
        if the key is not in the graph.
378
 
 
 
374
        
379
375
        :param keys: Key to check (eg revision_id)
380
376
        :return: A list of children
381
377
        """