Rev 4537: Fix WorkingTree4.unversion when unversioning the parents of files that were renamed from a basis tree. (Robert Collins, bug 187207) in http://bazaar.launchpad.net/~lifeless/bzr/bug-187207

Robert Collins robertc at robertcollins.net
Wed Jul 15 05:33:27 BST 2009


At http://bazaar.launchpad.net/~lifeless/bzr/bug-187207

------------------------------------------------------------
revno: 4537
revision-id: robertc at robertcollins.net-20090715043314-jeuws3m6utp6cfyd
parent: pqm at pqm.ubuntu.com-20090714173313-3p3ytzlfuc3y2bm6
committer: Robert Collins <robertc at robertcollins.net>
branch nick: bug-187207
timestamp: Wed 2009-07-15 14:33:14 +1000
message:
  Fix WorkingTree4.unversion when unversioning the parents of files  that were renamed from a basis tree. (Robert Collins, bug 187207)
=== modified file 'NEWS'
--- a/NEWS	2009-07-14 16:27:40 +0000
+++ b/NEWS	2009-07-15 04:33:14 +0000
@@ -25,6 +25,10 @@
 * BranchBuilder now accepts timezone to avoid test failures in countries far
   from GMT. (Vincent Ladeuil, #397716)
 
+* ``WorkingTree4.unversion`` will no longer fail to unversion ids which
+  were present in a parent tree but renamed in the working tree.
+  (Robert Collins, #187207)
+
 Improvements
 ************
 

=== modified file 'bzrlib/tests/per_workingtree/test_unversion.py'
--- a/bzrlib/tests/per_workingtree/test_unversion.py	2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_unversion.py	2009-07-15 04:33:14 +0000
@@ -37,6 +37,20 @@
         tree = self.make_branch_and_tree('.')
         self.assertRaises(errors.NoSuchId, tree.unversion, ['missing-id'])
 
+    def test_unversion_parent_and_child_renamed_bug_187207(self):
+        # When unversioning dirstate trees show a bug in dealing with
+        # unversioning children of reparented children of unversioned
+        # paths when relocation entries are present and the relocation
+        # points later into the dirstate.
+        tree = self.make_branch_and_tree(['.'])
+        self.build_tree(['del/', 'del/sub/', 'del/sub/b'])
+        tree.add(['del', 'del/sub', 'del/sub/b'], ['del', 'sub', 'b'])
+        tree.commit('setup')
+        tree.rename_one('del/sub', 'sub')
+        self.assertEqual('sub/b', tree.id2path('b'))
+        tree.unversion(['del', 'b'])
+        self.assertRaises(errors.NoSuchId, tree.id2path, 'b')
+
     def test_unversion_several_files(self):
         """After unversioning several files, they should not be versioned."""
         tree = self.make_branch_and_tree('.')

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2009-07-06 07:51:29 +0000
+++ b/bzrlib/workingtree_4.py	2009-07-15 04:33:14 +0000
@@ -1195,13 +1195,16 @@
                 # just forget the whole block.
                 entry_index = 0
                 while entry_index < len(block[1]):
-                    # Mark this file id as having been removed
                     entry = block[1][entry_index]
-                    ids_to_unversion.discard(entry[0][2])
-                    if (entry[1][0][0] in 'ar' # don't remove absent or renamed
-                                               # entries
-                        or not state._make_absent(entry)):
+                    if entry[1][0][0] in 'ar':
+                        # don't remove absent or renamed entries
                         entry_index += 1
+                    else:
+                        # Mark this file id as having been removed
+                        ids_to_unversion.discard(entry[0][2])
+                        if not state._make_absent(entry):
+                            # The block has not shrunk.
+                            entry_index += 1
                 # go to the next block. (At the moment we dont delete empty
                 # dirblocks)
                 block_index += 1




More information about the bazaar-commits mailing list