~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-13 04:06:16 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080713040616-fl43f8inkw19qj2l
Bring in the code to collapse linear portions of the graph.
Also, start handling when we get NULL_REVISION instead of a tuple key
from various apis.
We could probably handle it at a different level if we really wanted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib import (
24
24
    debug,
25
25
    errors,
 
26
    graph as _mod_graph,
26
27
    osutils,
27
28
    patiencediff,
28
29
    registry,
1462
1463
                    unique_lca = None
1463
1464
                else:
1464
1465
                    unique_lca = list(cur_lcas)[0]
 
1466
                    if unique_lca == NULL_REVISION:
 
1467
                        # find_lca will return a plain 'NULL_REVISION' rather
 
1468
                        # than a key tuple when there is no common ancestor, we
 
1469
                        # prefer to just use None, because it doesn't confuse
 
1470
                        # _get_interesting_texts()
 
1471
                        unique_lca = None
1465
1472
                parent_map.update(self._find_unique_parents(next_lcas,
1466
1473
                                                            unique_lca))
1467
1474
                break
1484
1491
        #       isn't a "backwards compatible" api change.
1485
1492
        if base_key is None:
1486
1493
            parent_map = dict(self.graph.iter_ancestry(tip_keys))
 
1494
            # We remove NULL_REVISION because it isn't a proper tuple key, and
 
1495
            # thus confuses things like _get_interesting_texts, and our logic
 
1496
            # to add the texts into the memory weave.
 
1497
            if NULL_REVISION in parent_map:
 
1498
                parent_map.pop(NULL_REVISION)
1487
1499
        else:
1488
1500
            interesting = set()
1489
1501
            for tip in tip_keys:
1494
1506
        culled_parent_map, child_map, tails = self._remove_external_references(
1495
1507
            parent_map)
1496
1508
        # Remove all the tails but base_key
1497
 
        tails.remove(base_key)
1498
 
        self._prune_tails(culled_parent_map, child_map, tails)
 
1509
        if base_key is not None:
 
1510
            tails.remove(base_key)
 
1511
            self._prune_tails(culled_parent_map, child_map, tails)
 
1512
        # Now remove all the uninteresting 'linear' regions
 
1513
        # simple_map = _mod_graph.collapse_linear_regions(culled_parent_map)
1499
1514
        return culled_parent_map
1500
1515
 
1501
1516
    @staticmethod
1566
1581
        all_revision_keys.add(self.a_key)
1567
1582
        all_revision_keys.add(self.b_key)
1568
1583
 
 
1584
        if NULL_REVISION in all_revision_keys:
 
1585
            import pdb; pdb.set_trace()
1569
1586
        # Everything else is in 'keys' but get_lines is in 'revision_ids'
1570
1587
        all_texts = self.get_lines([k[-1] for k in all_revision_keys])
1571
1588
        return all_texts