Rev 4662: Fixed as per Aaron's remark. in file:///home/vila/src/bzr/experimental/conflict-manager/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Jan 6 11:18:45 GMT 2010


At file:///home/vila/src/bzr/experimental/conflict-manager/

------------------------------------------------------------
revno: 4662
revision-id: v.ladeuil+lp at free.fr-20100106111845-inun0xxl8rx4yvst
parent: v.ladeuil+lp at free.fr-20100105170638-5355y6f8go0luo52
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: description
timestamp: Wed 2010-01-06 12:18:45 +0100
message:
  Fixed as per Aaron's remark.
  
  * bzrlib/tests/test_conflicts.py:
  (TestResolveParentLoop.test_resolve_keeping_mine,
  TestResolveParentLoop.test_resolve_taking_theirs): Toghten the
  tests as debug showed they were passing with bogus code.
  
  * bzrlib/conflicts.py:
  (ParentLoop.take_theirs): Use a TreeTransform to safely rename
  multiple files at once.
-------------- next part --------------
=== modified file 'bzrlib/conflicts.py'
--- a/bzrlib/conflicts.py	2010-01-05 17:06:38 +0000
+++ b/bzrlib/conflicts.py	2010-01-06 11:18:45 +0000
@@ -31,6 +31,7 @@
     osutils,
     rio,
     trace,
+    transform,
     workingtree,
     )
 """)
@@ -607,11 +608,19 @@
     def take_theirs(self, tree):
         # FIXME: We shouldn't have to manipulate so many paths here (and there
         # is probably a bug or two...)
+        base_path = osutils.basename(self.path)
         conflict_base_path = osutils.basename(self.conflict_path)
-        base_path = osutils.basename(self.path)
-        tree.rename_one(self.conflict_path, conflict_base_path)
-        tree.rename_one(self.path,
-                        osutils.joinpath([conflict_base_path, base_path]))
+        tt = transform.TreeTransform(tree)
+        try:
+            p_tid = tt.trans_id_file_id(self.file_id)
+            parent_tid = tt.get_tree_parent(p_tid)
+            cp_tid = tt.trans_id_file_id(self.conflict_file_id)
+            cparent_tid = tt.get_tree_parent(cp_tid)
+            tt.adjust_path(base_path, cparent_tid, cp_tid)
+            tt.adjust_path(conflict_base_path, parent_tid, p_tid)
+            tt.apply()
+        finally:
+            tt.finalize()
 
 
 class UnversionedParent(HandledConflict):

=== modified file 'bzrlib/tests/test_conflicts.py'
--- a/bzrlib/tests/test_conflicts.py	2010-01-05 17:06:38 +0000
+++ b/bzrlib/tests/test_conflicts.py	2010-01-06 11:18:45 +0000
@@ -551,12 +551,14 @@
 $ bzr resolve --keep-mine dir2
 $ bzr commit --strict -m 'No more conflicts nor unknown files'
 """)
+        self.failUnlessExists('dir2')
 
     def test_resolve_taking_theirs(self):
         self.run_script("""
 $ bzr resolve --take-theirs dir2
 $ bzr commit --strict -m 'No more conflicts nor unknown files'
 """)
+        self.failUnlessExists('dir1')
 
 
 class TestResolveNonDirectoryParent(TestResolveConflicts):



More information about the bazaar-commits mailing list