You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2009/12/21 18:48:06 UTC

svn commit: r892903 - /subversion/trunk/subversion/libsvn_client/externals.c

Author: philip
Date: Mon Dec 21 17:48:06 2009
New Revision: 892903

URL: http://svn.apache.org/viewvc?rev=892903&view=rev
Log:
Use recursive locking when deleting an external. No need to make a
distinction between files and dirs as the previous code did.

* subversion/libsvn_client/externals.c
  (handle_external_item_change): Remove the adm_access functions and use
    svn_wc_{acqurire,release}write_lock instead and svn_wc_locked2()
    instead.

Patch by: Daniel Näslund <daniel{_AT_}longitudo.com>
Review by: me

Modified:
    subversion/trunk/subversion/libsvn_client/externals.c

Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=892903&r1=892902&r2=892903&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Mon Dec 21 17:48:06 2009
@@ -894,51 +894,22 @@
          just be renamed to a new one. */
 
       svn_error_t *err;
-      svn_wc_adm_access_t *adm_access;
-      svn_boolean_t close_access_baton_when_done;
-
       const char *remove_target_abspath;
+      svn_boolean_t lock_existed; 
 
-      /* Determine if a directory or file external is being removed.
-         Try to handle the case when the user deletes the external by
-         hand or it is missing.  First try to open the directory for a
-         directory external.  If that doesn't work, get the access
-         baton for the parent directory and remove the entry for the
-         external. */
-      err = svn_wc__adm_open_in_context(&adm_access, ib->ctx->wc_ctx, path,
-                                        TRUE, -1, ib->ctx->cancel_func,
-                                        ib->ctx->cancel_baton, ib->iter_pool);
-      if (err)
-        {
-          const char *anchor;
-          const char *target;
-          svn_error_t *err2;
-
-          SVN_ERR(svn_wc_get_actual_target2(&anchor, &target, ib->ctx->wc_ctx,
-                                            path, ib->iter_pool,
-                                            ib->iter_pool));
+      SVN_ERR(svn_dirent_get_absolute(&remove_target_abspath,
+                                      path,
+                                      ib->iter_pool));
 
-          err2 = svn_wc_adm_retrieve(&adm_access, ib->adm_access, anchor,
-                                     ib->iter_pool);
-          if (err2)
-            {
-              svn_error_clear(err2);
-              return svn_error_return(err);
-            }
-          else
-            {
-              svn_error_clear(err);
-            }
-          close_access_baton_when_done = FALSE;
-          SVN_ERR(svn_dirent_get_absolute(&remove_target_abspath, target,
-                                          ib->iter_pool));
-        }
-      else
+      SVN_ERR(svn_wc_locked2(&lock_existed, NULL, ib->ctx->wc_ctx,
+                             remove_target_abspath, ib->iter_pool));
+
+      if (! lock_existed)
         {
-          close_access_baton_when_done = TRUE;
-          SVN_ERR(svn_dirent_get_absolute(&remove_target_abspath,
-                                          svn_wc_adm_access_path(adm_access),
-                                          ib->iter_pool));
+          SVN_ERR(svn_wc__acquire_write_lock(NULL, ib->ctx->wc_ctx,
+                                             remove_target_abspath, 
+                                             ib->iter_pool,
+                                             ib->iter_pool));
         }
 
       /* We don't use relegate_dir_external() here, because we know that
@@ -965,13 +936,15 @@
         }
 
       /* ### Ugly. Unlock only if not going to return an error. Revisit */
-      if (close_access_baton_when_done &&
-          (!err || err->apr_err == SVN_ERR_WC_LEFT_LOCAL_MOD))
+      if (! lock_existed
+          && (! err || err->apr_err == SVN_ERR_WC_LEFT_LOCAL_MOD))
         {
-          svn_error_t *err2 = svn_wc_adm_close2(adm_access, ib->iter_pool);
+          svn_error_t *err2 = svn_wc__release_write_lock(ib->ctx->wc_ctx, 
+                                                         remove_target_abspath,
+                                                         ib->iter_pool);
           if (err2)
             {
-              if (!err)
+              if (! err)
                 err = err2;
               else
                 svn_error_clear(err2);