Author: philip
Date: Mon Jan 16 11:39:32 2012
New Revision: 1231944

URL: http://svn.apache.org/viewvc?rev=1231944&view=rev
Log:
Add a regression test for a patch problem where the patch file causes
multiple levels of directories to be added and also deletes a file.

* subversion/tests/cmdline/patch_tests.py
  (patch_add_and_delete): New test.

Modified:
    subversion/trunk/subversion/tests/cmdline/patch_tests.py

Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1231944&r1=1231943&r2=1231944&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Mon Jan 16 
11:39:32 2012
@@ -4045,6 +4045,60 @@ def patch_target_no_eol_at_eof(sbox):
                                        1, # check-props
                                        1) # dry-run
 
+@XFail()
+def patch_add_and_delete(sbox):
+  "patch add multiple levels and delete"
+
+  sbox.build(read_only = True)
+  wc_dir = sbox.wc_dir
+  patch_file_path = make_patch_path(sbox)
+
+  unidiff_patch = [
+    "Index: foo\n",
+    "===================================================================\n",
+    "--- P/Q/foo\t(revision 0)\n"
+    "+++ P/Q/foo\t(working copy)\n"
+    "@@ -0,0 +1 @@\n",
+    "+This is the file 'foo'.\n",
+    "Index: iota\n"
+    "===================================================================\n",
+    "--- iota\t(revision 1)\n"
+    "+++ iota\t(working copy)\n"
+    "@@ -1 +0,0 @@\n",
+    "-This is the file 'iota'.\n",
+    ]
+
+  svntest.main.file_write(patch_file_path, ''.join(unidiff_patch))
+
+  expected_output = [
+    'A         %s\n' % os.path.join(wc_dir, 'P'),
+    'A         %s\n' % os.path.join(wc_dir, 'P', 'Q'),
+    'A         %s\n' % os.path.join(wc_dir, 'P', 'Q', 'foo'),
+    'D         %s\n' % os.path.join(wc_dir, 'iota'),
+  ]
+  expected_disk = svntest.main.greek_state.copy()
+  expected_disk.remove('iota')
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_disk.add({'P/Q/foo' : Item(contents="This is the file 'foo'.\n")})
+  expected_status.tweak('iota', status='D ')
+  expected_status.add({
+      'P'       : Item(status='A ', wc_rev=0),
+      'P/Q'     : Item(status='A ', wc_rev=0),
+      'P/Q/foo' : Item(status='A ', wc_rev=0),
+      })
+  expected_skip = wc.State('', { })
+
+  # Failed with "The node 'P' was not found" when erroneously checking
+  # whether 'P/Q' should be deleted.
+  svntest.actions.run_and_verify_patch(wc_dir, 
os.path.abspath(patch_file_path),
+                                       expected_output,
+                                       expected_disk,
+                                       expected_status,
+                                       expected_skip,
+                                       None, # expected err
+                                       1, # check-props
+                                       1) # dry-run
+
 ########################################################################
 #Run the tests
 
@@ -4088,6 +4142,7 @@ test_list = [ None,
               patch_dev_null,
               patch_delete_and_skip,
               patch_target_no_eol_at_eof,
+              patch_add_and_delete,
             ]
 
 if __name__ == '__main__':


Reply via email to