~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-10-14 03:18:36 UTC
  • mfrom: (3363.17.29 merge-into2)
  • Revision ID: pqm@pqm.ubuntu.com-20081014031836-0pn8u98igc7gvtv0
Allow merging into PreviewTrees

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
from bzrlib.trace import mutter, warning, note, is_quiet
56
56
from bzrlib.transform import (TransformPreview, TreeTransform,
57
57
                              resolve_conflicts, cook_conflicts,
58
 
                              conflict_pass, FinalPaths, create_by_entry,
 
58
                              conflict_pass, FinalPaths, create_from_tree,
59
59
                              unique_add, ROOT_PARENT)
60
60
from bzrlib.versionedfile import PlanWeaveMerge
61
61
from bzrlib import ui
132
132
                                      _set_base_is_other_ancestor)
133
133
 
134
134
    @staticmethod
135
 
    def from_uncommitted(tree, other_tree, pb):
 
135
    def from_uncommitted(tree, other_tree, pb, base_tree=None):
136
136
        """Return a Merger for uncommitted changes in other_tree.
137
137
 
138
138
        :param tree: The tree to merge into
139
139
        :param other_tree: The tree to get uncommitted changes from
140
140
        :param pb: A progress indicator
 
141
        :param base_tree: The basis to use for the merge.  If unspecified,
 
142
            other_tree.basis_tree() will be used.
141
143
        """
142
 
        merger = Merger(tree.branch, other_tree, other_tree.basis_tree(), tree,
143
 
                        pb)
 
144
        if base_tree is None:
 
145
            base_tree = other_tree.basis_tree()
 
146
        merger = Merger(tree.branch, other_tree, base_tree, tree, pb)
144
147
        merger.base_rev_id = merger.base_tree.get_revision_id()
145
148
        merger.other_rev_id = None
146
149
        merger.other_basis = merger.base_rev_id
176
179
                          tree_branch=None):
177
180
        """Return a Merger for revision-ids.
178
181
 
 
182
        :param pb: A progress indicator
179
183
        :param tree: The tree to merge changes into
180
184
        :param other: The revision-id to use as OTHER
181
185
        :param base: The revision-id to use as BASE.  If not specified, will
186
190
            not supplied, other_branch or tree.branch will be used.
187
191
        :param revision_graph: If you have a revision_graph precomputed, pass
188
192
            it in, otherwise it will be created for you.
189
 
        :param pb: A progress indicator
 
193
        :param tree_branch: The branch associated with tree.  If not supplied,
 
194
            tree.branch will be used.
190
195
        """
191
196
        if tree_branch is None:
192
197
            tree_branch = tree.branch
873
878
        if self.tt.final_file_id(self.tt.root) is None:
874
879
            self.tt.version_file(self.tt.tree_file_id(self.tt.root), 
875
880
                                 self.tt.root)
876
 
        if self.other_tree.inventory.root is None:
877
 
            return
878
881
        other_root_file_id = self.other_tree.get_root_id()
 
882
        if other_root_file_id is None:
 
883
            return
879
884
        other_root = self.tt.trans_id_file_id(other_root_file_id)
880
885
        if other_root == self.tt.root:
881
886
            return
1131
1136
                    self.tt.delete_contents(trans_id)
1132
1137
                if file_id in self.other_tree:
1133
1138
                    # OTHER changed the file
1134
 
                    create_by_entry(self.tt,
1135
 
                                    self.other_tree.inventory[file_id],
1136
 
                                    self.other_tree, trans_id)
 
1139
                    create_from_tree(self.tt, trans_id,
 
1140
                                     self.other_tree, file_id)
1137
1141
                    if file_id not in self.this_tree:
1138
1142
                        self.tt.version_file(file_id, trans_id)
1139
1143
                    return "modified"
1237
1241
                    versioned = True
1238
1242
        return file_group
1239
1243
           
1240
 
    def _conflict_file(self, name, parent_id, tree, file_id, suffix, 
 
1244
    def _conflict_file(self, name, parent_id, tree, file_id, suffix,
1241
1245
                       lines=None):
1242
1246
        """Emit a single conflict file."""
1243
1247
        name = name + '.' + suffix
1244
1248
        trans_id = self.tt.create_path(name, parent_id)
1245
 
        entry = tree.inventory[file_id]
1246
 
        create_by_entry(self.tt, entry, tree, trans_id, lines)
 
1249
        create_from_tree(self.tt, trans_id, tree, file_id, lines)
1247
1250
        return trans_id
1248
1251
 
1249
1252
    def merge_executable(self, file_id, file_status):