~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-06 22:44:57 UTC
  • mfrom: (6436 +trunk)
  • mto: (6437.3.11 2.5)
  • mto: This revision was merged to the branch mainline in revision 6444.
  • Revision ID: jelmer@samba.org-20120106224457-re0pcy0fz31xob77
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
        self.assertIsInstance(
202
202
            SampleBranchFormat.from_string("Sample branch format."),
203
203
            SampleBranchFormat)
204
 
        self.assertRaises(ValueError,
 
204
        self.assertRaises(AssertionError,
205
205
            SampleBranchFormat.from_string, "Different branch format.")
206
206
 
207
207
    def test_find_format_not_branch(self):
217
217
                          _mod_branch.BranchFormatMetadir.find_format,
218
218
                          dir)
219
219
 
 
220
    def test_find_format_with_features(self):
 
221
        tree = self.make_branch_and_tree('.', format='2a')
 
222
        tree.branch.update_feature_flags({"name": "optional"})
 
223
        found_format = _mod_branch.BranchFormatMetadir.find_format(tree.bzrdir)
 
224
        self.assertIsInstance(found_format, _mod_branch.BranchFormatMetadir)
 
225
        self.assertEquals(found_format.features.get("name"), "optional")
 
226
        tree.branch.update_feature_flags({"name": None})
 
227
        branch = _mod_branch.Branch.open('.')
 
228
        self.assertEquals(branch._format.features, {})
 
229
 
220
230
    def test_register_unregister_format(self):
221
231
        # Test the deprecated format registration functions
222
232
        format = SampleBranchFormat()
346
356
        self.assertPathDoesNotExist('a/.bzr/branch/parent')
347
357
        self.assertEqual('http://example.com', branch.get_parent())
348
358
        branch.set_push_location('sftp://example.com')
349
 
        config = branch.get_config()._get_branch_data_config()
350
 
        self.assertEqual('sftp://example.com',
351
 
                         config.get_user_option('push_location'))
 
359
        config = branch.get_config_stack()
 
360
        self.assertEqual('sftp://example.com', config.get('push_location'))
352
361
        branch.set_bound_location('ftp://example.com')
353
362
        self.assertPathDoesNotExist('a/.bzr/branch/bound')
354
363
        self.assertEqual('ftp://example.com', branch.get_bound_location())
403
412
    def test_light_checkout_with_references(self):
404
413
        self.do_checkout_test(lightweight=True)
405
414
 
406
 
    def test_set_push(self):
407
 
        branch = self.make_branch('source', format=self.get_format_name())
408
 
        branch.get_config().set_user_option('push_location', 'old',
409
 
            store=config.STORE_LOCATION)
410
 
        warnings = []
411
 
        def warning(*args):
412
 
            warnings.append(args[0] % args[1:])
413
 
        _warning = trace.warning
414
 
        trace.warning = warning
415
 
        try:
416
 
            branch.set_push_location('new')
417
 
        finally:
418
 
            trace.warning = _warning
419
 
        self.assertEqual(warnings[0], 'Value "new" is masked by "old" from '
420
 
                         'locations.conf')
421
 
 
422
415
 
423
416
class TestBranch6(TestBranch67, tests.TestCaseWithTransport):
424
417
 
668
661
    def setUp(self):
669
662
        super(TestBranchOptions, self).setUp()
670
663
        self.branch = self.make_branch('.')
671
 
        self.config = self.branch.get_config()
 
664
        self.config_stack = self.branch.get_config_stack()
672
665
 
673
666
    def check_append_revisions_only(self, expected_value, value=None):
674
667
        """Set append_revisions_only in config and check its interpretation."""
675
668
        if value is not None:
676
 
            self.config.set_user_option('append_revisions_only', value)
 
669
            self.config_stack.set('append_revisions_only', value)
677
670
        self.assertEqual(expected_value,
678
671
                         self.branch.get_append_revisions_only())
679
672
 
680
673
    def test_valid_append_revisions_only(self):
681
674
        self.assertEquals(None,
682
 
                          self.config.get_user_option('append_revisions_only'))
 
675
                          self.config_stack.get('append_revisions_only'))
683
676
        self.check_append_revisions_only(None)
684
677
        self.check_append_revisions_only(False, 'False')
685
678
        self.check_append_revisions_only(True, 'True')
697
690
        self.check_append_revisions_only(None, 'not-a-bool')
698
691
        self.assertLength(1, self.warnings)
699
692
        self.assertEqual(
700
 
            'Value "not-a-bool" is not a boolean for "append_revisions_only"',
 
693
            'Value "not-a-bool" is not valid for "append_revisions_only"',
701
694
            self.warnings[0])
702
695
 
703
696
 
734
727
        f = StringIO()
735
728
        r.report(f)
736
729
        self.assertEqual("No revisions or tags to pull.\n", f.getvalue())
737