You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2011/04/20 23:59:37 UTC

svn commit: r1095534 - in /subversion/trunk/subversion: libsvn_wc/upgrade.c tests/cmdline/upgrade_tests.py

Author: rhuijben
Date: Wed Apr 20 21:59:37 2011
New Revision: 1095534

URL: http://svn.apache.org/viewvc?rev=1095534&view=rev
Log:
Fix issue #3808 'svn upgrade' doesn't remove directories scheduled for deletion

* subversion/libsvn_wc/upgrade.c
  (get_versioned_subdirs): Add delete_dir argument and grab its value from the
     entries we just read.
  (svn_wc__wipe_postupgrade): Pass delete_dir boolean and try to delete the
     directory if the entries indicate that it should be deleted.
     Add svn_error_return.

* subversion/tests/cmdline/upgrade_tests.py
  (delete_and_keep_local): Remove XFail marker.

Modified:
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/tests/cmdline/upgrade_tests.py

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1095534&r1=1095533&r2=1095534&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Wed Apr 20 21:59:37 2011
@@ -288,9 +288,13 @@ maybe_add_subdir(apr_array_header_t *sub
 
 
 /* Return in CHILDREN, the list of all 1.6 versioned subdirectories
-   which also exist on disk as directories.  */
+   which also exist on disk as directories.
+
+   If DELETE_DIR is not NULL set *DELETE_DIR to TRUE if the directory
+   should be deleted after migrating to WC-NG, otherwise to FALSE. */
 static svn_error_t *
 get_versioned_subdirs(apr_array_header_t **children,
+                      svn_boolean_t *delete_dir,
                       const char *dir_abspath,
                       apr_pool_t *result_pool,
                       apr_pool_t *scratch_pool)
@@ -298,6 +302,7 @@ get_versioned_subdirs(apr_array_header_t
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   apr_hash_t *entries;
   apr_hash_index_t *hi;
+  svn_wc_entry_t *this_dir = NULL;
 
   *children = apr_array_make(result_pool, 10, sizeof(const char *));
 
@@ -311,7 +316,10 @@ get_versioned_subdirs(apr_array_header_t
 
       /* skip "this dir"  */
       if (*name == '\0')
-        continue;
+        {
+          this_dir = svn__apr_hash_index_val(hi);
+          continue;
+        }
 
       svn_pool_clear(iterpool);
 
@@ -321,6 +329,13 @@ get_versioned_subdirs(apr_array_header_t
 
   svn_pool_destroy(iterpool);
 
+  if (delete_dir != NULL)
+    {
+      *delete_dir = (this_dir != NULL)
+                     && (this_dir->schedule == svn_wc_schedule_delete)
+                     && ! this_dir->keep_local;
+    }
+
   return SVN_NO_ERROR;
 }
 
@@ -512,12 +527,14 @@ svn_wc__wipe_postupgrade(const char *dir
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   apr_array_header_t *subdirs;
   svn_error_t *err;
+  svn_boolean_t delete_dir;
   int i;
 
   if (cancel_func)
     SVN_ERR((*cancel_func)(cancel_baton));
 
-  err = get_versioned_subdirs(&subdirs, dir_abspath, scratch_pool, iterpool);
+  err = get_versioned_subdirs(&subdirs, &delete_dir, dir_abspath,
+                              scratch_pool, iterpool);
   if (err)
     {
       if (APR_STATUS_IS_ENOENT(err->apr_err))
@@ -527,7 +544,7 @@ svn_wc__wipe_postupgrade(const char *dir
           err = NULL;
         }
       svn_pool_destroy(iterpool);
-      return err;
+      return svn_error_return(err);
     }
   for (i = 0; i < subdirs->nelts; ++i)
     {
@@ -546,6 +563,17 @@ svn_wc__wipe_postupgrade(const char *dir
   else
     wipe_obsolete_files(dir_abspath, scratch_pool);
 
+  if (delete_dir)
+    {
+      /* If this was a WC-NG single database copy, this directory wouldn't
+         be here (unless it was deleted with --keep-local)
+
+         If the directory is empty, we can just delete it; if not we
+         keep it.
+       */
+      svn_error_clear(svn_io_dir_remove_nonrecursive(dir_abspath, iterpool));
+    }
+
   svn_pool_destroy(iterpool);
 
   return SVN_NO_ERROR;
@@ -1539,7 +1567,8 @@ upgrade_working_copy(void *parent_baton,
       return SVN_NO_ERROR;
     }
 
-  err = get_versioned_subdirs(&subdirs, dir_abspath, scratch_pool, iterpool);
+  err = get_versioned_subdirs(&subdirs, NULL, dir_abspath,
+                              scratch_pool, iterpool);
   if (err)
     {
       if (APR_STATUS_IS_ENOENT(err->apr_err))

Modified: subversion/trunk/subversion/tests/cmdline/upgrade_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/upgrade_tests.py?rev=1095534&r1=1095533&r2=1095534&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/upgrade_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/upgrade_tests.py Wed Apr 20 21:59:37 2011
@@ -644,7 +644,6 @@ def missing_dirs2(sbox):
     })
   run_and_verify_status_no_server(sbox.wc_dir, expected_status)
 
-@XFail()
 @Issue(3808)
 def delete_and_keep_local(sbox):
   "check status delete and delete --keep-local"