Rev 5975: (vila) Make ContentConflict resolution more robust (Vincent Ladeuil) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jun 15 14:09:15 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5975 [merge]
revision-id: pqm at pqm.ubuntu.com-20110615140912-gt861n592ieglfe9
parent: pqm at pqm.ubuntu.com-20110615130055-anv7vid86fsmrj17
parent: v.ladeuil+lp at free.fr-20110615132146-52wlrhfezohakpd7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-06-15 14:09:12 +0000
message:
  (vila) Make ContentConflict resolution more robust (Vincent Ladeuil)
modified:
  bzrlib/conflicts.py            conflicts.py-20051001061850-78ef952ba63d2b42
  bzrlib/tests/blackbox/test_resolve.py test_resolve.py-20101103145514-ygpa369r69hhxsmi-1
  bzrlib/tests/test_revert.py    test_revert.py-20060828180832-fqb1v6ecpyvnlitj-1
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'bzrlib/conflicts.py'
--- a/bzrlib/conflicts.py	2011-05-27 00:22:26 +0000
+++ b/bzrlib/conflicts.py	2011-06-15 13:21:46 +0000
@@ -583,7 +583,7 @@
         :param tt: The TreeTransform where the conflict is resolved.
         :param suffix_to_remove: Either 'THIS' or 'OTHER'
 
-        The resolution is symmetric, when taking THIS, OTHER is deleted and
+        The resolution is symmetric: when taking THIS, OTHER is deleted and
         item.THIS is renamed into item and vice-versa.
         """
         try:
@@ -596,12 +596,23 @@
             # never existed or was already deleted (including the case
             # where the user deleted it)
             pass
-        # Rename 'item.suffix_to_remove' (note that if
-        # 'item.suffix_to_remove' has been deleted, this is a no-op)
-        this_tid = tt.trans_id_file_id(self.file_id)
-        parent_tid = tt.get_tree_parent(this_tid)
-        tt.adjust_path(osutils.basename(self.path), parent_tid, this_tid)
-        tt.apply()
+        try:
+            this_path = tt._tree.id2path(self.file_id)
+        except errors.NoSuchId:
+            # The file is not present anymore. This may happen if the user
+            # deleted the file either manually or when resolving a conflict on
+            # the parent.  We may raise some exception to indicate that the
+            # conflict doesn't exist anymore and as such doesn't need to be
+            # resolved ? -- vila 20110615 
+            this_tid = None
+        else:
+            this_tid = tt.trans_id_tree_path(this_path)
+        if this_tid is not None:
+            # Rename 'item.suffix_to_remove' (note that if
+            # 'item.suffix_to_remove' has been deleted, this is a no-op)
+            parent_tid = tt.get_tree_parent(this_tid)
+            tt.adjust_path(osutils.basename(self.path), parent_tid, this_tid)
+            tt.apply()
 
     def action_take_this(self, tree):
         self._resolve_with_cleanups(tree, 'OTHER')

=== modified file 'bzrlib/tests/blackbox/test_resolve.py'
--- a/bzrlib/tests/blackbox/test_resolve.py	2011-01-10 22:20:12 +0000
+++ b/bzrlib/tests/blackbox/test_resolve.py	2011-06-15 11:36:05 +0000
@@ -73,6 +73,44 @@
 """)
 
 
+class TestBug788000(script.TestCaseWithTransportAndScript):
+
+    def test_bug_788000(self):
+        self.run_script('''\
+$ bzr init a
+$ mkdir a/dir
+$ echo foo > a/dir/file
+$ bzr add a/dir
+$ cd a
+$ bzr commit -m one
+$ cd ..
+$ bzr clone a b
+$ echo bar > b/dir/file
+$ cd a
+$ rm -r dir
+$ bzr commit -m two
+$ cd ../b
+''',
+                        null_output_matches_anything=True)
+
+        self.run_script('''\
+$ bzr pull
+Using saved parent location:...
+Now on revision 2.
+2>RM  dir/file => dir/file.THIS
+2>Conflict: can't delete dir because it is not empty.  Not deleting.
+2>Conflict because dir is not versioned, but has versioned children...
+2>Contents conflict in dir/file
+2>3 conflicts encountered.
+''')
+        self.run_script('''\
+$ bzr resolve --take-other
+2>deleted dir/file.THIS
+2>deleted dir
+2>3 conflict(s) resolved, 0 remaining
+''')
+
+
 class TestResolveAuto(tests.TestCaseWithTransport):
 
     def test_auto_resolve(self):

=== modified file 'bzrlib/tests/test_revert.py'
--- a/bzrlib/tests/test_revert.py	2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/test_revert.py	2011-06-15 11:36:05 +0000
@@ -134,15 +134,6 @@
         self.assertPathDoesNotExist('file')
         self.assertEqual({}, tree.merge_modified())
 
-    def test_empty_deprecated(self):
-        tree = self.make_branch_and_tree('.')
-        self.build_tree(['file'])
-        tree.add('file')
-        self.callDeprecated(['Using [] to revert all files is deprecated'
-            ' as of bzr 0.91.  Please use None (the default) instead.'],
-            tree.revert, [])
-        self.assertIs(None, tree.path2id('file'))
-
     def test_revert_file_in_deleted_dir(self):
         tree = self.make_branch_and_tree('.')
         self.build_tree(['dir/', 'dir/file1', 'dir/file2'])

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2011-05-18 16:42:48 +0000
+++ b/bzrlib/workingtree.py	2011-06-15 11:36:05 +0000
@@ -1385,11 +1385,6 @@
     def revert(self, filenames=None, old_tree=None, backups=True,
                pb=None, report_changes=False):
         from bzrlib.conflicts import resolve
-        if filenames == []:
-            filenames = None
-            symbol_versioning.warn('Using [] to revert all files is deprecated'
-                ' as of bzr 0.91.  Please use None (the default) instead.',
-                DeprecationWarning, stacklevel=2)
         if old_tree is None:
             basis_tree = self.basis_tree()
             basis_tree.lock_read()




More information about the bazaar-commits mailing list