Rev 2463: Fix test_smart_add tests for dirstate - mainly inventory outside locks issues. in file:///home/robertc/source/baz/dirstate/

Robert Collins robertc at robertcollins.net
Thu Mar 1 05:21:02 GMT 2007


At file:///home/robertc/source/baz/dirstate/

------------------------------------------------------------
revno: 2463
revision-id: robertc at robertcollins.net-20070301052056-h3byz7nuk38la3os
parent: robertc at robertcollins.net-20070301051807-3qz6wj0jtjsieyj2
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate
timestamp: Thu 2007-03-01 16:20:56 +1100
message:
  Fix test_smart_add tests for dirstate - mainly inventory outside locks issues.
modified:
  bzrlib/tests/test_smart_add.py test_smart_add.py-20050824235919-c60dcdb0c8e999ce
=== modified file 'bzrlib/tests/test_smart_add.py'
--- a/bzrlib/tests/test_smart_add.py	2006-09-10 19:04:48 +0000
+++ b/bzrlib/tests/test_smart_add.py	2007-03-01 05:20:56 +0000
@@ -114,8 +114,6 @@
         wt = self.make_branch_and_tree('.')
         self.build_tree(['file'])
         smart_add_tree(wt, ['file'], save=False)
-        self.assertNotEqual(wt.path2id('file'), None, "No id added for 'file'")
-        wt.read_working_inventory()
         self.assertEqual(wt.path2id('file'), None)
 
     def test_add_dry_run(self):
@@ -258,7 +256,9 @@
                               'added dir1/file2 with id file-dir1%file2\n',
                               'added file1 with id file-file1\n',
                              ], lines)
-        self.assertEqual([('', wt.inventory.root.file_id),
+        wt.lock_read()
+        self.addCleanup(wt.unlock)
+        self.assertEqual([('', wt.path2id('')),
                           ('dir1', 'directory-dir1'),
                           ('dir1/file2', 'file-dir1%file2'),
                           ('file1', 'file-file1'),
@@ -341,6 +341,8 @@
         # These should get newly generated ids
         c_id = new_tree.path2id('c')
         self.assertNotEqual(None, c_id)
+        self.base_tree.lock_read()
+        self.addCleanup(self.base_tree.unlock)
         self.failIf(c_id in self.base_tree)
 
         d_id = new_tree.path2id('subdir/d')
@@ -364,6 +366,8 @@
         # matching path or child of 'subby'.
         a_id = new_tree.path2id('subby/a')
         self.assertNotEqual(None, a_id)
+        self.base_tree.lock_read()
+        self.addCleanup(self.base_tree.unlock)
         self.failIf(a_id in self.base_tree)
 
 
@@ -383,6 +387,8 @@
         osutils.normalized_filename = osutils._accessible_normalized_filename
         try:
             smart_add_tree(self.wt, [u'a\u030a'])
+            self.wt.lock_read()
+            self.addCleanup(self.wt.unlock)
             self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
                     [(path, ie.kind) for path,ie in 
                         self.wt.inventory.iter_entries()])
@@ -395,6 +401,8 @@
         osutils.normalized_filename = osutils._accessible_normalized_filename
         try:
             smart_add_tree(self.wt, [])
+            self.wt.lock_read()
+            self.addCleanup(self.wt.unlock)
             self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
                     [(path, ie.kind) for path,ie in 
                         self.wt.inventory.iter_entries()])



More information about the bazaar-commits mailing list