Rev 2925: Add a test which shows why the previous fix is broken. in http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/bogus_removal_114615

John Arbash Meinel john at arbash-meinel.com
Tue Oct 23 20:52:24 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/bogus_removal_114615

------------------------------------------------------------
revno: 2925
revision-id:john at arbash-meinel.com-20071023195147-echbf8brs44uifo4
parent: john at arbash-meinel.com-20071023194449-wb8fafx5unde63wq
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bogus_removal_114615
timestamp: Tue 2007-10-23 14:51:47 -0500
message:
  Add a test which shows why the previous fix is broken.
  Basically, it causes files which are renamed *out* of that directory to
  be considered deleted. So instead just remove the assertion that
  the target should not be absent.
modified:
  bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
  bzrlib/tests/workingtree_implementations/test_commit.py test_commit.py-20060421013633-1610ec2331c8190f
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2007-10-23 19:44:49 +0000
+++ b/bzrlib/dirstate.py	2007-10-23 19:51:47 +0000
@@ -1971,8 +1971,6 @@
         # because we are removing it. But if it is a rename, we need to remove
         # the actual location.
         details = current_old[1][0]
-        if details[0] == 'r':
-            all_remaining_keys.add(tuple(osutils.split(details[1])) + (current_old[0][2],))
         for details in current_old[1][1:]:
             if details[0] not in ('a', 'r'): # absent, relocated
                 all_remaining_keys.add(current_old[0])
@@ -2004,12 +2002,6 @@
                 self._find_entry_index(update_key, self._dirblocks[update_block_index][1])
             assert present, 'could not find entry for %s' % (update_key,)
             update_tree_details = self._dirblocks[update_block_index][1][update_entry_index][1]
-            # it must not be absent at the moment
-            # This doesn't seem to be strictly true, if you have a file renamed
-            # inside a directory, and you remove the directory
-            if update_tree_details[0][0] == 'a':
-                import pdb; pdb.set_trace()
-            assert update_tree_details[0][0] != 'a' # absent
             update_tree_details[0] = DirState.NULL_PARENT_DETAILS
         self._dirblock_state = DirState.IN_MEMORY_MODIFIED
         return last_reference

=== modified file 'bzrlib/tests/workingtree_implementations/test_commit.py'
--- a/bzrlib/tests/workingtree_implementations/test_commit.py	2007-10-23 18:12:18 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_commit.py	2007-10-23 19:51:47 +0000
@@ -112,6 +112,29 @@
         # The only paths left should be the root
         self.assertEqual([('', root_id)], paths)
 
+    def test_no_autodelete_renamed_away(self):
+        tree_a = self.make_branch_and_tree('a')
+        self.build_tree(['a/dir/', 'a/dir/f1', 'a/dir/f2', 'a/dir2/'])
+        tree_a.add(['dir', 'dir/f1', 'dir/f2', 'dir2'],
+                   ['dir-id', 'f1-id', 'f2-id', 'dir2-id'])
+        rev_id1 = tree_a.commit('init')
+        # Rename one entry out of this directory
+        tree_a.rename_one('dir/f1', 'dir2/a')
+        osutils.rmtree('a/dir')
+        tree_a.commit('autoremoved')
+
+        tree_a.lock_read()
+        try:
+            root_id = tree_a.inventory.root.file_id
+            paths = [(path, ie.file_id)
+                     for path, ie in tree_a.iter_entries_by_dir()]
+        finally:
+            tree_a.unlock()
+        # The only paths left should be the root
+        self.assertEqual([('', root_id), ('dir2', 'dir2-id'),
+                          ('dir2/a', 'f1-id'),
+                         ], paths)
+
     def test_commit_sets_last_revision(self):
         tree = self.make_branch_and_tree('tree')
         committed_id = tree.commit('foo', rev_id='foo')



More information about the bazaar-commits mailing list