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

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 16:40:42 UTC
  • mfrom: (6653.6.7 rename-controldir)
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170610164042-zrxqgy2htyduvke2
MergeĀ rename-controldirĀ branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
143
143
        trunk_revid = trunk_tree.commit('mainline')
144
144
        # and make branch from it which is stacked
145
145
        try:
146
 
            new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
 
146
            new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
147
147
        except unstackable_format_errors as e:
148
148
            raise TestNotApplicable(e)
149
149
        # stacked repository
160
160
        trunk_revid = trunk_tree.commit('mainline')
161
161
        # Make sure that we can make a stacked branch from it
162
162
        try:
163
 
            trunk_tree.bzrdir.sprout('testbranch', stacked=True)
 
163
            trunk_tree.controldir.sprout('testbranch', stacked=True)
164
164
        except unstackable_format_errors as e:
165
165
            raise TestNotApplicable(e)
166
166
        # Now serve the original mainline from a smart server
187
187
        mainline_revid = 'rev-1'
188
188
        # and make branch from it which is stacked (with no tags)
189
189
        try:
190
 
            new_dir = trunk.bzrdir.sprout(self.get_url('newbranch'), stacked=True)
 
190
            new_dir = trunk.controldir.sprout(self.get_url('newbranch'), stacked=True)
191
191
        except unstackable_format_errors as e:
192
192
            raise TestNotApplicable(e)
193
193
        # stacked repository
264
264
            prefix = ''
265
265
        tree = self.make_branch_and_tree(prefix + 'stacked-on')
266
266
        tree.commit('Added foo')
267
 
        stacked_bzrdir = tree.branch.bzrdir.sprout(
 
267
        stacked_bzrdir = tree.branch.controldir.sprout(
268
268
            self.get_url(prefix + 'stacked'), tree.branch.last_revision(),
269
269
            stacked=True)
270
270
        return stacked_bzrdir
315
315
    def test_no_op_preserve_stacking(self):
316
316
        """With no stacking, preserve_stacking should be a no-op."""
317
317
        branch = self.make_branch('source')
318
 
        cloned_bzrdir = branch.bzrdir.clone('cloned', preserve_stacking=True)
 
318
        cloned_bzrdir = branch.controldir.clone('cloned', preserve_stacking=True)
319
319
        self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat),
320
320
                          cloned_bzrdir.open_branch().get_stacked_on_url)
321
321
 
335
335
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
336
336
        source = self.make_branch('source')
337
337
        stack_on = self.make_stacked_on_matching(source)
338
 
        parent_bzrdir = self.make_bzrdir('.', format='default')
 
338
        parent_bzrdir = self.make_controldir('.', format='default')
339
339
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
340
 
        target = source.bzrdir.sprout('target').open_branch()
 
340
        target = source.controldir.sprout('target').open_branch()
341
341
        # When we sprout we upgrade the branch when there is a default stack_on
342
342
        # set by a config *and* the targeted branch supports stacking.
343
343
        if stack_on._format.supports_stacking():
352
352
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
353
353
        source = self.make_branch('source')
354
354
        stack_on = self.make_stacked_on_matching(source)
355
 
        parent_bzrdir = self.make_bzrdir('.', format='default')
 
355
        parent_bzrdir = self.make_controldir('.', format='default')
356
356
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
357
 
        target = source.bzrdir.clone('target').open_branch()
 
357
        target = source.controldir.clone('target').open_branch()
358
358
        # When we clone we upgrade the branch when there is a default stack_on
359
359
        # set by a config *and* the targeted branch supports stacking.
360
360
        if stack_on._format.supports_stacking():
369
369
            raise TestNotApplicable('Branch format is not usable via HPSS.')
370
370
        source = self.make_branch('source')
371
371
        stack_on = self.make_stacked_on_matching(source)
372
 
        parent_bzrdir = self.make_bzrdir('.', format='default')
 
372
        parent_bzrdir = self.make_controldir('.', format='default')
373
373
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
374
374
        url = self.make_smart_server('target').base
375
 
        target = source.bzrdir.sprout(url).open_branch()
 
375
        target = source.controldir.sprout(url).open_branch()
376
376
        # When we sprout we upgrade the branch when there is a default stack_on
377
377
        # set by a config *and* the targeted branch supports stacking.
378
378
        if stack_on._format.supports_stacking():
385
385
        stack_on = self.make_branch_and_tree('stack-on')
386
386
        stack_on.commit('first commit', rev_id='rev1')
387
387
        try:
388
 
            stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
 
388
            stacked_dir = stack_on.controldir.sprout('stacked', stacked=True)
389
389
        except unstackable_format_errors as e:
390
390
            raise TestNotApplicable('Format does not support stacking.')
391
391
        unstacked = self.make_repository('unstacked')
420
420
        self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
421
421
        stack_on.add('a')
422
422
        stack_on.commit('base commit')
423
 
        stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
 
423
        stacked_dir = stack_on.controldir.sprout('stacked', stacked=True)
424
424
        stacked_branch = stacked_dir.open_branch()
425
 
        local_tree = stack_on.bzrdir.sprout('local').open_workingtree()
 
425
        local_tree = stack_on.controldir.sprout('local').open_workingtree()
426
426
        for i in range(20):
427
427
            text_lines[0] = 'changed in %d\n' % i
428
428
            self.build_tree_contents([('local/a', ''.join(text_lines))])
441
441
        stack_on.add('a')
442
442
        stack_on.commit('base commit')
443
443
        # make a stacked branch from the mainline
444
 
        stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
 
444
        stacked_dir = stack_on.controldir.sprout('stacked', stacked=True)
445
445
        stacked_tree = stacked_dir.open_workingtree()
446
446
        # make a second non-stacked branch from the mainline
447
 
        other_dir = stack_on.bzrdir.sprout('other')
 
447
        other_dir = stack_on.controldir.sprout('other')
448
448
        other_tree = other_dir.open_workingtree()
449
449
        text_lines[9] = 'changed in other\n'
450
450
        self.build_tree_contents([('other/a', ''.join(text_lines))])
466
466
        src_tree.commit('first commit')
467
467
 
468
468
        # Make the stacked-on branch.
469
 
        src_tree.bzrdir.sprout('stacked-on')
 
469
        src_tree.controldir.sprout('stacked-on')
470
470
 
471
471
        # Make a branch stacked on it.
472
472
        target = self.make_branch('target')
518
518
        if not repo._format.supports_nesting_repositories:
519
519
            raise TestNotApplicable()
520
520
        # Avoid make_branch, which produces standalone branches.
521
 
        bzrdir = self.make_bzrdir('repo/stack-on')
 
521
        bzrdir = self.make_controldir('repo/stack-on')
522
522
        try:
523
523
            b = bzrdir.create_branch()
524
524
        except errors.UninitializableFormat:
525
525
            raise TestNotApplicable()
526
526
        transport = self.get_transport('stacked')
527
 
        b.bzrdir.clone_on_transport(transport, stacked_on=b.base)
 
527
        b.controldir.clone_on_transport(transport, stacked_on=b.base)
528
528
        # Ensure that opening the branch doesn't raise.
529
529
        branch.Branch.open(transport.base)
530
530
 
533
533
        stack_on = self.make_branch_and_tree('stack-on')
534
534
        stack_on.commit('first commit', rev_id='rev1')
535
535
        try:
536
 
            stacked_dir = stack_on.bzrdir.sprout(
 
536
            stacked_dir = stack_on.controldir.sprout(
537
537
                self.get_url('stacked'), stacked=True)
538
538
        except unstackable_format_errors as e:
539
539
            raise TestNotApplicable('Format does not support stacking.')
546
546
        tree.commit('second commit', rev_id='rev2')
547
547
        # Sanity check: stacked's repo should not contain rev1, otherwise this
548
548
        # test isn't testing what it's supposed to.
549
 
        repo = stacked.branch.repository.bzrdir.open_repository()
 
549
        repo = stacked.branch.repository.controldir.open_repository()
550
550
        repo.lock_read()
551
551
        self.addCleanup(repo.unlock)
552
552
        self.assertEqual({}, repo.get_parent_map(['rev1']))