~bzr/ubuntu/lucid/bzr/beta-ppa

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Max Bowsher
  • Date: 2011-02-09 04:08:25 UTC
  • mfrom: (0.5074.6 lucid)
  • Revision ID: maxb@f2s.com-20110209040825-7jqm4i78b8ojoy9z
Merge beta-ppa into ppa upon release of 2.3.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
582
582
            elif len(lcas) == 1:
583
583
                self.base_rev_id = list(lcas)[0]
584
584
            else: # len(lcas) > 1
 
585
                self._is_criss_cross = True
585
586
                if len(lcas) > 2:
586
587
                    # find_unique_lca can only handle 2 nodes, so we have to
587
588
                    # start back at the beginning. It is a shame to traverse
592
593
                else:
593
594
                    self.base_rev_id = self.revision_graph.find_unique_lca(
594
595
                                            *lcas)
595
 
                self._is_criss_cross = True
 
596
                sorted_lca_keys = self.revision_graph.find_merge_order(                
 
597
                    revisions[0], lcas)
 
598
                if self.base_rev_id == _mod_revision.NULL_REVISION:
 
599
                    self.base_rev_id = sorted_lca_keys[0]
 
600
                
596
601
            if self.base_rev_id == _mod_revision.NULL_REVISION:
597
602
                raise errors.UnrelatedBranches()
598
603
            if self._is_criss_cross:
599
604
                trace.warning('Warning: criss-cross merge encountered.  See bzr'
600
605
                              ' help criss-cross.')
601
606
                trace.mutter('Criss-cross lcas: %r' % lcas)
602
 
                interesting_revision_ids = [self.base_rev_id]
603
 
                interesting_revision_ids.extend(lcas)
 
607
                if self.base_rev_id in lcas:
 
608
                    trace.mutter('Unable to find unique lca. '
 
609
                                 'Fallback %r as best option.' % self.base_rev_id)
 
610
                interesting_revision_ids = set(lcas)
 
611
                interesting_revision_ids.add(self.base_rev_id)
604
612
                interesting_trees = dict((t.get_revision_id(), t)
605
613
                    for t in self.this_branch.repository.revision_trees(
606
614
                        interesting_revision_ids))
607
615
                self._cached_trees.update(interesting_trees)
608
 
                self.base_tree = interesting_trees.pop(self.base_rev_id)
609
 
                sorted_lca_keys = self.revision_graph.find_merge_order(
610
 
                    revisions[0], lcas)
 
616
                if self.base_rev_id in lcas:
 
617
                    self.base_tree = interesting_trees[self.base_rev_id]
 
618
                else:
 
619
                    self.base_tree = interesting_trees.pop(self.base_rev_id)
611
620
                self._lca_trees = [interesting_trees[key]
612
621
                                   for key in sorted_lca_keys]
613
622
            else:
1085
1094
        return result
1086
1095
 
1087
1096
    def fix_root(self):
1088
 
        try:
1089
 
            self.tt.final_kind(self.tt.root)
1090
 
        except errors.NoSuchFile:
 
1097
        if self.tt.final_kind(self.tt.root) is None:
1091
1098
            self.tt.cancel_deletion(self.tt.root)
1092
1099
        if self.tt.final_file_id(self.tt.root) is None:
1093
1100
            self.tt.version_file(self.tt.tree_file_id(self.tt.root),
1102
1109
            # the other tree's root is a non-root in the current tree (as when
1103
1110
            # a previously unrelated branch is merged into another)
1104
1111
            return
1105
 
        try:
1106
 
            self.tt.final_kind(other_root)
 
1112
        if self.tt.final_kind(other_root) is not None:
1107
1113
            other_root_is_present = True
1108
 
        except errors.NoSuchFile:
 
1114
        else:
1109
1115
            # other_root doesn't have a physical representation. We still need
1110
1116
            # to move any references to the actual root of the tree.
1111
1117
            other_root_is_present = False
1115
1121
        for thing, child in self.other_tree.inventory.root.children.iteritems():
1116
1122
            trans_id = self.tt.trans_id_file_id(child.file_id)
1117
1123
            if not other_root_is_present:
1118
 
                # FIXME: Make final_kind returns None instead of raising
1119
 
                # NoSuchFile to avoid the ugly construct below -- vila 20100402
1120
 
                try:
1121
 
                    self.tt.final_kind(trans_id)
 
1124
                if self.tt.final_kind(trans_id) is not None:
1122
1125
                    # The item exist in the final tree and has a defined place
1123
1126
                    # to go already.
1124
1127
                    continue
1125
 
                except errors.NoSuchFile, e:
1126
 
                    pass
1127
1128
            # Move the item into the root
1128
1129
            self.tt.adjust_path(self.tt.final_name(trans_id),
1129
1130
                                self.tt.root, trans_id)
1405
1406
            self.tt.version_file(file_id, trans_id)
1406
1407
        # The merge has been performed, so the old contents should not be
1407
1408
        # retained.
1408
 
        try:
1409
 
            self.tt.delete_contents(trans_id)
1410
 
        except errors.NoSuchFile:
1411
 
            pass
 
1409
        self.tt.delete_contents(trans_id)
1412
1410
        return result
1413
1411
 
1414
1412
    def _default_other_winner_merge(self, merge_hook_params):
1586
1584
        if winner == 'this' and file_status != "modified":
1587
1585
            return
1588
1586
        trans_id = self.tt.trans_id_file_id(file_id)
1589
 
        try:
1590
 
            if self.tt.final_kind(trans_id) != "file":
1591
 
                return
1592
 
        except errors.NoSuchFile:
 
1587
        if self.tt.final_kind(trans_id) != "file":
1593
1588
            return
1594
1589
        if winner == "this":
1595
1590
            executability = this_executable