~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2007-04-04 01:22:11 UTC
  • mfrom: (2393.1.1 bzr.docs)
  • mto: This revision was merged to the branch mainline in revision 2397.
  • Revision ID: mbp@sourcefrog.net-20070404012211-sq269me6bai9m6xk
merge trunk and doc fix from elliot

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
         
96
96
        # a inventory with a ghost that can be corrected now.
97
97
        t.copy_tree('inventory_one_ghost', 'inventory_ghost_present')
98
 
        repo = bzrlib.repository.Repository.open('inventory_ghost_present')
 
98
        bzrdir_url = self.get_url('inventory_ghost_present')
 
99
        bzrdir = bzrlib.bzrdir.BzrDir.open(bzrdir_url)
 
100
        repo = bzrdir.open_repository()
99
101
        inv = Inventory(revision_id='the_ghost')
100
102
        inv.root.revision = 'the_ghost'
101
103
        sha1 = repo.add_inventory('the_ghost', inv, [])
111
113
    def checkEmptyReconcile(self, **kwargs):
112
114
        """Check a reconcile on an empty repository."""
113
115
        self.make_repository('empty')
114
 
        d = bzrlib.bzrdir.BzrDir.open('empty')
 
116
        d = bzrlib.bzrdir.BzrDir.open(self.get_url('empty'))
115
117
        # calling on a empty repository should do nothing
116
118
        reconciler = d.find_repository().reconcile(**kwargs)
117
119
        # no inconsistent parents should have been found
131
133
 
132
134
    def test_convenience_reconcile_inventory_without_revision_reconcile(self):
133
135
        # smoke test for the all in one ui tool
134
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision')
135
 
        reconcile(d)
 
136
        bzrdir_url = self.get_url('inventory_without_revision')
 
137
        bzrdir = bzrlib.bzrdir.BzrDir.open(bzrdir_url)
 
138
        reconcile(bzrdir)
136
139
        # now the backup should have it but not the current inventory
137
 
        repo = d.open_repository()
 
140
        repo = bzrdir.open_repository()
138
141
        self.check_missing_was_removed(repo)
139
142
 
140
143
    def test_reweave_inventory_without_revision(self):
141
144
        # an excess inventory on its own is only reconciled by using thorough
142
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision')
 
145
        d_url = self.get_url('inventory_without_revision')
 
146
        d = bzrlib.bzrdir.BzrDir.open(d_url)
143
147
        repo = d.open_repository()
144
148
        self.checkUnreconciled(d, repo.reconcile())
145
149
        reconciler = repo.reconcile(thorough=True)
184
188
    def test_reweave_inventory_without_revision_reconciler(self):
185
189
        # smoke test for the all in one Reconciler class,
186
190
        # other tests use the lower level repo.reconcile()
187
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision_and_ghost')
 
191
        d_url = self.get_url('inventory_without_revision_and_ghost')
 
192
        d = bzrlib.bzrdir.BzrDir.open(d_url)
188
193
        def reconcile():
189
194
            reconciler = Reconciler(d)
190
195
            reconciler.reconcile()
193
198
 
194
199
    def test_reweave_inventory_without_revision_and_ghost(self):
195
200
        # actual low level test.
196
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision_and_ghost')
 
201
        d_url = self.get_url('inventory_without_revision_and_ghost')
 
202
        d = bzrlib.bzrdir.BzrDir.open(d_url)
197
203
        repo = d.open_repository()
198
204
        # nothing should have been altered yet : inventories without
199
205
        # revisions are not data loss incurring for current format
201
207
            thorough=True)
202
208
 
203
209
    def test_reweave_inventory_preserves_a_revision_with_ghosts(self):
204
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_one_ghost')
 
210
        d = bzrlib.bzrdir.BzrDir.open(self.get_url('inventory_one_ghost'))
205
211
        reconciler = d.open_repository().reconcile(thorough=True)
206
212
        # no inconsistent parents should have been found: 
207
213
        # the lack of a parent for ghost is normal
214
220
        self.assertEqual([None, 'ghost'], repo.get_ancestry('ghost'))
215
221
        
216
222
    def test_reweave_inventory_fixes_ancestryfor_a_present_ghost(self):
217
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_ghost_present')
 
223
        d = bzrlib.bzrdir.BzrDir.open(self.get_url('inventory_ghost_present'))
218
224
        repo = d.open_repository()
219
225
        ghost_ancestry = repo.get_ancestry('ghost')
220
226
        if ghost_ancestry == [None, 'the_ghost', 'ghost']:
245
251
    """
246
252
 
247
253
    def setUp(self):
 
254
        self.reduceLockdirTimeout()
248
255
        super(TestReconcileWithIncorrectRevisionCache, self).setUp()
249
256
        
250
257
        t = get_transport(self.get_url())
260
267
        
261
268
        # first off the common logic:
262
269
        tree = self.make_branch_and_tree('wrong-first-parent')
263
 
        tree.commit('1', rev_id='1')
264
 
        uncommit(tree.branch, tree=tree)
265
 
        tree.commit('2', rev_id='2')
266
 
        uncommit(tree.branch, tree=tree)
267
 
        tree.commit('3', rev_id='3')
268
 
        uncommit(tree.branch, tree=tree)
269
 
        repo_secondary = tree.bzrdir.clone(
270
 
            'reversed-secondary-parents').open_repository()
 
270
        second_tree = self.make_branch_and_tree('reversed-secondary-parents')
 
271
        for t in [tree, second_tree]:
 
272
            t.commit('1', rev_id='1')
 
273
            uncommit(t.branch, tree=t)
 
274
            t.commit('2', rev_id='2')
 
275
            uncommit(t.branch, tree=t)
 
276
            t.commit('3', rev_id='3')
 
277
            uncommit(t.branch, tree=t)
 
278
        #second_tree = self.make_branch_and_tree('reversed-secondary-parents')
 
279
        #second_tree.pull(tree) # XXX won't copy the repo?
 
280
        repo_secondary = second_tree.branch.repository
271
281
 
272
282
        # now setup the wrong-first parent case
273
283
        repo = tree.branch.repository
299
309
 
300
310
    def test_reconcile_wrong_order(self):
301
311
        # a wrong order in primary parents is optionally correctable
302
 
        d = bzrlib.bzrdir.BzrDir.open('wrong-first-parent')
 
312
        t = get_transport(self.get_url()).clone('wrong-first-parent')
 
313
        d = bzrlib.bzrdir.BzrDir.open_from_transport(t)
303
314
        repo = d.open_repository()
304
315
        g = repo.get_revision_graph()
305
316
        if g['wrong-first-parent'] == ['1', '2']:
318
329
 
319
330
    def test_reconcile_wrong_order_secondary(self):
320
331
        # a wrong order in secondary parents is ignored.
321
 
        d = bzrlib.bzrdir.BzrDir.open('reversed-secondary-parents')
 
332
        t = get_transport(self.get_url()).clone('reversed-secondary-parents')
 
333
        d = bzrlib.bzrdir.BzrDir.open_from_transport(t)
322
334
        repo = d.open_repository()
323
335
        self.checkUnreconciled(d, repo.reconcile())
324
336
        self.checkUnreconciled(d, repo.reconcile(thorough=True))