Rev 2318: track down a couple other places where we are using list_files. in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

John Arbash Meinel john at arbash-meinel.com
Thu Feb 15 18:33:29 GMT 2007


At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

------------------------------------------------------------
revno: 2318
revision-id: john at arbash-meinel.com-20070215183224-grz0nmma8kve7go0
parent: john at arbash-meinel.com-20070215175900-28ukh0bwk1lnv1qq
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Thu 2007-02-15 12:32:24 -0600
message:
  track down a couple other places where we are using list_files.
modified:
  bzrlib/benchmarks/bench_workingtree.py bench_workingtree.py-20060527061822-cxrgsa9ax2q4d82q-1
  bzrlib/version_info_formats/__init__.py generate_version_info.py-20051228204928-8358edabcddcd97e
-------------- next part --------------
=== modified file 'bzrlib/benchmarks/bench_workingtree.py'
--- a/bzrlib/benchmarks/bench_workingtree.py	2007-02-15 17:56:10 +0000
+++ b/bzrlib/benchmarks/bench_workingtree.py	2007-02-15 18:32:24 +0000
@@ -45,7 +45,11 @@
             if root == '.':
                 continue
             tree.add(root)
-        self.time(list, tree.list_files())
+        tree.lock_read()
+        try:
+            self.time(list, tree.list_files())
+        finally:
+            tree.unlock()
 
     def test_is_ignored_single_call(self):
         """How long does is_ignored take to initialise and check one file."""

=== modified file 'bzrlib/version_info_formats/__init__.py'
--- a/bzrlib/version_info_formats/__init__.py	2006-09-29 00:04:13 +0000
+++ b/bzrlib/version_info_formats/__init__.py	2007-02-15 18:32:24 +0000
@@ -81,45 +81,54 @@
 
         if self._working_tree is not None:
             basis_tree = self._working_tree.basis_tree()
+            # TODO: jam 20070215 The working tree should actually be locked at
+            #       a higher level, but this will do for now.
+            self._working_tree.lock_read()
         else:
             basis_tree = self._branch.basis_tree()
 
-        # Build up the list from the basis inventory
-        for info in basis_tree.list_files(include_root=True):
-            self._file_revisions[info[0]] = info[-1].revision
-
-        if not self._check or self._working_tree is None:
-            return
-
-        delta = self._working_tree.changes_from(basis_tree, 
-                                                include_root=True)
-
-        # Using a 2-pass algorithm for renames. This is because you might have
-        # renamed something out of the way, and then created a new file
-        # in which case we would rather see the new marker
-        # Or you might have removed the target, and then renamed
-        # in which case we would rather see the renamed marker
-        for (old_path, new_path, file_id,
-             kind, text_mod, meta_mod) in delta.renamed:
-            self._clean = False
-            self._file_revisions[old_path] = u'renamed to %s' % (new_path,)
-        for path, file_id, kind in delta.removed:
-            self._clean = False
-            self._file_revisions[path] = 'removed'
-        for path, file_id, kind in delta.added:
-            self._clean = False
-            self._file_revisions[path] = 'new'
-        for (old_path, new_path, file_id,
-             kind, text_mod, meta_mod) in delta.renamed:
-            self._clean = False
-            self._file_revisions[new_path] = u'renamed from %s' % (old_path,)
-        for path, file_id, kind, text_mod, meta_mod in delta.modified:
-            self._clean = False
-            self._file_revisions[path] = 'modified'
-
-        for path in self._working_tree.unknowns():
-            self._clean = False
-            self._file_revisions[path] = 'unversioned'
+        basis_tree.lock_read()
+        try:
+            # Build up the list from the basis inventory
+            for info in basis_tree.list_files(include_root=True):
+                self._file_revisions[info[0]] = info[-1].revision
+
+            if not self._check or self._working_tree is None:
+                return
+
+            delta = self._working_tree.changes_from(basis_tree, 
+                                                    include_root=True)
+
+            # Using a 2-pass algorithm for renames. This is because you might have
+            # renamed something out of the way, and then created a new file
+            # in which case we would rather see the new marker
+            # Or you might have removed the target, and then renamed
+            # in which case we would rather see the renamed marker
+            for (old_path, new_path, file_id,
+                 kind, text_mod, meta_mod) in delta.renamed:
+                self._clean = False
+                self._file_revisions[old_path] = u'renamed to %s' % (new_path,)
+            for path, file_id, kind in delta.removed:
+                self._clean = False
+                self._file_revisions[path] = 'removed'
+            for path, file_id, kind in delta.added:
+                self._clean = False
+                self._file_revisions[path] = 'new'
+            for (old_path, new_path, file_id,
+                 kind, text_mod, meta_mod) in delta.renamed:
+                self._clean = False
+                self._file_revisions[new_path] = u'renamed from %s' % (old_path,)
+            for path, file_id, kind, text_mod, meta_mod in delta.modified:
+                self._clean = False
+                self._file_revisions[path] = 'modified'
+
+            for path in self._working_tree.unknowns():
+                self._clean = False
+                self._file_revisions[path] = 'unversioned'
+        finally:
+            basis_tree.unlock()
+            if self._working_tree is not None:
+                self._working_tree.unlock()
 
     def _extract_revision_history(self):
         """Find the messages for all revisions in history."""



More information about the bazaar-commits mailing list