~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Martin Pool
  • Date: 2007-02-21 05:34:56 UTC
  • mfrom: (2296 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2309.
  • Revision ID: mbp@sourcefrog.net-20070221053456-vyr6o0ehqnbetrvb
merge trunk, in particular new Branch6 changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
 
89
89
class Merger(object):
90
90
    def __init__(self, this_branch, other_tree=None, base_tree=None, 
91
 
                 this_tree=None, pb=DummyProgress()):
 
91
                 this_tree=None, pb=DummyProgress(), change_reporter=None):
92
92
        object.__init__(self)
93
93
        assert this_tree is not None, "this_tree is required"
94
94
        self.this_branch = this_branch
106
106
        self.reprocess = False
107
107
        self._pb = pb 
108
108
        self.pp = None
109
 
 
 
109
        self.change_reporter = change_reporter
110
110
 
111
111
    def revision_tree(self, revision_id):
112
112
        return self.this_branch.repository.revision_tree(revision_id)
269
269
        elif self.show_base:
270
270
            raise BzrError("Showing base is not supported for this"
271
271
                                  " merge type. %s" % self.merge_type)
272
 
        merge = self.merge_type(pb=self._pb, **kwargs)
 
272
        merge = self.merge_type(pb=self._pb,
 
273
                                change_reporter=self.change_reporter,
 
274
                                **kwargs)
273
275
        if len(merge.cooked_conflicts) == 0:
274
276
            if not self.ignore_zero:
275
277
                note("All changes applied successfully.")
357
359
 
358
360
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
359
361
                 interesting_ids=None, reprocess=False, show_base=False,
360
 
                 pb=DummyProgress(), pp=None):
 
362
                 pb=DummyProgress(), pp=None, change_reporter=None):
361
363
        """Initialize the merger object and perform the merge."""
362
364
        object.__init__(self)
363
365
        self.this_tree = working_tree
369
371
        self.show_base = show_base
370
372
        self.pb = pb
371
373
        self.pp = pp
 
374
        self.change_reporter = change_reporter
372
375
        if self.pp is None:
373
376
            self.pp = ProgressPhase("Merge phase", 3, self.pb)
374
377
 
397
400
                fs_conflicts = resolve_conflicts(self.tt, child_pb)
398
401
            finally:
399
402
                child_pb.finished()
 
403
            if change_reporter is not None:
 
404
                from bzrlib import delta
 
405
                delta.report_changes(self.tt._iter_changes(), change_reporter)
400
406
            self.cook_conflicts(fs_conflicts)
401
407
            for conflict in self.cooked_conflicts:
402
408
                warning(conflict)
820
826
 
821
827
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
822
828
                 interesting_ids=None, pb=DummyProgress(), pp=None,
823
 
                 reprocess=False):
 
829
                 reprocess=False, change_reporter=None):
824
830
        self.this_revision_tree = self._get_revision_tree(this_tree)
825
831
        self.other_revision_tree = self._get_revision_tree(other_tree)
826
832
        super(WeaveMerger, self).__init__(working_tree, this_tree, 
827
833
                                          base_tree, other_tree, 
828
834
                                          interesting_ids=interesting_ids, 
829
 
                                          pb=pb, pp=pp, reprocess=reprocess)
 
835
                                          pb=pb, pp=pp, reprocess=reprocess,
 
836
                                          change_reporter=change_reporter)
830
837
 
831
838
    def _get_revision_tree(self, tree):
832
839
        """Return a revision tree related to this tree.
933
940
                other_rev_id=None,
934
941
                interesting_files=None,
935
942
                this_tree=None,
936
 
                pb=DummyProgress()):
 
943
                pb=DummyProgress(),
 
944
                change_reporter=None):
937
945
    """Primary interface for merging. 
938
946
 
939
947
        typical use is probably 
947
955
             stacklevel=2)
948
956
        this_tree = this_branch.bzrdir.open_workingtree()
949
957
    merger = Merger(this_branch, other_tree, base_tree, this_tree=this_tree, 
950
 
                    pb=pb)
 
958
                    pb=pb, change_reporter=change_reporter)
951
959
    merger.backup_files = backup_files
952
960
    merger.merge_type = merge_type
953
961
    merger.interesting_ids = interesting_ids