/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2007-02-09 07:12:55 UTC
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20070209071255-74pex0pbd0gelb1u
Get merge working initially

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
class Merger(object):
89
89
    def __init__(self, this_branch, other_tree=None, base_tree=None, 
90
 
                 this_tree=None, pb=DummyProgress()):
 
90
                 this_tree=None, pb=DummyProgress(), recurse='down'):
91
91
        object.__init__(self)
92
92
        assert this_tree is not None, "this_tree is required"
93
93
        self.this_branch = this_branch
97
97
        self.this_revision_tree = None
98
98
        self.this_basis_tree = None
99
99
        self.other_tree = other_tree
 
100
        self.other_branch = None
100
101
        self.base_tree = base_tree
101
102
        self.ignore_zero = False
102
103
        self.backup_files = False
105
106
        self.reprocess = False
106
107
        self._pb = pb 
107
108
        self.pp = None
108
 
 
 
109
        self.recurse = recurse
109
110
 
110
111
    def revision_tree(self, revision_id):
111
112
        return self.this_branch.repository.revision_tree(revision_id)
194
195
 
195
196
        :param other_revision: The [path, revision] list to merge from.
196
197
        """
197
 
        other_branch, self.other_tree = _get_tree(other_revision,
 
198
        self.other_branch, self.other_tree = _get_tree(other_revision,
198
199
                                                  self.this_branch)
199
200
        if other_revision[1] == -1:
200
201
            self.other_rev_id = other_branch.last_revision()
212
213
        if other_branch.base != self.this_branch.base:
213
214
            self.this_branch.fetch(other_branch, last_revision=self.other_basis)
214
215
 
 
216
    def set_other_revision(self, revision_id, other_branch):
 
217
        """Set 'other' based on a branch and revision id
 
218
 
 
219
        :param revision_id: The revision to use for a tree
 
220
        :param other_branch: The branch containing this tree
 
221
        """
 
222
        self.other_rev_id = revision_id
 
223
        self.other_branch = other_branch
 
224
        self.this_branch.fetch(other_branch, self.other_rev_id)
 
225
        self.other_tree = self.revision_tree(revision_id)
 
226
        self.other_basis = revision_id
 
227
 
215
228
    def find_base(self):
216
229
        self.set_base([None, None])
217
230
 
274
287
        else:
275
288
            note("%d conflicts encountered." % len(merge.cooked_conflicts))
276
289
 
 
290
        if self.recurse == 'down':
 
291
            for path, entry in self.this_tree.iter_reference_entries():
 
292
                sub_tree = self.this_tree.get_nested_tree(entry, path)
 
293
                other_entry = self.other_tree.inventory[entry.file_id]
 
294
                other_revision = self.other_tree.get_reference_revision(
 
295
                    other_entry, path)
 
296
                if  other_revision == sub_tree.last_revision():
 
297
                    continue
 
298
                sub_merge = Merger(sub_tree.branch, this_tree=sub_tree)
 
299
                sub_merge.merge_type = self.merge_type
 
300
                other_branch = self.other_branch.reference_parent(
 
301
                    entry.file_id, path)
 
302
                sub_merge.set_other_revision(other_revision, other_branch)
 
303
                base_entry = self.base_tree.inventory[entry.file_id]
 
304
                base_revision = \
 
305
                    self.base_tree.get_reference_revision(base_entry)
 
306
                sub_merge.base_tree = \
 
307
                    sub_tree.branch.repository.revision_tree(base_revision)
 
308
                sub_merge.do_merge()
 
309
 
277
310
        return len(merge.cooked_conflicts)
278
311
 
279
312
    def regen_inventory(self, new_entries):