~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_core.py

  • Committer: Martin Pool
  • Date: 2005-07-16 00:07:40 UTC
  • mfrom: (909.1.5)
  • Revision ID: mbp@sourcefrog.net-20050716000740-f2dcb8894a23fd2d
- merge aaron's bugfix branch
  up to abentley@panoramicfeedback.com-20050715134354-78f2bca607acb415

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
            new_cset.add_entry(entry)
51
51
        else:
52
52
            new_entry = make_merged_entry(entry, inventory, conflict_handler)
53
 
            new_contents = make_merged_contents(entry, this, base, other,
54
 
                                                conflict_handler)
 
53
            new_contents = make_merged_contents(entry, this, base, other, 
 
54
                                                inventory, conflict_handler)
55
55
            new_entry.contents_change = new_contents
56
56
            new_entry.metadata_change = make_merged_metadata(entry, base, other)
57
57
            new_cset.add_entry(new_entry)
116
116
    return new_entry
117
117
 
118
118
 
119
 
def make_merged_contents(entry, this, base, other, conflict_handler):
 
119
def make_merged_contents(entry, this, base, other, inventory, conflict_handler):
120
120
    contents = entry.contents_change
121
121
    if contents is None:
122
122
        return None
214
214
        os.chmod(self.abs_path(path), mode)
215
215
        self.inventory[id] = path
216
216
 
 
217
    def remove_file(self, id):
 
218
        os.unlink(self.full_path(id))
 
219
        del self.inventory[id]
 
220
 
217
221
    def add_dir(self, id, parent, name, mode):
218
222
        path = self.child_path(parent, name)
219
223
        full_path = self.abs_path(path)
226
230
        return os.path.join(self.dir, path)
227
231
 
228
232
    def full_path(self, id):
229
 
        return self.abs_path(self.inventory[id])
 
233
        try:
 
234
            tree_path = self.inventory[id]
 
235
        except KeyError:
 
236
            return None
 
237
        return self.abs_path(tree_path)
230
238
 
231
239
    def readonly_path(self, id):
232
240
        return self.full_path(id)
259
267
        path = self.get_cset_path(parent, name)
260
268
        self.cset.add_entry(changeset.ChangesetEntry(id, parent, path))
261
269
 
 
270
    def remove_file(self, id, base=False, this=False, other=False):
 
271
        for option, tree in ((base, self.base), (this, self.this), 
 
272
                             (other, self.other)):
 
273
            if option:
 
274
                tree.remove_file(id)
 
275
            if other or base:
 
276
                change = self.cset.entries[id].contents_change
 
277
                assert isinstance(change, changeset.ReplaceContents)
 
278
                if other:
 
279
                    change.new_contents=None
 
280
                if base:
 
281
                    change.old_contents=None
 
282
                if change.old_contents is None and change.new_contents is None:
 
283
                    change = None
 
284
 
 
285
 
262
286
    def add_dir(self, id, parent, name, mode):
263
287
        path = self.get_cset_path(parent, name)
264
288
        self.base.add_dir(id, parent, name, mode)
505
529
                          cset)
506
530
        builder.cleanup()
507
531
 
 
532
        builder = MergeBuilder()
 
533
        builder.add_file("1", "0", "name1", "text1", 0755)
 
534
        builder.change_contents("1", other="text4", base="text3")
 
535
        builder.remove_file("1", base=True)
 
536
        self.assertRaises(changeset.NewContentsConflict,
 
537
                          builder.merge_changeset)
 
538
        builder.cleanup()
 
539
 
 
540
        builder = MergeBuilder()
 
541
        builder.add_file("1", "0", "name1", "text1", 0755)
 
542
        builder.change_contents("1", other="text4", base="text3")
 
543
        builder.remove_file("1", this=True)
 
544
        self.assertRaises(changeset.MissingForMerge, builder.merge_changeset)
 
545
        builder.cleanup()
 
546
 
508
547
    def test_perms_merge(self):
509
548
        builder = MergeBuilder()
510
549
        builder.add_file("1", "0", "name1", "text1", 0755)