~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-22 22:25:42 UTC
  • mto: (3697.7.4 1.7)
  • mto: This revision was merged to the branch mainline in revision 3748.
  • Revision ID: john@arbash-meinel.com-20080722222542-r4so03343ba2me68
Switch the lca_trees to be in 'find_merge_order'.

We don't *have* to use that order, but it means we guarantee the lca ordering,
rather than just guessing.
One alternative that would be a bit faster is just simple lexicographical ordering.

Also handle when one of the LCA trees doesn't have an entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
378
378
                        interesting_revision_ids))
379
379
                self._cached_trees.update(interesting_trees)
380
380
                self.base_tree = interesting_trees.pop(self.base_rev_id)
381
 
                self._lca_trees = interesting_trees
 
381
                sorted_lca_keys = self.revision_graph.find_merge_order(
 
382
                    revisions[0], lcas)
 
383
                self._lca_trees = [interesting_trees[key]
 
384
                                   for key in sorted_lca_keys]
382
385
            else:
383
386
                self.base_tree = self.revision_tree(self.base_rev_id)
384
387
        self.base_is_ancestor = True
658
661
            executable  ((base, [exec, in, lcas]), exec_in_other, exec_in_this)
659
662
        """
660
663
        result = []
661
 
        walker = _mod_tree.MultiWalker(self.other_tree,
662
 
                                       self._lca_trees.values())
 
664
        # XXX: Do we want a better sort order than this?
 
665
        walker = _mod_tree.MultiWalker(self.other_tree, self._lca_trees)
663
666
 
664
667
        base_inventory = self.base_tree.inventory
665
668
        this_inventory = self.this_tree.inventory
666
669
        for path, file_id, other_ie, lca_values in walker.iter_all():
667
670
            # Is this modified at all from any of the other trees?
668
671
            last_rev = other_ie.revision
 
672
            # I believe we can actually change this to see if last_rev is
 
673
            # identical to *any* of the lca values.
669
674
            for lca_path, ie in lca_values:
670
 
                if ie.revision != last_rev:
 
675
                if ie is None or ie.revision != last_rev:
671
676
                    break
672
677
            else: # Identical in all trees
673
678
                continue
678
683
            parent_id_changed = False
679
684
            name_changed = False
680
685
            for lca_path, ie in lca_values:
 
686
                if ie is None:
 
687
                    kind_changed = parent_id_changed = name_changed = True
 
688
                    break
681
689
                if ie.kind != other_kind:
682
690
                    kind_changed = True
683
691
                if ie.parent_id != other_parent_id:
706
714
            else:
707
715
                this_parent_id = this_name = this_executable = None
708
716
 
 
717
            lca_parent_ids = []
 
718
            lca_names = []
 
719
            lca_executable = []
 
720
            for path, ie in lca_values:
 
721
                if ie is None:
 
722
                    lca_parent_ids.append(None)
 
723
                    lca_names.append(None)
 
724
                    lca_executable.append(None)
 
725
                else:
 
726
                    lca_parent_ids.append(ie.parent_id)
 
727
                    lca_names.append(ie.name)
 
728
                    lca_executable.append(ie.executable)
 
729
 
 
730
            # If we have gotten this far, that means something has changed
709
731
            result.append((file_id, True,
710
 
                           ((base_parent_id,
711
 
                            [ie.parent_id for path, ie in lca_values]),
 
732
                           ((base_parent_id, lca_parent_ids),
712
733
                            other_ie.parent_id, this_parent_id),
713
 
                           ((base_name,
714
 
                            [ie.name for path, ie in lca_values]),
 
734
                           ((base_name, lca_names),
715
735
                            other_ie.name, this_name),
716
 
                           ((base_executable,
717
 
                            [ie.executable for path, ie in lca_values]),
 
736
                           ((base_executable, lca_executable),
718
737
                            other_ie.executable, this_executable)
719
738
                          ))
720
739
        return result