Author: rhuijben
Date: Fri May 27 14:43:43 2011
New Revision: 1128328

URL: http://svn.apache.org/viewvc?rev=1128328&view=rev
Log:
Move the removal of externals into libsvn_wc. This defines a proper api for
this specific task instead of using the big cannon called
svn_wc_remove_from_revision_control2().

* subversion/include/private/svn_wc_private.h
  (svn_wc__external_remove): New function.

* subversion/libsvn_client/externals.c
  (relegate_dir_external): Update caller. Pass wri_abspath.
  (handle_external_item_removal): Update caller.
  (svn_client__handle_externals): Update caller.

* subversion/libsvn_wc/externals.c
  (svn_wc__external_remove): New function.

* subversion/libsvn_wc/wc_db.c
  (db_external_remove): Remove version check. Add work items.
  (svn_wc__db_external_remove): Always call db_external_remove.
    Pass work items.

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/externals.c
    subversion/trunk/subversion/libsvn_wc/externals.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/include/private/svn_wc_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_wc_private.h?rev=1128328&r1=1128327&r2=1128328&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Fri May 27 
14:43:43 2011
@@ -168,6 +168,22 @@ svn_wc__external_register(svn_wc_context
                           svn_revnum_t revision,
                           apr_pool_t *scratch_pool);
 
+/* Remove the external at LOCAL_ABSPATH from the working copy identified by
+   WRI_ABSPATH using WC_CTX.
+
+   If not NULL, call CANCEL_FUNC with CANCEL_BATON to allow canceling while
+   removing the working copy files.
+
+   ### This function wraps svn_wc_remove_from_version_control2.
+ */
+svn_error_t *
+svn_wc__external_remove(svn_wc_context_t *wc_ctx,
+                        const char *wri_abspath,
+                        const char *local_abspath,
+                        svn_cancel_func_t cancel_func,
+                        void *cancel_baton,
+                        apr_pool_t *scratch_pool);
+
 
 /** Set @a *tree_conflict to a newly allocated @c
  * svn_wc_conflict_description_t structure describing the tree

Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=1128328&r1=1128327&r2=1128328&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Fri May 27 14:43:43 
2011
@@ -72,6 +72,7 @@ struct external_change_baton_t
  */
 static svn_error_t *
 relegate_dir_external(svn_wc_context_t *wc_ctx,
+                      const char *wri_abspath,
                       const char *local_abspath,
                       svn_cancel_func_t cancel_func,
                       void *cancel_baton,
@@ -79,10 +80,8 @@ relegate_dir_external(svn_wc_context_t *
 {
   svn_error_t *err = SVN_NO_ERROR;
 
-  err = svn_wc_remove_from_revision_control2(wc_ctx, local_abspath,
-                                             TRUE, FALSE,
-                                             cancel_func, cancel_baton,
-                                             scratch_pool);
+  err = svn_wc__external_remove(wc_ctx, wri_abspath, local_abspath,
+                                cancel_func, cancel_baton, scratch_pool);
   if (err && (err->apr_err == SVN_ERR_WC_LEFT_LOCAL_MOD))
     {
       const char *parent_dir;
@@ -274,7 +273,8 @@ switch_dir_external(const char *local_ab
       SVN_ERR(svn_wc__acquire_write_lock(NULL, ctx->wc_ctx, local_abspath,
                                          FALSE, pool, pool));
 
-      SVN_ERR(relegate_dir_external(ctx->wc_ctx, local_abspath,
+      SVN_ERR(relegate_dir_external(ctx->wc_ctx, defining_abspath,
+                                    local_abspath,
                                     ctx->cancel_func, ctx->cancel_baton,
                                     pool));
     }
@@ -747,6 +747,7 @@ resolve_relative_external_url(const char
 
 static svn_error_t *
 handle_external_item_removal(const struct external_change_baton_t *eb,
+                             const char *wri_abspath,
                              const char *local_abspath,
                              const char *old_url,
                              apr_pool_t *scratch_pool)
@@ -782,10 +783,9 @@ handle_external_item_removal(const struc
      nothing else in this externals description (at least) is
      going to need this directory, and therefore it's better to
      leave stuff where the user expects it. */
-  err = svn_wc_remove_from_revision_control2(
-                    eb->ctx->wc_ctx, local_abspath, TRUE, FALSE,
-                    eb->ctx->cancel_func, eb->ctx->cancel_baton,
-                    scratch_pool);
+  err = svn_wc__external_remove(eb->ctx->wc_ctx, wri_abspath, local_abspath,
+                                eb->ctx->cancel_func, eb->ctx->cancel_baton,
+                                scratch_pool);
 
   if (eb->ctx->notify_func2)
     {
@@ -1317,7 +1317,8 @@ svn_client__handle_externals(apr_hash_t 
 
       SVN_ERR(wrap_external_error(
                           &eb, item_abspath,
-                          handle_external_item_removal(&eb, item_abspath,
+                          handle_external_item_removal(&eb, target_abspath,
+                                                       item_abspath,
                                                        old_url, iterpool),
                           iterpool));
     }

Modified: subversion/trunk/subversion/libsvn_wc/externals.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/externals.c?rev=1128328&r1=1128327&r2=1128328&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/externals.c (original)
+++ subversion/trunk/subversion/libsvn_wc/externals.c Fri May 27 14:43:43 2011
@@ -1187,3 +1187,41 @@ svn_wc__external_register(svn_wc_context
   return SVN_NO_ERROR;
 #endif
 }
+
+svn_error_t *
+svn_wc__external_remove(svn_wc_context_t *wc_ctx,
+                        const char *wri_abspath,
+                        const char *local_abspath,
+                        svn_cancel_func_t cancel_func,
+                        void *cancel_baton,
+                        apr_pool_t *scratch_pool)
+{
+  svn_wc__db_status_t status;
+  svn_wc__db_kind_t kind;
+
+  SVN_ERR(svn_wc__db_external_read(&status, &kind, NULL, NULL, NULL, NULL,
+                                   NULL, NULL,
+                                   wc_ctx->db, local_abspath, wri_abspath,
+                                   scratch_pool, scratch_pool));
+
+#if SVN_WC__VERSION >= SVN_WC__HAS_EXTERNALS_STORE
+  SVN_ERR(svn_wc__db_external_remove(wc_ctx->db, local_abspath, wri_abspath,
+                                     NULL, scratch_pool));
+#endif
+
+  if (kind == svn_wc__db_kind_dir)
+    SVN_ERR(svn_wc_remove_from_revision_control2(wc_ctx, local_abspath,
+                                                 TRUE, FALSE,
+                                                 cancel_func, cancel_baton,
+                                                 scratch_pool));
+  else
+    {
+#if SVN_WC__VERSION < SVN_WC__HAS_EXTERNALS_STORE
+      SVN_ERR(svn_wc__db_base_remove(wc_ctx->db, local_abspath, scratch_pool));
+#endif
+      SVN_ERR(svn_io_remove_file2(local_abspath, TRUE, scratch_pool));
+    }
+
+  return SVN_NO_ERROR;
+}
+

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1128328&r1=1128327&r2=1128328&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri May 27 14:43:43 2011
@@ -2963,7 +2963,6 @@ svn_wc__db_external_add_dir(svn_wc__db_t
                                 &ieb, scratch_pool));
 }
 
-#if SVN_WC__VERSION >= SVN_WC__HAS_EXTERNALS_STORE
 static svn_error_t *
 db_external_remove(void *baton, svn_wc__db_wcroot_t *wcroot,
                    const char *local_relpath, apr_pool_t *scratch_pool)
@@ -2975,10 +2974,11 @@ db_external_remove(void *baton, svn_wc__
   SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
   SVN_ERR(svn_sqlite__step_done(stmt));
 
+  SVN_ERR(add_work_items(wcroot->sdb, baton, scratch_pool));
+
   /* ### What about actual? */
   return SVN_NO_ERROR;
 }
-#endif
 
 svn_error_t *
 svn_wc__db_external_remove(svn_wc__db_t *db,
@@ -3003,17 +3003,10 @@ svn_wc__db_external_remove(svn_wc__db_t 
 
   local_relpath = svn_dirent_skip_ancestor(wcroot->abspath, local_abspath);
 
-#if SVN_WC__VERSION < SVN_WC__HAS_EXTERNALS_STORE
-  SVN_ERR(svn_wc__db_with_txn(wcroot, local_relpath, db_base_remove, NULL,
-                              scratch_pool));
-
-  return SVN_NO_ERROR;
-#else
-  SVN_ERR(svn_wc__db_with_txn(wcroot, local_relpath, db_external_remove, NULL,
-                              scratch_pool));
+  SVN_ERR(svn_wc__db_with_txn(wcroot, local_relpath, db_external_remove,
+                              work_items, scratch_pool));
 
   return SVN_NO_ERROR;
-#endif
 }
 
 svn_error_t *
@@ -3068,10 +3061,15 @@ svn_wc__db_external_read(svn_wc__db_stat
         || base_status != svn_wc__db_status_normal
         || base_kind == svn_wc__db_kind_dir)
       {
-        return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
-                                 _("The node '%s' is not an external"),
-                                 svn_dirent_local_style(local_abspath,
-                                                        scratch_pool));
+        svn_boolean_t is_root;
+        SVN_ERR(svn_wc__db_is_wcroot(&is_root, db, local_abspath,
+                                     scratch_pool));
+
+        if (!is_root)
+          return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                                   _("The node '%s' is not an external"),
+                                   svn_dirent_local_style(local_abspath,
+                                                          scratch_pool));
       }
 
     if (status)


Reply via email to