You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2015/01/06 22:05:57 UTC

svn commit: r1649951 - in /subversion/trunk/subversion: libsvn_client/add.c tests/cmdline/basic_tests.py

Author: julianfoad
Date: Tue Jan  6 21:05:56 2015
New Revision: 1649951

URL: http://svn.apache.org/r1649951
Log:
Fix a bug in 'svn mkdir --parents' whereby if the target directory already
existed on disk it was adding its entire contents recursively.

This reverts a change of depth empty to depth infinity made in r871175.

* subversion/libsvn_client/add.c
  (svn_client__make_local_parents): Only add the directory we created (depth empty).

* subversion/tests/cmdline/basic_tests.py
  (mkdir_parents_target_exists_on_disk): New test.
  (test_list): Run it.

Modified:
    subversion/trunk/subversion/libsvn_client/add.c
    subversion/trunk/subversion/tests/cmdline/basic_tests.py

Modified: subversion/trunk/subversion/libsvn_client/add.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/add.c?rev=1649951&r1=1649950&r2=1649951&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/add.c (original)
+++ subversion/trunk/subversion/libsvn_client/add.c Tue Jan  6 21:05:56 2015
@@ -1270,11 +1270,7 @@ svn_client__make_local_parents(const cha
   else
     SVN_ERR(svn_io_dir_make(local_abspath, APR_OS_DEFAULT, scratch_pool));
 
-  /* Should no longer use svn_depth_empty to indicate that only the directory
-     itself is added, since it not only constraints the operation depth, but
-     also defines the depth of the target directory now. Moreover, the new
-     directory will have no children at all.*/
-  err = svn_client_add5(local_abspath, svn_depth_infinity, FALSE, FALSE, FALSE,
+  err = svn_client_add5(local_abspath, svn_depth_empty, FALSE, FALSE, FALSE,
                         make_parents, ctx, scratch_pool);
 
   /* If we created a new directory, but couldn't add it to version

Modified: subversion/trunk/subversion/tests/cmdline/basic_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/basic_tests.py?rev=1649951&r1=1649950&r2=1649951&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/basic_tests.py Tue Jan  6 21:05:56 2015
@@ -3146,6 +3146,31 @@ def basic_youngest(sbox):
                                            'youngest', path)
 
 
+# With 'svn mkdir --parents' the target directory may already exist on disk.
+# In that case it was wrongly performing a recursive 'add' on its contents.
+def mkdir_parents_target_exists_on_disk(sbox):
+  "mkdir parents target exists on disk"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  Y_path = sbox.ospath('Y')
+  Y_Z_path = sbox.ospath('Y/Z')
+
+  os.mkdir(Y_path)
+  os.mkdir(Y_Z_path)
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'mkdir', '--parents', Y_path)
+
+  # Y should be added, and Z should not. There was a regression in which Z
+  # was also added.
+  expected_status = svntest.actions.get_virginal_state(sbox.wc_dir, 1)
+  expected_status.add({
+    'Y'      : Item(status='A ', wc_rev=0),
+    })
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+
 ########################################################################
 # Run the tests
 
@@ -3215,6 +3240,7 @@ test_list = [ None,
               delete_conflicts_one_of_many,
               peg_rev_on_non_existent_wc_path,
               basic_youngest,
+              mkdir_parents_target_exists_on_disk,
              ]
 
 if __name__ == '__main__':