Rev 3963: Change _get_trees_to_diff so that they return locked objects. in lp:///~jameinel/bzr/win32-shelve

John Arbash Meinel john at arbash-meinel.com
Mon Jan 26 21:38:01 GMT 2009


At lp:///~jameinel/bzr/win32-shelve

------------------------------------------------------------
revno: 3963
revision-id: john at arbash-meinel.com-20090126213740-uy7eg1o2cjxze5b3
parent: john at arbash-meinel.com-20090126204620-gox8qouutcotl15x
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: win32-shelve
timestamp: Mon 2009-01-26 15:37:40 -0600
message:
  Change _get_trees_to_diff so that they return locked objects.
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-01-15 05:18:22 +0000
+++ b/bzrlib/builtins.py	2009-01-26 21:37:40 +0000
@@ -1687,11 +1687,18 @@
 
         old_tree, new_tree, specific_files, extra_trees = \
                 _get_trees_to_diff(file_list, revision, old, new)
-        return show_diff_trees(old_tree, new_tree, sys.stdout, 
-                               specific_files=specific_files,
-                               external_diff_options=diff_options,
-                               old_label=old_label, new_label=new_label,
-                               extra_trees=extra_trees, using=using)
+        try:
+            return show_diff_trees(old_tree, new_tree, sys.stdout,
+                                   specific_files=specific_files,
+                                   external_diff_options=diff_options,
+                                   old_label=old_label, new_label=new_label,
+                                   extra_trees=extra_trees, using=using)
+        finally:
+            old_tree.unlock()
+            new_tree.unlock()
+            if extra_trees:
+                for tree in extra_trees:
+                    tree.unlock()
 
 
 class cmd_deleted(Command):

=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py	2009-01-06 16:16:52 +0000
+++ b/bzrlib/diff.py	2009-01-26 21:37:40 +0000
@@ -327,9 +327,13 @@
         old_url = default_location
     working_tree, branch, relpath = \
         bzrdir.BzrDir.open_containing_tree_or_branch(old_url)
+    if working_tree is not None:
+        working_tree.lock_read()
     if consider_relpath and relpath != '':
         specific_files.append(relpath)
     old_tree = _get_tree_to_diff(old_revision_spec, working_tree, branch)
+    if old_tree is not working_tree:
+        old_tree.lock_read()
 
     # Get the new location
     if new_url is None:
@@ -341,6 +345,8 @@
             specific_files.append(relpath)
     new_tree = _get_tree_to_diff(new_revision_spec, working_tree, branch,
         basis_is_default=working_tree is None)
+    if new_tree is not working_tree:
+        new_tree.lock_read()
 
     # Get the specific files (all files is None, no files is [])
     if make_paths_wt_relative and working_tree is not None:



More information about the bazaar-commits mailing list