/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_workingtree/test_flush.py

  • Committer: Jelmer Vernooij
  • Date: 2019-08-11 13:21:03 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7388.
  • Revision ID: jelmer@jelmer.uk-20190811132103-u3ne03yf37c1h57n
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
    def test_flush_fresh_tree(self):
28
28
        tree = self.make_branch_and_tree('t1')
29
 
        tree.lock_write()
30
 
        try:
 
29
        with tree.lock_write():
31
30
            tree.flush()
32
 
        finally:
33
 
            tree.unlock()
34
31
 
35
32
    def test_flush_when_inventory_is_modified(self):
36
33
        if sys.platform == "win32":
49
46
        tree = self.make_branch_and_tree('tree')
50
47
        # prepare for a series of changes that will modify the
51
48
        # inventory
52
 
        tree.lock_write()
53
 
        try:
54
 
            old_root = tree.get_root_id()
 
49
        with tree.lock_write():
 
50
            old_root = tree.path2id('')
55
51
            tree.add('')
56
52
            # to detect that the inventory is written by flush, we
57
53
            # first check that it was not written yet.
58
54
            reference_tree = tree.controldir.open_workingtree()
59
 
            self.assertEqual(old_root, reference_tree.get_root_id())
 
55
            self.assertEqual(old_root, reference_tree.path2id(''))
60
56
            # now flush the tree which should write the inventory.
61
57
            tree.flush()
62
58
            # and check it was written using another reference tree
63
59
            reference_tree = tree.controldir.open_workingtree()
64
 
            self.assertIsNot(None, reference_tree.get_root_id())
65
 
        finally:
66
 
            tree.unlock()
 
60
            self.assertIsNot(None, reference_tree.path2id(''))
67
61
 
68
62
    def test_flush_with_read_lock_fails(self):
69
63
        """Flush cannot be used during a read lock."""
70
64
        tree = self.make_branch_and_tree('t1')
71
 
        tree.lock_read()
72
 
        try:
 
65
        with tree.lock_read():
73
66
            self.assertRaises(errors.NotWriteLocked, tree.flush)
74
 
        finally:
75
 
            tree.unlock()
76
67
 
77
68
    def test_flush_with_no_lock_fails(self):
78
69
        tree = self.make_branch_and_tree('t1')