Rev 4610: Start writing tests for all expected conflict resolution actions. in file:///home/vila/src/bzr/experimental/conflict-manager/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Sep 16 14:38:07 BST 2009


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

------------------------------------------------------------
revno: 4610
revision-id: v.ladeuil+lp at free.fr-20090916133807-7kv4fmifgvffxtyj
parent: v.ladeuil+lp at free.fr-20090910101952-dv7z80tg6yhxhb4q
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: description
timestamp: Wed 2009-09-16 15:38:07 +0200
message:
  Start writing tests for all expected conflict resolution actions.
  
  * bzrlib/tests/test_conflicts.py: 
  Add shel--like tests for all conflict types.
  
  * Outline.txt:
  Some updates.
-------------- next part --------------
=== modified file 'Outline.txt'
--- a/Outline.txt	2009-09-01 16:15:07 +0000
+++ b/Outline.txt	2009-09-16 13:38:07 +0000
@@ -8,6 +8,7 @@
 https://bugs.edge.launchpad.net/bzr/+bug/113809
 https://bugs.edge.launchpad.net/bzr/+bug/322767
 https://bugs.edge.launchpad.net/bzr/+bug/416903
+https://bugs.edge.launchpad.net/bzr/+bug/355964
 
 https://bugs.edge.launchpad.net/bzr/+bug/405264
 
@@ -135,7 +136,9 @@
 - manually combine <item> and .moved
 
 resolve:
-- delete .moved if still present ? (not done so far ?)
+
+- nothing to do ? If the '.moved' file still exists emit a
+  warning ? Delete it ? Put it to the trash ?
 
 
 Unversioned parent
@@ -149,9 +152,7 @@
 - manually rename <children>
 
 resolve:
-- nothing to do ?
-
-XXX: need investigation to enumerate all cases
+- nothing to do nothing more than the conflicted objects have been created
 
 
 Missing parent
@@ -165,9 +166,7 @@
 - manually rename <children>
 
 resolve:
-- nothing to do ?
-
-XXX: need investigation to enumerate all cases
+- nothing to do, nothing more than the conflicted objects have been created
 
 
 Deleting parent

=== modified file 'bzrlib/tests/test_conflicts.py'
--- a/bzrlib/tests/test_conflicts.py	2009-08-13 16:38:52 +0000
+++ b/bzrlib/tests/test_conflicts.py	2009-09-16 13:38:07 +0000
@@ -23,6 +23,7 @@
     errors,
     tests,
     )
+from bzrlib.tests import script
 
 
 # TODO: Test commit with some added, and added-but-missing files
@@ -172,3 +173,386 @@
         self.assertEqual(conflicts.ConflictList([]), tree.conflicts())
 
 
+class TestResolveConflicts(script.TestCaseWithTransportAndScript):
+
+    preamble = None # The setup script set by daughter classes
+
+    def setUp(self):
+        super(TestResolveConflicts, self).setUp()
+        self.run_script(self.preamble)
+
+
+class TestResolveTextConflicts(TestResolveConflicts):
+    # TBC
+    pass
+
+
+class TestResolveContentConflicts(TestResolveConflicts):
+
+    # FIXME: We need to add the reverse case (delete in trunk, modify in
+    # branch) but that could wait until the resolution mechanism is implemented.
+
+    preamble = """
+bzr init trunk
+cd trunk
+echo 'trunk content' >file
+bzr add file
+bzr commit -m 'Create trunk'
+
+bzr branch . ../branch
+cd ../branch
+bzr rm file
+bzr commit -m 'Delete file'
+
+cd ../trunk
+echo 'more content' >>file
+bzr commit -m 'Modify file'
+
+cd ../branch
+bzr merge ../trunk
+2>+N  file.OTHER
+2>Contents conflict in file
+2>1 conflicts encountered.
+"""
+
+    def test_keep_this(self):
+        self.run_script("""
+bzr rm file.OTHER --force # a simple rm file.OTHER is valid too
+bzr resolve file
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_keep_other(self):
+        self.run_script("""
+bzr mv file.OTHER file
+bzr resolve file
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+
+class TestResolveDuplicatePaths(TestResolveConflicts):
+
+    preamble = """
+bzr init trunk
+cd trunk
+echo 'trunk content' >file
+bzr add file
+bzr commit -m 'Create trunk'
+echo 'trunk content too' >file2
+bzr add file2
+bzr commit -m 'Add file2 in trunk'
+
+bzr branch . -r 1 ../branch
+cd ../branch
+echo 'branch content' >file2
+bzr add file2
+bzr commit -m 'Add file2 in branch'
+
+bzr merge ../trunk
+2>+N  file2
+2>R   file2 => file2.moved
+2>Conflict adding file file2.  Moved existing file to file2.moved.
+2>1 conflicts encountered.
+"""
+
+    def test_keep_this(self):
+        self.run_script("""
+bzr rm file2  --force
+bzr mv file2.moved file2
+bzr resolve file2
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_keep_other(self):
+        self.failIfExists('branch/file2.moved')
+        self.run_script("""
+bzr rm file2.moved --force
+bzr resolve file2
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+        self.failIfExists('branch/file2.moved')
+
+
+class TestResolveUnversionedParent(TestResolveConflicts):
+
+    preamble = """
+bzr init trunk
+cd trunk
+echo 'trunk content' >file
+bzr add file
+bzr commit -m 'Create trunk'
+echo 'trunk content too' >file2
+bzr add file2
+bzr commit -m 'Add file2 in trunk'
+
+bzr branch . -r 1 ../branch
+cd ../branch
+echo 'branch content' >file2
+bzr add file2
+bzr commit -m 'Add file2 in branch'
+
+bzr merge ../trunk
+2>+N  file2
+2>R   file2 => file2.moved
+2>Conflict adding file file2.  Moved existing file to file2.moved.
+2>1 conflicts encountered.
+"""
+
+    def test_keep_this(self):
+        self.run_script("""
+bzr rm file2  --force
+bzr mv file2.moved file2
+bzr resolve file2
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_keep_other(self):
+        self.failIfExists('branch/file2.moved')
+        self.run_script("""
+bzr rm file2.moved --force
+bzr resolve file2
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+        self.failIfExists('branch/file2.moved')
+
+
+class TestResolveMissingParent(TestResolveConflicts):
+
+    preamble = """
+bzr init trunk
+cd trunk
+mkdir dir
+echo 'trunk content' >dir/file
+bzr add
+bzr commit -m 'Create trunk'
+echo 'trunk content' >dir/file2
+bzr add dir/file2
+bzr commit -m 'Add dir/file2 in branch'
+
+bzr branch . -r 1 ../branch
+cd ../branch
+bzr rm dir/file --force
+bzr rm dir
+bzr commit -m 'Remove dir/file'
+
+bzr merge ../trunk
+2>+N  dir/
+2>+N  dir/file2
+2>Conflict adding files to dir.  Created directory.
+2>Conflict because dir is not versioned, but has versioned children.  Versioned directory.
+2>2 conflicts encountered.
+"""
+
+    def test_keep_them_all(self):
+        self.run_script("""
+bzr resolve dir
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_adopt_child(self):
+        self.run_script("""
+bzr mv dir/file2 file2
+bzr rm dir --force
+bzr resolve dir
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_kill_them_all(self):
+        self.run_script("""
+bzr rm dir --force
+bzr resolve dir
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+
+class TestResolveDeletingParent(TestResolveConflicts):
+
+    preamble = """
+bzr init trunk
+cd trunk
+mkdir dir
+echo 'trunk content' >dir/file
+bzr add
+bzr commit -m 'Create trunk'
+bzr rm dir/file --force
+bzr rm dir --force
+bzr commit -m 'Remove dir/file'
+
+bzr branch . -r 1 ../branch
+cd ../branch
+echo 'branch content' >dir/file2
+bzr add dir/file2
+bzr commit -m 'Add dir/file2 in branch'
+
+bzr merge ../trunk
+2>-D  dir/file
+2>Conflict: can't delete dir because it is not empty.  Not deleting.
+2>Conflict because dir is not versioned, but has versioned children.  Versioned directory.
+2>2 conflicts encountered.
+"""
+
+    def test_keep_them_all(self):
+        self.run_script("""
+bzr resolve dir
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_adopt_child(self):
+        self.run_script("""
+bzr mv dir/file2 file2
+bzr rm dir --force
+bzr resolve dir
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_kill_them_all(self):
+        self.run_script("""
+bzr rm dir --force
+bzr resolve dir
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+
+class TestResolvePathConflict(TestResolveConflicts):
+
+    preamble = """
+bzr init trunk
+cd trunk
+mkdir dir
+echo 'Boo!' >file
+bzr add
+bzr commit -m 'Create trunk'
+bzr mv file file-in-trunk
+bzr commit -m 'Renamed to file-in-trunk'
+
+bzr branch . -r 1 ../branch
+cd ../branch
+bzr mv file file-in-branch
+bzr commit -m 'Renamed to file-in-branch'
+
+bzr merge ../trunk
+2>R   file-in-branch => file-in-trunk
+2>Path conflict: file-in-branch / file-in-trunk
+2>1 conflicts encountered.
+"""
+
+    def test_keep_source(self):
+        self.run_script("""
+bzr resolve file-in-trunk
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_keep_target(self):
+        self.run_script("""
+bzr mv file-in-trunk file-in-branch
+bzr resolve file-in-branch
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+
+class TestResolveParentLoop(TestResolveConflicts):
+
+    preamble = """
+bzr init trunk
+cd trunk
+bzr mkdir dir1
+bzr mkdir dir2
+bzr commit -m 'Create trunk'
+bzr mv dir2 dir1
+bzr commit -m 'Moved dir2 into dir1'
+
+bzr branch . -r 1 ../branch
+cd ../branch
+bzr mv dir1 dir2
+bzr commit -m 'Moved dir1 into dir2'
+
+bzr merge ../trunk
+2>Conflict moving dir2/dir1 into dir2.  Cancelled move.
+2>1 conflicts encountered.
+"""
+
+    def test_keep_target(self):
+        self.run_script("""
+bzr resolve dir2
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_keep_source(self):
+        self.run_script("""
+bzr ls -RV
+bzr mv dir2/dir1 dir1
+bzr mv dir2 dir1
+bzr resolve dir2
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+
+class TestResolveNonDirectoryParent(TestResolveConflicts):
+
+    preamble = """
+bzr init trunk
+cd trunk
+bzr mkdir foo
+bzr commit -m 'Create trunk'
+echo "Boing" >foo/bar
+bzr add foo/bar
+bzr commit -m 'Add foo/bar'
+
+bzr branch . -r 1 ../branch
+cd ../branch
+rm -r foo
+echo "Boo!" >foo
+bzr commit -m 'foo is now a file'
+
+bzr merge ../trunk
+2>+N  foo.new/bar
+2>RK  foo => foo.new/
+# FIXME: The message is misleading, foo.new *is* a directory when the message
+# is displayed -- vila 090916
+2>Conflict: foo.new is not a directory, but has files in it.  Created directory.
+2>1 conflicts encountered.
+"""
+
+    def test_remove_this(self):
+        self.run_script("""
+bzr rm foo --force
+bzr mv foo.new foo
+bzr resolve foo
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+    def test_remove_other(self):
+        self.run_script("""
+bzr rm foo.new --force
+# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
+# aside ? -- vila 090916
+bzr add foo
+bzr resolve foo.new
+bzr commit --strict -m 'No more conflicts nor unknown files'
+""")
+
+
+class TestMalformedTransform(script.TestCaseWithTransportAndScript):
+
+    def test_bug_430129(self):
+        # This is nearly like TestResolveNonDirectoryParent but with branch and
+        # trunk switched. As such it should certainly produce the same
+        # conflict.
+        self.run_script("""
+bzr init trunk
+cd trunk
+bzr mkdir foo
+bzr commit -m 'Create trunk'
+rm -r foo
+echo "Boo!" >foo
+bzr commit -m 'foo is now a file'
+
+bzr branch . -r 1 ../branch
+cd ../branch
+echo "Boing" >foo/bar
+bzr add foo/bar
+bzr commit -m 'Add foo/bar'
+
+bzr merge ../trunk
+2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]
+""")



More information about the bazaar-commits mailing list