~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-04 02:29:16 UTC
  • mfrom: (5816.2.4 wt-default)
  • Revision ID: pqm@pqm.ubuntu.com-20110504022916-5kjvsleivsy53zox
(jelmer) Support lazily setting the default format for working trees.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
            workingtree.format_registry.set_default(old_format)
78
78
        self.assertEqual(old_format, workingtree.format_registry.get_default())
79
79
 
 
80
    def test_get_set_default_format_by_key(self):
 
81
        old_format = workingtree.format_registry.get_default()
 
82
        # default is 3
 
83
        format = SampleTreeFormat()
 
84
        workingtree.format_registry.register(format)
 
85
        self.addCleanup(workingtree.format_registry.remove, format)
 
86
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
 
87
        workingtree.format_registry.set_default_key(format.get_format_string())
 
88
        try:
 
89
            # the default branch format is used by the meta dir format
 
90
            # which is not the default bzrdir format at this point
 
91
            dir = bzrdir.BzrDirMetaFormat1().initialize('.')
 
92
            dir.create_repository()
 
93
            dir.create_branch()
 
94
            result = dir.create_workingtree()
 
95
            self.assertEqual(result, 'A tree')
 
96
        finally:
 
97
            workingtree.format_registry.set_default_key(
 
98
                old_format.get_format_string())
 
99
        self.assertEqual(old_format, workingtree.format_registry.get_default())
 
100
 
80
101
    def test_open(self):
81
102
        tree = self.make_branch_and_tree('.')
82
103
        open_direct = workingtree.WorkingTree.open('.')