Rev 5118: (vila) Correctly resolve --take-this/--take-other for path/content conflicts in file:///home/pqm/archives/thelove/bzr/2.2/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jan 14 23:04:37 UTC 2011


At file:///home/pqm/archives/thelove/bzr/2.2/

------------------------------------------------------------
revno: 5118 [merge]
revision-id: pqm at pqm.ubuntu.com-20110114230435-ww0f1p7y9rgdr7nn
parent: pqm at pqm.ubuntu.com-20101224190215-x3132uugt3ovn2up
parent: v.ladeuil+lp at free.fr-20110114213635-sflp4q80bpcb7ex0
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Fri 2011-01-14 23:04:35 +0000
message:
  (vila) Correctly resolve --take-this/--take-other for path/content conflicts
   in subdirs. (Vincent Ladeuil)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/conflicts.py            conflicts.py-20051001061850-78ef952ba63d2b42
  bzrlib/tests/test_conflicts.py test_conflicts.py-20051006031059-e2dad9bbeaa5891f
=== modified file 'NEWS'
--- a/NEWS	2010-12-24 16:10:07 +0000
+++ b/NEWS	2011-01-14 21:36:35 +0000
@@ -28,6 +28,9 @@
 * Avoid UnicodeDecodeError in ``bzr add`` with multiple files under a non-ascii
   path on windows from symlink support addition. (Martin [gz], #686611)
 
+* Correctly resolve content (and path) conflicts for files in subdirs.
+  (Vincent Ladeuil, #660935)
+
 * Don't probe for a repository from within ``NotBranchError.__repr__``,
   because this can cause knock-on errors at awkward times.
   (Andrew Bennetts, #687653)

=== modified file 'bzrlib/conflicts.py'
--- a/bzrlib/conflicts.py	2010-11-02 14:28:58 +0000
+++ b/bzrlib/conflicts.py	2011-01-14 21:35:52 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2007, 2009, 2010 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -504,7 +504,7 @@
         # Adjust the path for the retained file id
         tid = tt.trans_id_file_id(file_id)
         parent_tid = tt.get_tree_parent(tid)
-        tt.adjust_path(path, parent_tid, tid)
+        tt.adjust_path(osutils.basename(path), parent_tid, tid)
         tt.apply()
 
     def _revision_tree(self, tree, revid):
@@ -590,7 +590,7 @@
         # '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(self.path, parent_tid, this_tid)
+        tt.adjust_path(osutils.basename(self.path), parent_tid, this_tid)
         tt.apply()
 
     def action_take_this(self, tree):

=== modified file 'bzrlib/tests/test_conflicts.py'
--- a/bzrlib/tests/test_conflicts.py	2010-04-06 10:12:42 +0000
+++ b/bzrlib/tests/test_conflicts.py	2011-01-14 21:35:52 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2010 Canonical Ltd
+# Copyright (C) 2005-2011 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -407,6 +407,15 @@
               dict(actions='modify_file', check='file_has_more_content')),
              ('file_deleted',
               dict(actions='delete_file', check='file_doesnt_exist')),),
+            # File modified/deleted in dir
+            (dict(_base_actions='create_file_in_dir',
+                  _path='dir/file', _file_id='file-id'),
+             ('file_modified_in_dir',
+              dict(actions='modify_file_in_dir',
+                   check='file_in_dir_has_more_content')),
+             ('file_deleted_in_dir',
+              dict(actions='delete_file',
+                   check='file_in_dir_doesnt_exist')),),
             ]
         return mirror_scenarios(base_scenarios)
 
@@ -425,6 +434,19 @@
     def check_file_doesnt_exist(self):
         self.failIfExists('branch/file')
 
+    def do_create_file_in_dir(self):
+        return [('add', ('dir', 'dir-id', 'directory', '')),
+                ('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
+
+    def do_modify_file_in_dir(self):
+        return [('modify', ('file-id', 'trunk content\nmore content\n'))]
+
+    def check_file_in_dir_has_more_content(self):
+        self.assertFileEqual('trunk content\nmore content\n', 'branch/dir/file')
+
+    def check_file_in_dir_doesnt_exist(self):
+        self.failIfExists('branch/dir/file')
+
     def _get_resolve_path_arg(self, wt, action):
         return self._path
 
@@ -457,6 +479,16 @@
                    # PathConflicts deletion handling requires a special
                    # hard-coded value
                    path='<deleted>', file_id='file-id')),),
+            # File renamed/deleted in dir
+            (dict(_base_actions='create_file_in_dir'),
+             ('file_renamed_in_dir',
+              dict(actions='rename_file_in_dir', check='file_in_dir_renamed',
+                   path='dir/new-file', file_id='file-id')),
+             ('file_deleted',
+              dict(actions='delete_file', check='file_in_dir_doesnt_exist',
+                   # PathConflicts deletion handling requires a special
+                   # hard-coded value
+                   path='<deleted>', file_id='file-id')),),
             # File renamed/renamed differently
             (dict(_base_actions='create_file'),
              ('file_renamed',
@@ -532,6 +564,20 @@
     def check_dir_doesnt_exist(self):
         self.failIfExists('branch/dir')
 
+    def do_create_file_in_dir(self):
+        return [('add', ('dir', 'dir-id', 'directory', '')),
+                ('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
+
+    def do_rename_file_in_dir(self):
+        return [('rename', ('dir/file', 'dir/new-file'))]
+
+    def check_file_in_dir_renamed(self):
+        self.failIfExists('branch/dir/file')
+        self.failUnlessExists('branch/dir/new-file')
+
+    def check_file_in_dir_doesnt_exist(self):
+        self.failIfExists('branch/dir/file')
+
     def _get_resolve_path_arg(self, wt, action):
         tpath = self._this['path']
         opath = self._other['path']
@@ -960,6 +1006,48 @@
 2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]
 """)
 
+    def test_bug_660935(self):
+        self.run_script("""
+$ bzr init trunk
+Created a standalone tree (format: 2a)
+$ cd trunk
+$ mkdir src
+$ echo trunk > src/file
+$ bzr add
+adding src
+adding src/file
+$ bzr commit -m 'create file on trunk'
+2>Committing to: .../trunk/
+2>added src
+2>added src/file
+2>Committed revision 1.
+$ cd ..
+$ bzr branch trunk featureA
+2>Branched 1 revision(s).
+$ cd featureA
+$ echo featureA > src/file
+$ bzr commit -m 'modify file for featureA'
+2>Committing to: .../featureA/
+2>modified src/file
+2>Committed revision 2.
+$ cd ..
+$ cd trunk
+$ bzr rm src/file
+2>deleted src/file
+$ bzr commit -m 'Delete file'
+2>Committing to: .../trunk/
+2>deleted src/file
+2>Committed revision 2.
+$ cd ../featureA
+$ bzr merge ../trunk
+2>RM  src/file => src/file.THIS
+2>Contents conflict in src/file
+2>1 conflicts encountered.
+$ bzr conflicts
+Contents conflict in src/file
+$ bzr resolve --take-other
+""")
+
 
 class TestResolveActionOption(tests.TestCase):
 




More information about the bazaar-commits mailing list