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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-02-03 23:21:15 UTC
  • mfrom: (7290.42.6 paramiko-compat)
  • Revision ID: breezy.the.bot@gmail.com-20200203232115-g7k11bhsfeiqcprv
Fix compatibility with newer versions of paramiko, which break on noise before keys in pem files.

Merged from https://code.launchpad.net/~jelmer/brz/paramiko-compat/+merge/378480

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    revision,
26
26
    trace,
27
27
    )
 
28
from .sixish import (
 
29
    viewitems,
 
30
    viewvalues,
 
31
    )
28
32
 
29
33
STEP_UNIQUE_SEARCHER_EVERY = 5
30
34
 
339
343
        """
340
344
        parent_map = self._parents_provider.get_parent_map(keys)
341
345
        parent_child = {}
342
 
        for child, parents in sorted(parent_map.items()):
 
346
        for child, parents in sorted(viewitems(parent_map)):
343
347
            for parent in parents:
344
348
                parent_child.setdefault(parent, []).append(child)
345
349
        return parent_child
650
654
        # TODO: it might be possible to collapse searchers faster when they
651
655
        #       only have *some* search tips in common.
652
656
        next_unique_searchers = []
653
 
        for searchers in unique_search_tips.values():
 
657
        for searchers in viewvalues(unique_search_tips):
654
658
            if len(searchers) == 1:
655
659
                # Searching unique tips, go for it
656
660
                next_unique_searchers.append(searchers[0])
839
843
                         for c in candidate_heads)
840
844
        active_searchers = dict(searchers)
841
845
        # skip over the actual candidate for each searcher
842
 
        for searcher in active_searchers.values():
 
846
        for searcher in viewvalues(active_searchers):
843
847
            next(searcher)
844
848
        # The common walker finds nodes that are common to two or more of the
845
849
        # input keys, so that we don't access all history when a currently
882
886
                    # some searcher has encountered our known common nodes:
883
887
                    # just stop it
884
888
                    ancestor_set = {ancestor}
885
 
                    for searcher in searchers.values():
 
889
                    for searcher in viewvalues(searchers):
886
890
                        searcher.stop_searching_any(ancestor_set)
887
891
                else:
888
892
                    # or it may have been just reached by all the searchers:
889
 
                    for searcher in searchers.values():
 
893
                    for searcher in viewvalues(searchers):
890
894
                        if ancestor not in searcher.seen:
891
895
                            break
892
896
                    else:
894
898
                        # making it be known as a descendant of all candidates,
895
899
                        # so we can stop searching it, and any seen ancestors
896
900
                        new_common.add(ancestor)
897
 
                        for searcher in searchers.values():
 
901
                        for searcher in viewvalues(searchers):
898
902
                            seen_ancestors =\
899
903
                                searcher.find_seen_ancestors([ancestor])
900
904
                            searcher.stop_searching_any(seen_ancestors)
1017
1021
            processed.update(pending)
1018
1022
            next_map = self.get_parent_map(pending)
1019
1023
            next_pending = set()
1020
 
            for item in next_map.items():
 
1024
            for item in viewitems(next_map):
1021
1025
                yield item
1022
1026
                next_pending.update(p for p in item[1] if p not in processed)
1023
1027
            ghosts = pending.difference(next_map)
1255
1259
        # for revision in revisions.intersection(descendants):
1256
1260
        # simple_ancestors.difference_update(descendants[revision])
1257
1261
        # return simple_ancestors
1258
 
        for revision, parent_ids in parent_map.items():
 
1262
        for revision, parent_ids in viewitems(parent_map):
1259
1263
            if parent_ids is None:
1260
1264
                continue
1261
1265
            for parent_id in parent_ids:
1462
1466
        seen.update(revisions)
1463
1467
        parent_map = self._parents_provider.get_parent_map(revisions)
1464
1468
        found_revisions.update(parent_map)
1465
 
        for rev_id, parents in parent_map.items():
 
1469
        for rev_id, parents in viewitems(parent_map):
1466
1470
            if parents is None:
1467
1471
                continue
1468
1472
            new_found_parents = [p for p in parents if p not in seen]
1505
1509
            all_parents = []
1506
1510
            # We don't care if it is a ghost, since it can't be seen if it is
1507
1511
            # a ghost
1508
 
            for parent_ids in parent_map.values():
 
1512
            for parent_ids in viewvalues(parent_map):
1509
1513
                all_parents.extend(parent_ids)
1510
1514
            next_pending = all_seen.intersection(
1511
1515
                all_parents).difference(seen_ancestors)
1551
1555
                    stop_rev_references[parent_id] += 1
1552
1556
            # if only the stopped revisions reference it, the ref count will be
1553
1557
            # 0 after this loop
1554
 
            for parents in self._current_parents.values():
 
1558
            for parents in viewvalues(self._current_parents):
1555
1559
                for parent_id in parents:
1556
1560
                    try:
1557
1561
                        stop_rev_references[parent_id] -= 1
1558
1562
                    except KeyError:
1559
1563
                        pass
1560
1564
            stop_parents = set()
1561
 
            for rev_id, refs in stop_rev_references.items():
 
1565
            for rev_id, refs in viewitems(stop_rev_references):
1562
1566
                if refs == 0:
1563
1567
                    stop_parents.add(rev_id)
1564
1568
            self._next_query.difference_update(stop_parents)
1594
1598
def invert_parent_map(parent_map):
1595
1599
    """Given a map from child => parents, create a map of parent=>children"""
1596
1600
    child_map = {}
1597
 
    for child, parents in parent_map.items():
 
1601
    for child, parents in viewitems(parent_map):
1598
1602
        for p in parents:
1599
1603
            # Any given parent is likely to have only a small handful
1600
1604
            # of children, many will have only one. So we avoid mem overhead of
1646
1650
    # Will not have any nodes removed, even though you do have an
1647
1651
    # 'uninteresting' linear D->B and E->C
1648
1652
    children = {}
1649
 
    for child, parents in parent_map.items():
 
1653
    for child, parents in viewitems(parent_map):
1650
1654
        children.setdefault(child, [])
1651
1655
        for p in parents:
1652
1656
            children.setdefault(p, []).append(child)