~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-10 20:22:41 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080710202241-7se48gbsuxm7ih4h
Fix the failing test by implementing the fallback logic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
591
591
        """
592
592
        result = []
593
593
        iterator = self.other_tree.iter_changes(self.base_tree,
594
 
                include_unchanged=True, specific_files=self.interesting_files,
 
594
                include_unchanged=False, specific_files=self.interesting_files,
595
595
                extra_trees=[self.this_tree])
596
596
        for (file_id, paths, changed, versioned, parents, names, kind,
597
597
             executable) in iterator:
1442
1442
            elif len(next_lcas) == 1:
1443
1443
                parent_map[next_lcas.pop()] = ()
1444
1444
                break
 
1445
            else:
 
1446
                # More than 2 lca's, fall back to grabbing all nodes between
 
1447
                # this and the unique lca.
 
1448
                mutter('More than 2 LCAs, falling back to all nodes for: %s',
 
1449
                       cur_ancestors)
 
1450
                cur_lcas = next_lcas
 
1451
                while len(cur_lcas) > 1:
 
1452
                    cur_lcas = self.graph.find_lca(*cur_lcas)
 
1453
                if len(cur_lcas) == 0:
 
1454
                    # No common base to find, use the full ancestry
 
1455
                    unique_lca = None
 
1456
                else:
 
1457
                    unique_lca = cur_lcas.pop()
 
1458
                parent_map.update(self._find_unique_parents(next_lcas,
 
1459
                                                            unique_lca))
 
1460
                break
1445
1461
            cur_ancestors = next_lcas
1446
1462
        return parent_map
1447
1463
 
 
1464
    def _find_unique_parents(self, tip_keys, base_key):
 
1465
        """Find ancestors of tip that aren't ancestors of base.
 
1466
        
 
1467
        :param tip_keys: Nodes that are interesting
 
1468
        :param base_key: Cull all ancestors of this node
 
1469
        :return: The parent map for all revisions between tip_keys and
 
1470
            base_key. base_key will be included. References to nodes outside of
 
1471
            the ancestor set will also be removed.
 
1472
        """
 
1473
        # TODO: (performance) We could also "collapse" the graph at this point,
 
1474
        #       to remove uninteresting linear chains of revisions.
 
1475
        # TODO: this would be simpler if find_unique_ancestors took a list
 
1476
        #       instead of a single tip, internally it supports it, but it
 
1477
        #       isn't a "backwards compatible" api change.
 
1478
        if base_key is None:
 
1479
            parent_map = dict(self.graph.iter_ancestry(tip_keys))
 
1480
        else:
 
1481
            interesting = set()
 
1482
            for tip in tip_keys:
 
1483
                interesting.update(
 
1484
                    self.graph.find_unique_ancestors(tip, [base_key]))
 
1485
            parent_map = self.graph.get_parent_map(interesting)
 
1486
            parent_map[base_key] = ()
 
1487
        culled_parent_map = {}
 
1488
        for key, parent_keys in parent_map.iteritems():
 
1489
            culled_parent_keys = tuple([p for p in parent_keys
 
1490
                                           if p in parent_map])
 
1491
            culled_parent_map[key] = culled_parent_keys
 
1492
        return culled_parent_map
 
1493
 
1448
1494
    def _get_interesting_texts(self, parent_map):
1449
1495
        """Return a dict of texts we are interested in.
1450
1496