~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2007-02-16 07:02:19 UTC
  • mfrom: (2292 +trunk)
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20070216070219-b22k0gwnisnxawnk
Merged bzr.dev (17 tests failing)

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(), recurse='down'):
 
91
                 this_tree=None, pb=DummyProgress(), change_reporter=None,
 
92
                 recurse='down'):
92
93
        object.__init__(self)
93
94
        assert this_tree is not None, "this_tree is required"
94
95
        self.this_branch = this_branch
108
109
        self._pb = pb 
109
110
        self.pp = None
110
111
        self.recurse = recurse
 
112
        self.change_reporter = change_reporter
111
113
 
112
114
    def revision_tree(self, revision_id):
113
115
        return self.this_branch.repository.revision_tree(revision_id)
200
202
        self.other_branch, self.other_tree = _get_tree(other_revision,
201
203
                                                  self.this_branch)
202
204
        if other_revision[1] == -1:
203
 
            self.other_rev_id = other_branch.last_revision()
 
205
            self.other_rev_id = self.other_branch.last_revision()
204
206
            if self.other_rev_id is None:
205
 
                raise NoCommits(other_branch)
 
207
                raise NoCommits(self.other_branch)
206
208
            self.other_basis = self.other_rev_id
207
209
        elif other_revision[1] is not None:
208
 
            self.other_rev_id = other_branch.get_rev_id(other_revision[1])
 
210
            self.other_rev_id = self.other_branch.get_rev_id(other_revision[1])
209
211
            self.other_basis = self.other_rev_id
210
212
        else:
211
213
            self.other_rev_id = None
212
 
            self.other_basis = other_branch.last_revision()
 
214
            self.other_basis = self.other_branch.last_revision()
213
215
            if self.other_basis is None:
214
 
                raise NoCommits(other_branch)
215
 
        if other_branch.base != self.this_branch.base:
216
 
            self.this_branch.fetch(other_branch, last_revision=self.other_basis)
 
216
                raise NoCommits(self.other_branch)
 
217
        if self.other_branch.base != self.this_branch.base:
 
218
            self.this_branch.fetch(self.other_branch,
 
219
                                   last_revision=self.other_basis)
217
220
 
218
221
    def set_other_revision(self, revision_id, other_branch):
219
222
        """Set 'other' based on a branch and revision id
282
285
        elif self.show_base:
283
286
            raise BzrError("Showing base is not supported for this"
284
287
                                  " merge type. %s" % self.merge_type)
285
 
        merge = self.merge_type(pb=self._pb, **kwargs)
 
288
        merge = self.merge_type(pb=self._pb,
 
289
                                change_reporter=self.change_reporter,
 
290
                                **kwargs)
286
291
        if len(merge.cooked_conflicts) == 0:
287
292
            if not self.ignore_zero:
288
293
                note("All changes applied successfully.")
390
395
 
391
396
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
392
397
                 interesting_ids=None, reprocess=False, show_base=False,
393
 
                 pb=DummyProgress(), pp=None):
 
398
                 pb=DummyProgress(), pp=None, change_reporter=None):
394
399
        """Initialize the merger object and perform the merge."""
395
400
        object.__init__(self)
396
401
        self.this_tree = working_tree
402
407
        self.show_base = show_base
403
408
        self.pb = pb
404
409
        self.pp = pp
 
410
        self.change_reporter = change_reporter
405
411
        if self.pp is None:
406
412
            self.pp = ProgressPhase("Merge phase", 3, self.pb)
407
413
 
430
436
                fs_conflicts = resolve_conflicts(self.tt, child_pb)
431
437
            finally:
432
438
                child_pb.finished()
 
439
            if change_reporter is not None:
 
440
                from bzrlib import delta
 
441
                delta.report_changes(self.tt._iter_changes(), change_reporter)
433
442
            self.cook_conflicts(fs_conflicts)
434
443
            for conflict in self.cooked_conflicts:
435
444
                warning(conflict)
853
862
 
854
863
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
855
864
                 interesting_ids=None, pb=DummyProgress(), pp=None,
856
 
                 reprocess=False):
 
865
                 reprocess=False, change_reporter=None):
857
866
        self.this_revision_tree = self._get_revision_tree(this_tree)
858
867
        self.other_revision_tree = self._get_revision_tree(other_tree)
859
868
        super(WeaveMerger, self).__init__(working_tree, this_tree, 
860
869
                                          base_tree, other_tree, 
861
870
                                          interesting_ids=interesting_ids, 
862
 
                                          pb=pb, pp=pp, reprocess=reprocess)
 
871
                                          pb=pb, pp=pp, reprocess=reprocess,
 
872
                                          change_reporter=change_reporter)
863
873
 
864
874
    def _get_revision_tree(self, tree):
865
875
        """Return a revision tree related to this tree.
966
976
                other_rev_id=None,
967
977
                interesting_files=None,
968
978
                this_tree=None,
969
 
                pb=DummyProgress()):
 
979
                pb=DummyProgress(),
 
980
                change_reporter=None):
970
981
    """Primary interface for merging. 
971
982
 
972
983
        typical use is probably 
980
991
             stacklevel=2)
981
992
        this_tree = this_branch.bzrdir.open_workingtree()
982
993
    merger = Merger(this_branch, other_tree, base_tree, this_tree=this_tree, 
983
 
                    pb=pb)
 
994
                    pb=pb, change_reporter=change_reporter)
984
995
    merger.backup_files = backup_files
985
996
    merger.merge_type = merge_type
986
997
    merger.interesting_ids = interesting_ids