Rev 4636: Remove some duplication. in file:///home/vila/src/bzr/bugs/531967-unify-name-conflicts/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Mar 9 16:32:56 GMT 2010


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

------------------------------------------------------------
revno: 4636
revision-id: v.ladeuil+lp at free.fr-20100309163256-c3ray0p8pz62kbqn
parent: v.ladeuil+lp at free.fr-20100309162431-hkp98mkfmprus54s
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 531967-unify-name-conflicts
timestamp: Tue 2010-03-09 17:32:56 +0100
message:
  Remove some duplication.
-------------- next part --------------
=== modified file 'bzrlib/conflicts.py'
--- a/bzrlib/conflicts.py	2010-03-09 15:24:27 +0000
+++ b/bzrlib/conflicts.py	2010-03-09 16:32:56 +0000
@@ -476,15 +476,25 @@
             else:
                 return []
 
-    def _resolve(self, tt, file_id, path, helper_path=None):
+    def _resolve(self, tt, file_id, path, winner):
         """Resolve the conflict.
 
         :param tt: The TreeTransform where the conflict is resolved.
         :param file_id: The retained file id.
         :param path: The retained path.
-        :param helper_path: The existing but unversioned path that needs to be
-            restored.
+        :param winner: 'this' or 'other' indicates which side is the winner.
         """
+        helper_path = None
+        if winner == 'this':
+            if self.path == '<deleted>':
+                return # Nothing to do
+            if self.conflict_path == '<deleted>':
+                helper_path = self.path + '.THIS'
+        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))
         # Adjust the path for the retained file id
@@ -528,15 +538,8 @@
 
     def action_take_this(self, tree):
         if self.file_id is not None:
-            if self.path == '<deleted>':
-                # Nothing to do
-                return
-            if self.conflict_path == '<deleted>':
-                helper_path = self.path + '.THIS'
-            else:
-                helper_path = None
             self._resolve_with_cleanups(tree, self.file_id, self.path,
-                                        helper_path=helper_path)
+                                        winner='this')
         else:
             # Prior to bug #531967 we need to find back the file_id and restore
             # the content from there
@@ -546,16 +549,9 @@
 
     def action_take_other(self, tree):
         if self.file_id is not None:
-            if self.conflict_path == '<deleted>':
-                # Nothing to do
-                return
-            if self.path == '<deleted>':
-                helper_path = self.conflict_path + '.OTHER'
-            else:
-                helper_path = None
             self._resolve_with_cleanups(tree, self.file_id,
                                         self.conflict_path,
-                                        helper_path=helper_path)
+                                        winner='other')
         else:
             # Prior to bug #531967 we need to find back the file_id and restore
             # the content from there



More information about the bazaar-commits mailing list