/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/tests/branch_implementations/test_stacking.py

  • Committer: Andrew Bennetts
  • Date: 2008-11-28 02:33:04 UTC
  • mfrom: (3869 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3871.
  • Revision ID: andrew.bennetts@canonical.com-20081128023304-ffcfuwrau3nswe78
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
class TestStacking(TestCaseWithBranch):
32
32
 
 
33
    def check_lines_added_or_present(self, stacked_branch, revid):
 
34
        # similar to a failure seen in bug 288751 by mbp 20081120
 
35
        stacked_repo = stacked_branch.repository
 
36
        stacked_repo.lock_read()
 
37
        try:
 
38
            list(stacked_repo.inventories.iter_lines_added_or_present_in_keys(
 
39
                    [(revid,)]))
 
40
        finally:
 
41
            stacked_repo.unlock()
 
42
 
33
43
    def test_get_set_stacked_on_url(self):
34
44
        # branches must either:
35
45
        # raise UnstackableBranchFormat or
293
303
        unstacked.fetch(stacked.branch.repository, 'rev2')
294
304
        unstacked.get_revision('rev1')
295
305
        unstacked.get_revision('rev2')
 
306
        self.check_lines_added_or_present(stacked.branch, 'rev1')
 
307
        self.check_lines_added_or_present(stacked.branch, 'rev2')
296
308
 
297
309
    def test_autopack_when_stacked(self):
298
310
        # in bzr.dev as of 20080730, autopack was reported to fail in stacked
334
346
        other_tree = other_dir.open_workingtree()
335
347
        text_lines[9] = 'changed in other\n'
336
348
        self.build_tree_contents([('other/a', ''.join(text_lines))])
337
 
        other_tree.commit('commit in other')
 
349
        stacked_revid = other_tree.commit('commit in other')
338
350
        # this should have generated a delta; try to pull that across
339
351
        # bug 252821 caused a RevisionNotPresent here...
340
352
        stacked_tree.pull(other_tree.branch)
341
353
        stacked_tree.branch.repository.pack()
342
354
        stacked_tree.branch.check()
 
355
        self.check_lines_added_or_present(stacked_tree.branch, stacked_revid)
343
356
 
344
357
    def test_fetch_revisions_with_file_changes(self):
345
358
        # Fetching revisions including file changes into a stacked branch
371
384
        rtree.lock_read()
372
385
        self.addCleanup(rtree.unlock)
373
386
        self.assertEqual('new content', rtree.get_file_by_path('a').read())
 
387
        self.check_lines_added_or_present(target, 'rev2')
374
388
 
375
389
    def test_transform_fallback_location_hook(self):
376
390
        # The 'transform_fallback_location' branch hook allows us to inspect
391
405
            'transform_fallback_location', hook, None)
392
406
        branch.Branch.open('stacked')
393
407
        self.assertEqual(['../stack-on'], hook_calls)
 
408
 
 
409
    def test_stack_on_repository_branch(self):
 
410
        # Stacking should work when the repo isn't co-located with the
 
411
        # stack-on branch.
 
412
        try:
 
413
            repo = self.make_repository('repo', shared=True)
 
414
        except errors.IncompatibleFormat:
 
415
            raise TestNotApplicable()
 
416
        # Avoid make_branch, which produces standalone branches.
 
417
        bzrdir = self.make_bzrdir('repo/stack-on')
 
418
        b = bzrdir.create_branch()
 
419
        transport = self.get_transport('stacked')
 
420
        b.bzrdir.clone_on_transport(transport, stacked_on=b.base)
 
421
        # Ensure that opening the branch doesn't raise.
 
422
        branch.Branch.open(transport.base)