Rev 4665: Unlock trees even if we fail to create a TreeTransform object. in http://bazaar.launchpad.net/~vila/bzr/2.0-integration

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Sep 15 17:28:25 BST 2009


At http://bazaar.launchpad.net/~vila/bzr/2.0-integration

------------------------------------------------------------
revno: 4665 [merge]
revision-id: v.ladeuil+lp at free.fr-20090915162812-ql1jzjeseizj7l2k
parent: pqm at pqm.ubuntu.com-20090911072307-zdxq23xosfyiq444
parent: garyvdm at gmail.com-20090915112227-jcrujse8j1ytsb7h
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 2.0-integration
timestamp: Tue 2009-09-15 18:28:12 +0200
message:
  Unlock trees even if we fail to create a TreeTransform object.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
  bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2009-09-10 06:47:42 +0000
+++ b/NEWS	2009-09-11 21:19:32 +0000
@@ -2,6 +2,16 @@
 Bazaar Release Notes
 ####################
 
+bzr 2.0.1
+##########
+
+Bug Fixes
+*********
+
+* Make sure that we unlock the tree if we fail to create a TreeTransform
+  object when doing a merge, and there is limbo, or pending-deletions
+  directory.  (Gary van der Merwe, #427773)
+
 
 bzr 2.0rc2
 ##########

=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py	2009-09-10 06:32:42 +0000
+++ b/bzrlib/merge.py	2009-09-11 21:19:32 +0000
@@ -613,19 +613,21 @@
         self.this_tree.lock_tree_write()
         self.base_tree.lock_read()
         self.other_tree.lock_read()
-        self.tt = TreeTransform(self.this_tree, self.pb)
         try:
-            self.pp.next_phase()
-            self._compute_transform()
-            self.pp.next_phase()
-            results = self.tt.apply(no_conflicts=True)
-            self.write_modified(results)
+            self.tt = TreeTransform(self.this_tree, self.pb)
             try:
-                self.this_tree.add_conflicts(self.cooked_conflicts)
-            except UnsupportedOperation:
-                pass
+                self.pp.next_phase()
+                self._compute_transform()
+                self.pp.next_phase()
+                results = self.tt.apply(no_conflicts=True)
+                self.write_modified(results)
+                try:
+                    self.this_tree.add_conflicts(self.cooked_conflicts)
+                except UnsupportedOperation:
+                    pass
+            finally:
+                self.tt.finalize()
         finally:
-            self.tt.finalize()
             self.other_tree.unlock()
             self.base_tree.unlock()
             self.this_tree.unlock()

=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py	2009-09-10 06:32:42 +0000
+++ b/bzrlib/tests/test_merge.py	2009-09-15 11:22:27 +0000
@@ -36,7 +36,7 @@
 from bzrlib.osutils import pathjoin, file_kind
 from bzrlib.tests import TestCaseWithTransport, TestCaseWithMemoryTransport
 from bzrlib.workingtree import WorkingTree
-
+from bzrlib.transform import TreeTransform
 
 class TestMerge(TestCaseWithTransport):
     """Test appending more than one revision"""
@@ -1143,6 +1143,27 @@
                 'X\n'
                 'e\n', 'test/foo')
 
+    def get_limbodir_deletiondir(self, wt):
+        transform = TreeTransform(wt)
+        limbodir = transform._limbodir
+        deletiondir = transform._deletiondir
+        transform.finalize()
+        return (limbodir, deletiondir)
+    
+    def test_merge_with_existing_limbo(self):
+        wt = self.make_branch_and_tree('this')
+        (limbodir, deletiondir) =  self.get_limbodir_deletiondir(wt)
+        os.mkdir(limbodir)
+        self.assertRaises(errors.ExistingLimbo, self.do_merge, wt, wt)
+        self.assertRaises(errors.LockError, wt.unlock)
+
+    def test_merge_with_pending_deletion(self):
+        wt = self.make_branch_and_tree('this')
+        (limbodir, deletiondir) =  self.get_limbodir_deletiondir(wt)
+        os.mkdir(deletiondir)
+        self.assertRaises(errors.ExistingPendingDeletion, self.do_merge, wt, wt)
+        self.assertRaises(errors.LockError, wt.unlock)
+
 
 class TestMerge3Merge(TestCaseWithTransport, TestMergeImplementation):
 



More information about the bazaar-commits mailing list