subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1464992 - /subversion/trunk/subversion/libsvn_client/delete.c
Date Fri, 05 Apr 2013 14:40:27 GMT
Author: stsp
Date: Fri Apr  5 14:40:27 2013
New Revision: 1464992

URL: http://svn.apache.org/r1464992
Log:
Don't allow externals to be deleted with 'svn rm' under any circumstances.

File externals could be deleted with the --force or --keep-local options.

Found by: Florin <support@syncrosvnclient.com>

* subversion/libsvn_client/delete.c
  (check_external): New helper function which raises an error if the path
   about to be deleted is an external. Split out of ...
  (can_delete_node): ... this function, which isn't called in case the
   --force or --kee-local options are used.
  (svn_client__wc_delete, svn_client__wc_delete_many): Unconditionally call
   the check_external() helper function before calling can_delete_node().

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

Modified: subversion/trunk/subversion/libsvn_client/delete.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/delete.c?rev=1464992&r1=1464991&r2=1464992&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/delete.c (original)
+++ subversion/trunk/subversion/libsvn_client/delete.c Fri Apr  5 14:40:27 2013
@@ -99,26 +99,23 @@ find_undeletables(void *baton,
   return SVN_NO_ERROR;
 }
 
-/* Verify that the path can be deleted without losing stuff,
-   i.e. ensure that there are no modified or unversioned resources
-   under PATH.  This is similar to checking the output of the status
-   command.  CTX is used for the client's config options.  POOL is
-   used for all temporary allocations. */
+/* Check whether LOCAL_ABSPATH is an external and raise an error if it is.
+  
+   A file external should not be deleted since the file external is
+   implemented as a switched file and it would delete the file the
+   file external is switched to, which is not the behavior the user
+   would probably want.
+   
+   A directory external should not be deleted since it is the root
+   of a different working copy. */
 static svn_error_t *
-can_delete_node(svn_boolean_t *target_missing,
-                const char *local_abspath,
-                svn_client_ctx_t *ctx,
-                apr_pool_t *scratch_pool)
+check_external(const char *local_abspath,
+               svn_client_ctx_t *ctx,
+               apr_pool_t *scratch_pool)
 {
   svn_node_kind_t external_kind;
   const char *defining_abspath;
-  apr_array_header_t *ignores;
-  struct can_delete_baton_t cdt;
 
-  /* A file external should not be deleted since the file external is
-     implemented as a switched file and it would delete the file the
-     file external is switched to, which is not the behavior the user
-     would probably want. */
   SVN_ERR(svn_wc__read_external_info(&external_kind, &defining_abspath, NULL,
                                      NULL, NULL,
                                      ctx->wc_ctx, local_abspath,
@@ -135,6 +132,22 @@ can_delete_node(svn_boolean_t *target_mi
                              svn_dirent_local_style(defining_abspath,
                                                     scratch_pool));
 
+  return SVN_NO_ERROR;
+}
+
+/* Verify that the path can be deleted without losing stuff,
+   i.e. ensure that there are no modified or unversioned resources
+   under PATH.  This is similar to checking the output of the status
+   command.  CTX is used for the client's config options.  POOL is
+   used for all temporary allocations. */
+static svn_error_t *
+can_delete_node(svn_boolean_t *target_missing,
+                const char *local_abspath,
+                svn_client_ctx_t *ctx,
+                apr_pool_t *scratch_pool)
+{
+  apr_array_header_t *ignores;
+  struct can_delete_baton_t cdt;
 
   /* Use an infinite-depth status check to see if there's anything in
      or under PATH which would make it unsafe for deletion.  The
@@ -409,6 +422,8 @@ svn_client__wc_delete(const char *local_
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
+  SVN_ERR(check_external(local_abspath, ctx, pool));
+
   if (!force && !keep_local)
     /* Verify that there are no "awkward" files */
     SVN_ERR(can_delete_node(&target_missing, local_abspath, ctx, pool));
@@ -444,6 +459,8 @@ svn_client__wc_delete_many(const apr_arr
 
       SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
+      SVN_ERR(check_external(local_abspath, ctx, pool));
+
       if (!force && !keep_local)
         {
           svn_boolean_t missing;



Mime
View raw message