148
148
# e.g. mkdir('foo') but all the mutating methods at the
149
149
# moment trigger inventory writes and thus will not
150
150
# let us trigger a read-when-dirty situation.
151
old_root = tree.get_root_id()
151
old_root = tree.path2id('')
153
153
# to detect that the inventory is written by unlock, we
154
154
# first check that it was not written yet.
155
155
# TODO: This requires taking a read lock while we are holding the above
156
156
# write lock, which shouldn't actually be possible
157
157
reference_tree = tree.controldir.open_workingtree()
158
self.assertEqual(old_root, reference_tree.get_root_id())
158
self.assertEqual(old_root, reference_tree.path2id(''))
159
159
# now unlock the second held lock, which should do nothing.
161
161
reference_tree = tree.controldir.open_workingtree()
162
self.assertEqual(old_root, reference_tree.get_root_id())
162
self.assertEqual(old_root, reference_tree.path2id(''))
163
163
# unlocking the first lock we took will now flush.
165
165
# and check it was written using another reference tree
166
166
reference_tree = tree.controldir.open_workingtree()
167
self.assertIsNot(None, reference_tree.get_root_id())
167
self.assertIsNot(None, reference_tree.path2id(''))
169
169
def test_unlock_from_tree_write_lock_flushes(self):
170
170
self._test_unlock_with_lock_method("lock_tree_write")