~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_stacking.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-17 22:43:26 UTC
  • mfrom: (4617.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090817224326-uhljmr5me5x3xyda
(robertc) Multiple 2a-as-default fixes. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
278
278
        self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat),
279
279
                          cloned_bzrdir.open_branch().get_stacked_on_url)
280
280
 
 
281
    def make_stacked_on_matching(self, source):
 
282
        if source.repository.supports_rich_root():
 
283
            if source.repository._format.supports_chks:
 
284
                format = "2a"
 
285
            else:
 
286
                format = "1.9-rich-root"
 
287
        else:
 
288
            format = "1.9"
 
289
        return self.make_branch('stack-on', format)
 
290
 
281
291
    def test_sprout_stacking_policy_handling(self):
282
292
        """Obey policy where possible, ignore otherwise."""
283
 
        stack_on = self.make_branch('stack-on')
 
293
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
294
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
 
295
        source = self.make_branch('source')
 
296
        stack_on = self.make_stacked_on_matching(source)
284
297
        parent_bzrdir = self.make_bzrdir('.', format='default')
285
298
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
286
 
        source = self.make_branch('source')
287
299
        target = source.bzrdir.sprout('target').open_branch()
288
 
        if self.branch_format.supports_stacking():
 
300
        # When we sprout we upgrade the branch when there is a default stack_on
 
301
        # set by a config *and* the targeted branch supports stacking.
 
302
        if stack_on._format.supports_stacking():
289
303
            self.assertEqual('../stack-on', target.get_stacked_on_url())
290
304
        else:
291
305
            self.assertRaises(
293
307
 
294
308
    def test_clone_stacking_policy_handling(self):
295
309
        """Obey policy where possible, ignore otherwise."""
 
310
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
311
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
296
312
        self.thisFailsStrictLockCheck()
297
 
        stack_on = self.make_branch('stack-on')
 
313
        source = self.make_branch('source')
 
314
        stack_on = self.make_stacked_on_matching(source)
298
315
        parent_bzrdir = self.make_bzrdir('.', format='default')
299
316
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
300
 
        source = self.make_branch('source')
301
317
        target = source.bzrdir.clone('target').open_branch()
302
 
        if self.branch_format.supports_stacking():
 
318
        # When we clone we upgrade the branch when there is a default stack_on
 
319
        # set by a config *and* the targeted branch supports stacking.
 
320
        if stack_on._format.supports_stacking():
303
321
            self.assertEqual('../stack-on', target.get_stacked_on_url())
304
322
        else:
305
323
            self.assertRaises(
309
327
        """Obey policy where possible, ignore otherwise."""
310
328
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
311
329
            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
312
 
        stack_on = self.make_branch('stack-on')
 
330
        source = self.make_branch('source')
 
331
        stack_on = self.make_stacked_on_matching(source)
313
332
        parent_bzrdir = self.make_bzrdir('.', format='default')
314
333
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
315
 
        source = self.make_branch('source')
316
334
        url = self.make_smart_server('target').base
317
335
        target = source.bzrdir.sprout(url).open_branch()
318
 
        if self.branch_format.supports_stacking():
 
336
        # When we sprout we upgrade the branch when there is a default stack_on
 
337
        # set by a config *and* the targeted branch supports stacking.
 
338
        if stack_on._format.supports_stacking():
319
339
            self.assertEqual('../stack-on', target.get_stacked_on_url())
320
340
        else:
321
341
            self.assertRaises(
352
372
        # repository boundaries.  however, i didn't actually get this test to
353
373
        # fail on that code. -- mbp
354
374
        # see https://bugs.launchpad.net/bzr/+bug/252821
355
 
        if not self.branch_format.supports_stacking():
 
375
        stack_on = self.make_branch_and_tree('stack-on')
 
376
        if not stack_on.branch._format.supports_stacking():
356
377
            raise TestNotApplicable("%r does not support stacking"
357
378
                % self.branch_format)
358
 
        stack_on = self.make_branch_and_tree('stack-on')
359
379
        text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
360
380
        self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
361
381
        stack_on.add('a')