Rev 2928: Add another direct test in unversion, because the other test 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 22:49:19 BST 2007


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

------------------------------------------------------------
revno: 2928
revision-id:john at arbash-meinel.com-20071023214830-5mlzu2mjcmnx7znz
parent: john at arbash-meinel.com-20071023213503-xrvfwqsaah4jmfn2
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bogus_removal_114615
timestamp: Tue 2007-10-23 16:48:30 -0500
message:
  Add another direct test in unversion, because the other test
  did not trigger the 'delete a file in another directory' bug.
modified:
  bzrlib/tests/workingtree_implementations/test_unversion.py test_unversion.py-20060907074408-bygh2y28jz8u0cg7-1
-------------- next part --------------
=== modified file 'bzrlib/tests/workingtree_implementations/test_unversion.py'
--- a/bzrlib/tests/workingtree_implementations/test_unversion.py	2007-10-23 21:35:03 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_unversion.py	2007-10-23 21:48:30 +0000
@@ -16,7 +16,10 @@
 
 """Tests of the WorkingTree.unversion API."""
 
-from bzrlib import errors
+from bzrlib import (
+    errors,
+    osutils,
+    )
 from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
 
 
@@ -137,3 +140,53 @@
                           ('dir2/f3', 'f3-id'),
                          ], paths)
 
+    def test_unversion_after_conflicted_merge(self):
+        # Test for bug #114615
+        tree_a = self.make_branch_and_tree('A')
+        self.build_tree(['A/a/', 'A/a/m', 'A/a/n'])
+        tree_a.add(['a', 'a/m', 'a/n'], ['a-id', 'm-id', 'n-id'])
+        tree_a.commit('init')
+
+        tree_a.lock_read()
+        try:
+            root_id = tree_a.inventory.root.file_id
+        finally:
+            tree_a.unlock()
+
+        tree_b = tree_a.bzrdir.sprout('B').open_workingtree()
+        self.build_tree(['B/xyz/'])
+        tree_b.add(['xyz'], ['xyz-id'])
+        tree_b.rename_one('a/m', 'xyz/m')
+        tree_b.unversion(['a-id'])
+        tree_b.commit('delete in B')
+
+        paths = [(path, ie.file_id)
+                 for path, ie in tree_b.iter_entries_by_dir()]
+        self.assertEqual([('', root_id),
+                          ('xyz', 'xyz-id'),
+                          ('xyz/m', 'm-id'),
+                         ], paths)
+
+        self.build_tree_contents([('A/a/n', 'new contents for n\n')])
+        tree_a.commit('change n in A')
+
+        # Merging from A should introduce conflicts because 'n' was modified
+        # and removed, so 'a' needs to be restored. We also have a conflict
+        # because 'a' is still an existing directory
+        num_conflicts = tree_b.merge_from_branch(tree_a.branch)
+        self.assertEqual(4, num_conflicts)
+        paths = [(path, ie.file_id)
+                 for path, ie in tree_b.iter_entries_by_dir()]
+        self.assertEqual([('', root_id),
+                          ('a', 'a-id'),
+                          ('xyz', 'xyz-id'),
+                          ('a/n.OTHER', 'n-id'),
+                          ('xyz/m', 'm-id'),
+                         ], paths)
+        tree_b.unversion(['a-id'])
+        paths = [(path, ie.file_id)
+                 for path, ie in tree_b.iter_entries_by_dir()]
+        self.assertEqual([('', root_id),
+                          ('xyz', 'xyz-id'),
+                          ('xyz/m', 'm-id'),
+                         ], paths)



More information about the bazaar-commits mailing list