~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 20:44:14 UTC
  • mfrom: (5807.2.2 inventory-tree-tests)
  • Revision ID: pqm@pqm.ubuntu.com-20110504204414-j893hspmx3k1rki4
(jelmer) Skip per_tree tests that are InventoryTree-specific if they're run
 against non-inventory trees. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    symbol_versioning,
23
23
    transport,
24
24
    workingtree,
25
 
    workingtree_3,
26
 
    workingtree_4,
27
25
    )
28
26
from bzrlib.lockdir import LockDir
29
27
from bzrlib.mutabletree import needs_tree_write_lock
64
62
 
65
63
    def test_get_set_default_format(self):
66
64
        old_format = workingtree.format_registry.get_default()
67
 
        # default is 6
68
 
        self.assertTrue(isinstance(old_format, workingtree_4.WorkingTreeFormat6))
 
65
        # default is 3
 
66
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
69
67
        workingtree.format_registry.set_default(SampleTreeFormat())
70
68
        try:
71
69
            # the default branch format is used by the meta dir format
81
79
 
82
80
    def test_get_set_default_format_by_key(self):
83
81
        old_format = workingtree.format_registry.get_default()
84
 
        # default is 6
 
82
        # default is 3
85
83
        format = SampleTreeFormat()
86
84
        workingtree.format_registry.register(format)
87
85
        self.addCleanup(workingtree.format_registry.remove, format)
88
 
        self.assertTrue(isinstance(old_format, workingtree_4.WorkingTreeFormat6))
 
86
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
89
87
        workingtree.format_registry.set_default_key(format.get_format_string())
90
88
        try:
91
89
            # the default branch format is used by the meta dir format
193
191
            t = transport.get_transport(url)
194
192
            found_format = workingtree.WorkingTreeFormat.find_format(dir)
195
193
            self.assertIsInstance(found_format, format.__class__)
196
 
        check_format(workingtree_3.WorkingTreeFormat3(), "bar")
 
194
        check_format(workingtree.WorkingTreeFormat3(), "bar")
197
195
 
198
196
    def test_find_format_no_tree(self):
199
197
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
236
234
                workingtree.WorkingTreeFormat.get_formats))
237
235
 
238
236
 
239
 
class TestWorkingTreeIterEntriesByDir_wSubtrees(TestCaseWithTransport):
240
 
 
241
 
    def make_simple_tree(self):
242
 
        tree = self.make_branch_and_tree('tree', format='development-subtree')
243
 
        self.build_tree(['tree/a/', 'tree/a/b/', 'tree/a/b/c'])
244
 
        tree.set_root_id('root-id')
245
 
        tree.add(['a', 'a/b', 'a/b/c'], ['a-id', 'b-id', 'c-id'])
246
 
        tree.commit('initial')
247
 
        return tree
248
 
 
249
 
    def test_just_directory(self):
250
 
        tree = self.make_simple_tree()
251
 
        self.assertEqual([('directory', 'root-id'),
252
 
                          ('directory', 'a-id'),
253
 
                          ('directory', 'b-id'),
254
 
                          ('file', 'c-id')],
255
 
                         [(ie.kind, ie.file_id)
256
 
                          for path, ie in tree.iter_entries_by_dir()])
257
 
        subtree = self.make_branch_and_tree('tree/a/b')
258
 
        self.assertEqual([('tree-reference', 'b-id')],
259
 
                         [(ie.kind, ie.file_id)
260
 
                          for path, ie in tree.iter_entries_by_dir(['b-id'])])
261
 
 
262
 
    def test_direct_subtree(self):
263
 
        tree = self.make_simple_tree()
264
 
        subtree = self.make_branch_and_tree('tree/a/b')
265
 
        self.assertEqual([('directory', 'root-id'),
266
 
                          ('directory', 'a-id'),
267
 
                          ('tree-reference', 'b-id')],
268
 
                         [(ie.kind, ie.file_id)
269
 
                          for path, ie in tree.iter_entries_by_dir()])
270
 
 
271
 
    def test_indirect_subtree(self):
272
 
        tree = self.make_simple_tree()
273
 
        subtree = self.make_branch_and_tree('tree/a')
274
 
        self.assertEqual([('directory', 'root-id'),
275
 
                          ('tree-reference', 'a-id')],
276
 
                         [(ie.kind, ie.file_id)
277
 
                          for path, ie in tree.iter_entries_by_dir()])
278
 
 
279
 
 
280
237
class TestWorkingTreeFormatRegistry(TestCase):
281
238
 
282
239
    def setUp(self):
318
275
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
319
276
        control.create_repository()
320
277
        control.create_branch()
321
 
        tree = workingtree_3.WorkingTreeFormat3().initialize(control)
 
278
        tree = workingtree.WorkingTreeFormat3().initialize(control)
322
279
        # we want:
323
280
        # format 'Bazaar-NG Working Tree format 3'
324
281
        # inventory = blank inventory
352
309
        repo = dir.create_repository()
353
310
        branch = dir.create_branch()
354
311
        try:
355
 
            tree = workingtree_3.WorkingTreeFormat3().initialize(dir)
 
312
            tree = workingtree.WorkingTreeFormat3().initialize(dir)
356
313
        except errors.NotLocalUrl:
357
314
            raise TestSkipped('Not a local URL')
358
315
        self.assertIsDirectory('.bzr', t)
369
326
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
370
327
        control.create_repository()
371
328
        control.create_branch()
372
 
        tree = workingtree_3.WorkingTreeFormat3().initialize(control)
 
329
        tree = workingtree.WorkingTreeFormat3().initialize(control)
373
330
        tree._transport.delete("pending-merges")
374
331
        self.assertEqual([], tree.get_parent_ids())
375
332