Rev 4637: Tweak the fix to not use helpers but let resolve restore the old version. in file:///home/vila/src/bzr/bugs/531967-unify-name-conflicts/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Mar 10 09:44:36 GMT 2010


At file:///home/vila/src/bzr/bugs/531967-unify-name-conflicts/

------------------------------------------------------------
revno: 4637
revision-id: v.ladeuil+lp at free.fr-20100310094436-b21be33p3nro45u0
parent: v.ladeuil+lp at free.fr-20100309163256-c3ray0p8pz62kbqn
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 531967-unify-name-conflicts
timestamp: Wed 2010-03-10 10:44:36 +0100
message:
  Tweak the fix to not use helpers but let resolve restore the old version.
  
  * bzrlib/merge.py:
  (Merge3Merger._merge_names): Don't create helpers as it may
  conflict with a related 'contents conflit'.
  
  * bzrlib/conflicts.py:
  (PathConflict.associated_filenames): No more helpers.
  (PathConflict._resolve): Restore the item if needed (based on the
  paths involved).
-------------- next part --------------
=== modified file 'bzrlib/conflicts.py'
--- a/bzrlib/conflicts.py	2010-03-09 16:32:56 +0000
+++ b/bzrlib/conflicts.py	2010-03-10 09:44:36 +0000
@@ -463,18 +463,8 @@
         return s
 
     def associated_filenames(self):
-        if self.file_id is None:
-            return []
-        else:
-            # FIXME: This may be too precise. associated_filenames() is really
-            # about *potentially* existing files, so we may just avoid the
-            # tests against <deleted>
-            if self.path == '<deleted>':
-                return [self.conflict_path + '.OTHER']
-            elif self.conflict_path == '<deleted>':
-                return [self.path + '.THIS']
-            else:
-                return []
+        # No additional files have been generated here
+        return []
 
     def _resolve(self, tt, file_id, path, winner):
         """Resolve the conflict.
@@ -484,19 +474,29 @@
         :param path: The retained path.
         :param winner: 'this' or 'other' indicates which side is the winner.
         """
-        helper_path = None
+        path_to_create = None
         if winner == 'this':
             if self.path == '<deleted>':
                 return # Nothing to do
             if self.conflict_path == '<deleted>':
-                helper_path = self.path + '.THIS'
+                path_to_create = self.path
+                revid = tt._tree.get_parent_ids()[0]
         elif winner == 'other':
             if self.conflict_path == '<deleted>':
                 return  # Nothing to do
             if self.path == '<deleted>':
-                helper_path = self.conflict_path + '.OTHER'
-        if helper_path is not None:
-            tt.version_file(file_id, tt.trans_id_tree_path(helper_path))
+                path_to_create = self.conflict_path
+                # FIXME: If there are more than two parents we may need to
+                # iterate. Taking the last parent is the safer bet in the mean
+                # time. -- vila 20100309
+                revid = tt._tree.get_parent_ids()[-1]
+        if path_to_create is not None:
+            tid = tt.trans_id_tree_path(path_to_create)
+            transform.create_from_tree(
+                tt, tt.trans_id_tree_path(path_to_create),
+                tt._tree.revision_tree(revid), file_id)
+            tt.version_file(file_id, tid)
+
         # Adjust the path for the retained file id
         tid = tt.trans_id_file_id(file_id)
         parent_tid = tt.get_tree_parent(tid)
@@ -504,6 +504,7 @@
         tt.apply()
 
     def _get_or_infer_file_id(self, tree):
+        # FIXME: Needs cleanup
         if self.file_id is not None:
             return self.file_id
 

=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py	2010-03-09 16:24:31 +0000
+++ b/bzrlib/merge.py	2010-03-10 09:44:36 +0000
@@ -1173,9 +1173,6 @@
         return 'conflict'
 
     @staticmethod
-    # FIXME: this looks unused and probably needs to be deprecated, the
-    # parameter order (this, base, other) doesn't match the other methods
-    # (base, other, this) anyway -- vila 20100308
     def scalar_three_way(this_tree, base_tree, other_tree, file_id, key):
         """Do a three-way test on a scalar.
         Return "this", "other" or "conflict", depending whether a value wins.
@@ -1234,18 +1231,6 @@
         if name_winner == 'conflict' or parent_id_winner == 'conflict':
             # Creating helpers here cause problems down the road if a
             # ContentConflict needs to be created so we should not do that
-            if other_name is None or other_parent is None:
-                # 'other' has been deleted, leave a .THIS
-                parent_id = self.tt.trans_id_file_id(this_parent)
-                trans_id = self.tt.create_path(this_name + '.THIS', parent_id)
-                transform.create_from_tree(self.tt, trans_id, self.this_tree,
-                                           file_id)
-            elif this_name is None or this_parent is None:
-                # 'this' has been deleted, leave a .OTHER
-                parent_id = self.tt.trans_id_file_id(other_parent)
-                trans_id = self.tt.create_path(other_name + '.OTHER', parent_id)
-                transform.create_from_tree(self.tt, trans_id, self.other_tree,
-                                           file_id)
             trans_id = self.tt.trans_id_file_id(file_id)
             self._raw_conflicts.append(('path conflict', trans_id, file_id,
                                         this_parent, this_name,



More information about the bazaar-commits mailing list