~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

Work in progress to make merge_inner work with dirstate trees.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
 
87
87
 
88
88
class Merger(object):
89
 
    def __init__(self, this_branch, other_tree=None, base_tree=None, 
 
89
    def __init__(self, this_branch, other_tree=None, base_tree=None,
90
90
                 this_tree=None, pb=DummyProgress()):
91
91
        object.__init__(self)
92
92
        assert this_tree is not None, "this_tree is required"
103
103
        self.interesting_ids = None
104
104
        self.show_base = False
105
105
        self.reprocess = False
106
 
        self._pb = pb 
 
106
        self._pb = pb
107
107
        self.pp = None
108
108
 
109
 
 
110
109
    def revision_tree(self, revision_id):
111
110
        return self.this_branch.repository.revision_tree(revision_id)
112
111
 
252
251
                                                self.this_branch)
253
252
 
254
253
    def do_merge(self):
255
 
        kwargs = {'working_tree':self.this_tree, 'this_tree': self.this_tree, 
256
 
                  'other_tree': self.other_tree, 
 
254
        kwargs = {'working_tree':self.this_tree, 'this_tree': self.this_tree,
 
255
                  'other_tree': self.other_tree,
257
256
                  'interesting_ids': self.interesting_ids,
258
257
                  'pp': self.pp}
259
258
        if self.merge_type.requires_base:
268
267
        elif self.show_base:
269
268
            raise BzrError("Showing base is not supported for this"
270
269
                                  " merge type. %s" % self.merge_type)
271
 
        merge = self.merge_type(pb=self._pb, **kwargs)
 
270
        self.this_tree.lock_write()
 
271
        if self.base_tree is not None:
 
272
            self.base_tree.lock_read()
 
273
        if self.other_tree is not None:
 
274
            self.other_tree.lock_read()
 
275
        try:
 
276
            merge = self.merge_type(pb=self._pb, **kwargs)
 
277
        finally:
 
278
            if self.other_tree is not None:
 
279
                self.other_tree.unlock()
 
280
            if self.base_tree is not None:
 
281
                self.base_tree.unlock()
 
282
            self.this_tree.unlock()
272
283
        if len(merge.cooked_conflicts) == 0:
273
284
            if not self.ignore_zero:
274
285
                note("All changes applied successfully.")
924
935
 
925
936
 
926
937
def merge_inner(this_branch, other_tree, base_tree, ignore_zero=False,
927
 
                backup_files=False, 
928
 
                merge_type=Merge3Merger, 
929
 
                interesting_ids=None, 
930
 
                show_base=False, 
931
 
                reprocess=False, 
 
938
                backup_files=False,
 
939
                merge_type=Merge3Merger,
 
940
                interesting_ids=None,
 
941
                show_base=False,
 
942
                reprocess=False,
932
943
                other_rev_id=None,
933
944
                interesting_files=None,
934
945
                this_tree=None,
945
956
             DeprecationWarning,
946
957
             stacklevel=2)
947
958
        this_tree = this_branch.bzrdir.open_workingtree()
948
 
    merger = Merger(this_branch, other_tree, base_tree, this_tree=this_tree, 
 
959
    merger = Merger(this_branch, other_tree, base_tree, this_tree=this_tree,
949
960
                    pb=pb)
950
961
    merger.backup_files = backup_files
951
962
    merger.merge_type = merge_type