~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-11 14:02:34 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080711140234-djkprpvy1738nbn1
Add some debugging, and work on getting the graph right so we get the weave insertion order correct.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1428
1428
        # rather than a key tuple. We will just map that directly to no common
1429
1429
        # ancestors.
1430
1430
        parent_map = {}
 
1431
        mutter('finding lcas for:\n%s, %s', self.a_rev, self.b_rev)
1431
1432
        while True:
1432
1433
            next_lcas = self.graph.find_lca(*cur_ancestors)
1433
1434
            # Map a plain NULL_REVISION to a simple no-ancestors
1434
1435
            if next_lcas == set([NULL_REVISION]):
1435
1436
                next_lcas = ()
1436
 
            # Order the lca's based on when they were merged into the first
1437
 
            # tip. While weave merge uses a set() of active revisions, the
1438
 
            # order of insertion *does* effect the implicit ordering of the
1439
 
            # texts.
1440
 
            next_lcas = tuple(self.graph.find_merge_order(cur_ancestors[0],
1441
 
                                                          next_lcas))
 
1437
            # Order the lca's based on when they were merged into the tip
 
1438
            # While the actual merge portion of weave merge uses a set() of
 
1439
            # active revisions, the order of insertion *does* effect the
 
1440
            # implicit ordering of the texts.
1442
1441
            for rev_key in cur_ancestors:
1443
 
                parent_map[rev_key] = next_lcas
 
1442
                ordered_parents = tuple(self.graph.find_merge_order(rev_key,
 
1443
                                                                    next_lcas))
 
1444
                mutter('found %s => %s', rev_key[-1], [p[-1] for p
 
1445
                                                       in ordered_parents])
 
1446
                parent_map[rev_key] = ordered_parents
1444
1447
            if len(next_lcas) == 0:
1445
1448
                break
1446
1449
            elif len(next_lcas) == 1:
1447
 
                parent_map[next_lcas[0]] = ()
 
1450
                parent_map[list(next_lcas)[0]] = ()
1448
1451
                break
1449
1452
            else:
1450
1453
                # More than 2 lca's, fall back to grabbing all nodes between
1531
1534
        tip_key = self._key_prefix + (_mod_revision.CURRENT_REVISION,)
1532
1535
        parent_map[tip_key] = (self.a_key, self.b_key)
1533
1536
 
 
1537
        ordering = []
1534
1538
        for seq_num, key, depth, eom in reversed(tsort.merge_sort(parent_map,
1535
1539
                                                                  tip_key)):
1536
1540
            if key == tip_key:
1537
1541
                continue
 
1542
        # for key in tsort.topo_sort(parent_map):
1538
1543
            parent_keys = parent_map[key]
1539
1544
            revision_id = key[-1]
 
1545
            ordering.append(revision_id)
1540
1546
            parent_ids = [k[-1] for k in parent_keys]
1541
1547
            self._weave.add_lines(revision_id, parent_ids,
1542
1548
                                  all_texts[revision_id])
 
1549
        mutter('order in weave: %s', ordering)
1543
1550
 
1544
1551
    def plan_merge(self):
1545
1552
        """Generate a 'plan' for merging the two revisions.