~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/repository_implementations/test_reconcile.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        t = get_transport(self.get_url())
57
57
        # an empty inventory with no revision for testing with.
58
58
        repo = self.make_repository('inventory_without_revision')
 
59
        repo.lock_write()
 
60
        repo.start_write_group()
59
61
        inv = Inventory(revision_id='missing')
60
62
        inv.root.revision = 'missing'
61
63
        repo.add_inventory('missing', inv, [])
 
64
        repo.commit_write_group()
 
65
        repo.unlock()
62
66
 
63
67
        # an empty inventory with no revision for testing with.
64
68
        # this is referenced by 'references_missing' to let us test
65
69
        # that all the cached data is correctly converted into ghost links
66
70
        # and the referenced inventory still cleaned.
67
71
        repo = self.make_repository('inventory_without_revision_and_ghost')
 
72
        repo.lock_write()
 
73
        repo.start_write_group()
68
74
        repo.add_inventory('missing', inv, [])
69
75
        inv = Inventory(revision_id='references_missing')
70
76
        inv.root.revision = 'references_missing'
77
83
                       revision_id='references_missing')
78
84
        rev.parent_ids = ['missing']
79
85
        repo.add_revision('references_missing', rev)
 
86
        repo.commit_write_group()
 
87
        repo.unlock()
80
88
 
81
89
        # a inventory with no parents and the revision has parents..
82
90
        # i.e. a ghost.
83
91
        repo = self.make_repository('inventory_one_ghost')
 
92
        repo.lock_write()
 
93
        repo.start_write_group()
84
94
        inv = Inventory(revision_id='ghost')
85
95
        inv.root.revision = 'ghost'
86
96
        sha1 = repo.add_inventory('ghost', inv, [])
92
102
                       revision_id='ghost')
93
103
        rev.parent_ids = ['the_ghost']
94
104
        repo.add_revision('ghost', rev)
 
105
        repo.commit_write_group()
 
106
        repo.unlock()
95
107
         
96
108
        # a inventory with a ghost that can be corrected now.
97
109
        t.copy_tree('inventory_one_ghost', 'inventory_ghost_present')
98
110
        bzrdir_url = self.get_url('inventory_ghost_present')
99
111
        bzrdir = bzrlib.bzrdir.BzrDir.open(bzrdir_url)
100
112
        repo = bzrdir.open_repository()
 
113
        repo.lock_write()
 
114
        repo.start_write_group()
101
115
        inv = Inventory(revision_id='the_ghost')
102
116
        inv.root.revision = 'the_ghost'
103
117
        sha1 = repo.add_inventory('the_ghost', inv, [])
109
123
                       revision_id='the_ghost')
110
124
        rev.parent_ids = []
111
125
        repo.add_revision('the_ghost', rev)
 
126
        repo.commit_write_group()
 
127
        repo.unlock()
112
128
 
113
129
    def checkEmptyReconcile(self, **kwargs):
114
130
        """Check a reconcile on an empty repository."""
281
297
 
282
298
        # now setup the wrong-first parent case
283
299
        repo = tree.branch.repository
 
300
        repo.lock_write()
 
301
        repo.start_write_group()
284
302
        inv = Inventory(revision_id='wrong-first-parent')
285
303
        inv.root.revision = 'wrong-first-parent'
286
304
        sha1 = repo.add_inventory('wrong-first-parent', inv, ['2', '1'])
292
310
                       revision_id='wrong-first-parent')
293
311
        rev.parent_ids = ['1', '2']
294
312
        repo.add_revision('wrong-first-parent', rev)
 
313
        repo.commit_write_group()
 
314
        repo.unlock()
295
315
 
296
316
        # now setup the wrong-secondary parent case
297
317
        repo = repo_secondary
 
318
        repo.lock_write()
 
319
        repo.start_write_group()
298
320
        inv = Inventory(revision_id='wrong-secondary-parent')
299
321
        inv.root.revision = 'wrong-secondary-parent'
300
322
        sha1 = repo.add_inventory('wrong-secondary-parent', inv, ['1', '3', '2'])
306
328
                       revision_id='wrong-secondary-parent')
307
329
        rev.parent_ids = ['1', '2', '3']
308
330
        repo.add_revision('wrong-secondary-parent', rev)
 
331
        repo.commit_write_group()
 
332
        repo.unlock()
309
333
 
310
334
    def test_reconcile_wrong_order(self):
311
335
        # a wrong order in primary parents is optionally correctable