Rev 6015: Add a test to explicitly test empty preview tree and empty working tree. in file:///home/vila/src/bzr/reviews/merge-prefers-this-root/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Jul 7 08:59:35 UTC 2011


At file:///home/vila/src/bzr/reviews/merge-prefers-this-root/

------------------------------------------------------------
revno: 6015
revision-id: v.ladeuil+lp at free.fr-20110707085935-pj1cze35av1ndp04
parent: v.ladeuil+lp at free.fr-20110707085833-xn1dd2zfieoyxxdj
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: merge-prefers-this-root
timestamp: Thu 2011-07-07 10:59:35 +0200
message:
  Add a test to explicitly test empty preview tree and empty working tree.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py	2011-07-06 20:52:00 +0000
+++ b/bzrlib/tests/test_merge.py	2011-07-07 08:59:35 +0000
@@ -135,20 +135,29 @@
             preview = tt.get_preview_tree()
             self.assertEqual(wt.get_root_id(), preview.get_root_id())
 
+    def test_merge_preview_unrelated_retains_root(self):
+        wt = self.make_branch_and_tree('tree')
+        null_tree = wt.basis_tree()
+        wt.commit('add root to tree')
+        other_tree = self.make_branch_and_tree('other')
+        other_tree.commit('add root in other')
+        merger = _mod_merge.Merge3Merger(wt, wt, null_tree, other_tree,
+                                         this_branch=wt.branch,
+                                         do_merge=False)
+        with merger.make_preview_transform() as tt:
+            preview = tt.get_preview_tree()
+            self.assertEqual(wt.get_root_id(), preview.get_root_id())
+
     def test_merge_unrelated_retains_root(self):
         wt = self.make_branch_and_tree('tree')
-        null_tree = wt.basis_tree()
-        self.build_tree(['tree/file'])
-        wt.add('file')
-        wt.commit('tree with root')
+        wt.commit('add root to tree')
+        root_id_before_merge = wt.get_root_id()
         other_tree = self.make_branch_and_tree('other')
-        other_tree.commit('add root')
-        merger = _mod_merge.Merge3Merger(wt, wt, null_tree, other_tree,
-                                         this_branch=wt.branch,
-                                         do_merge=False)
-        with merger.make_preview_transform() as tt:
-            preview = tt.get_preview_tree()
-            self.assertEqual(wt.get_root_id(), preview.get_root_id())
+        other_tree.commit('add root to other')
+        self.debug()
+        wt.merge_from_branch(other_tree.branch, from_revision='null:',
+                             to_revision=other_tree.last_revision())
+        self.assertEqual(root_id_before_merge, wt.get_root_id())
 
     def test_create_rename(self):
         """Rename an inventory entry while creating the file"""



More information about the bazaar-commits mailing list