Author: dannas
Date: Tue Aug  3 16:36:43 2010
New Revision: 981960

URL: http://svn.apache.org/viewvc?rev=981960&view=rev
Log:
Make 'svn patch' always skip targets if the parent dir is scheduled for
deletion.

* subversion/tests/cmdline/patch_tests.py
  (patch_add_new_dir): Adjust expected values that were sloppily set.
  (test_list): Remove XFail marker for patch_add_new_dir().

* subversion/libsvn_client/patch.c
  (create_missing_parents,
   install_patched_target): Mark the target to be skipped if a parent dir
    is scheduled for deletion.

Modified:
    subversion/trunk/subversion/libsvn_client/patch.c
    subversion/trunk/subversion/tests/cmdline/patch_tests.py

Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=981960&r1=981959&r2=981960&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Tue Aug  3 16:36:43 2010
@@ -1950,7 +1950,10 @@ create_missing_parents(patch_target_t *t
       else if (wc_kind == svn_node_dir)
         {
           if (is_deleted)
-            break;
+            {
+              target->skipped = TRUE;
+              break;
+            }
 
           /* continue one level deeper */
           present_components++;
@@ -2072,7 +2075,25 @@ install_patched_target(patch_target_t *t
                                    svn_dirent_dirname(target->local_abspath,
                                                       pool),
                                    FALSE, pool));
-          if (parent_db_kind != svn_node_dir)
+
+          /* We don't allow targets to be added under dirs scheduled for
+           * deletion. */
+          if (parent_db_kind == svn_node_dir)
+            {
+              const char *parent_abspath;
+              svn_boolean_t is_deleted;
+              
+              parent_abspath = svn_dirent_dirname(target->local_abspath,
+                                                  pool);
+              SVN_ERR(svn_wc__node_is_status_deleted(&is_deleted, ctx->wc_ctx,
+                                                     parent_abspath, pool));
+              if (is_deleted)
+                {
+                  target->skipped = TRUE;
+                  return SVN_NO_ERROR;
+                }
+            }
+          else
             SVN_ERR(create_missing_parents(target, abs_wc_path, ctx,
                                            dry_run, pool));
         }

Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=981960&r1=981959&r2=981960&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Tue Aug  3 
16:36:43 2010
@@ -981,9 +981,9 @@ def patch_add_new_dir(sbox):
     'A         %s\n' % os.path.join(wc_dir, 'X'),
     'A         %s\n' % os.path.join(wc_dir, 'X', 'Y'),
     'A         %s\n' % os.path.join(wc_dir, 'X', 'Y', 'new'),
-    'Skipped missing target: \'%s\'\n' % A_Z_new_path,
     'Skipped missing target: \'%s\'\n' % A_B_E_Y_new_path,
     'Skipped missing target: \'%s\'\n' % A_C_new_path,
+    'Skipped missing target: \'%s\'\n' % A_Z_new_path,
     'Summary of conflicts:\n',
     '  Skipped paths: 3\n',
   ]
@@ -994,13 +994,20 @@ def patch_add_new_dir(sbox):
   expected_disk = svntest.main.greek_state.copy()
   expected_disk.add({
            'X/Y/new'   : Item(contents='new\n'),
+           'A/Z'       : Item()
   })
+  expected_disk.remove('A/B/E/alpha')
+  expected_disk.remove('A/B/E/beta')
 
   expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
            'X'         : Item(status='A ', wc_rev=0),
            'X/Y'       : Item(status='A ', wc_rev=0),
            'X/Y/new'   : Item(status='A ', wc_rev=0),
+           'A/B/E'     : Item(status='D ', wc_rev=1),
+           'A/B/E/alpha': Item(status='D ', wc_rev=1),
+           'A/B/E/beta': Item(status='D ', wc_rev=1),
+           'A/C'       : Item(status='D ', wc_rev=1),
   })
 
   expected_skip = wc.State('', {A_Z_new_path : Item(),
@@ -2976,7 +2983,7 @@ test_list = [ None,
               patch_chopped_leading_spaces,
               patch_strip1,
               patch_no_index_line,
-              XFail(patch_add_new_dir),
+              patch_add_new_dir,
               patch_remove_empty_dirs,
               patch_reject,
               patch_keywords,


Reply via email to