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 2013/12/05 12:16:40 UTC

svn commit: r1548088 - in /subversion/trunk/subversion: include/svn_client.h libsvn_client/cleanup.c libsvn_client/deprecated.c svn/cleanup-cmd.c

Author: rhuijben
Date: Thu Dec  5 11:16:40 2013
New Revision: 1548088

URL: http://svn.apache.org/r1548088
Log:
Following up on r1548075, split the new in 1.9 svn_client_cleanup2() api into
two separate functions.

* subversion/include/svn_client.h
  (svn_client_vacuum): New function.
  (svn_client_cleanup2): Update prototype. Remove vacuum support.
  (svn_client_cleanup): Update documentation.

* subversion/libsvn_client/cleanup.c
  (cleanup_status_walk_baton): Add more flags.
  (do_cleanup): Rely on svn_wc_cleanup4() for locking check when not breaking
    locks. Pass and handle flags.
  (cleanup_status_walk): Update caller.

  (svn_client_cleanup2): Update api.
  (svn_client_vacuum): New function.

* subversion/libsvn_client/deprecated.c
  (svn_client_cleanup): Update caller.

* subversion/svn/cleanup-cmd.c
  (svn_cl__cleanup): Update caller. Choose the right function for the job.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/cleanup.c
    subversion/trunk/subversion/libsvn_client/deprecated.c
    subversion/trunk/subversion/svn/cleanup-cmd.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1548088&r1=1548087&r2=1548088&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Thu Dec  5 11:16:40 2013
@@ -4095,11 +4095,11 @@ svn_client_mergeinfo_log_eligible(const 
  * @{
  */
 
-/** Recursively cleanup a working copy directory @a dir, finishing any
- * incomplete operations, removing lockfiles, etc.
+/** Recursively vacuum a working copy directory @a dir, removing unnecessary
+ * data.
  *
- * If @a include_externals is @c TRUE, recurse into externals and clean
- * them up as well.
+ * If @a include_externals is @c TRUE, recurse into externals and vacuum them
+ * as well.
  *
  * If @a remove_unversioned_items is @c TRUE, remove unversioned items
  * in @a dir after successfull working copy cleanup.
@@ -4107,10 +4107,36 @@ svn_client_mergeinfo_log_eligible(const 
  * in @a dir after successfull working copy cleanup.
  *
  * When asked to remove unversioned or ignored items, and the working copy
- * is already locked via a different client or WC context than @a ctx, return
- * #SVN_ERR_WC_LOCKED. This prevents accidental working copy corruption in
- * case users run the cleanup operation to remove unversioned items while
- * another client is performing some other operation on the working copy.
+ * is already locked, return #SVN_ERR_WC_LOCKED. This prevents accidental
+ * working copy corruption in case users run the cleanup operation to
+ * remove unversioned items while another client is performing some other
+ * operation on the working copy.
+ *
+ * If @a ctx->cancel_func is non-NULL, invoke it with @a
+ * ctx->cancel_baton at various points during the operation.  If it
+ * returns an error (typically #SVN_ERR_CANCELLED), return that error
+ * immediately.
+ *
+ * Use @a scratch_pool for any temporary allocations.
+ *
+ * @since New in 1.9.
+ */
+svn_error_t *
+svn_client_vacuum(const char *dir_abspath,
+                  svn_boolean_t remove_unversioned_items,
+                  svn_boolean_t remove_ignored_items,
+                  svn_boolean_t fix_recorded_timestamps,
+                  svn_boolean_t vacuum_pristines,
+                  svn_boolean_t include_externals,
+                  svn_client_ctx_t *ctx,
+                  apr_pool_t *scratch_pool);
+
+
+/** Recursively cleanup a working copy directory @a dir, finishing any
+ * incomplete operations, removing lockfiles, etc.
+ *
+ * If @a include_externals is @c TRUE, recurse into externals and clean
+ * them up as well.
  *
  * If @a ctx->cancel_func is non-NULL, invoke it with @a
  * ctx->cancel_baton at various points during the operation.  If it
@@ -4122,15 +4148,17 @@ svn_client_mergeinfo_log_eligible(const 
  * @since New in 1.9.
  */
 svn_error_t *
-svn_client_cleanup2(const char *dir,
+svn_client_cleanup2(const char *dir_abspath,
+                    svn_boolean_t break_locks,
+                    svn_boolean_t fix_recorded_timestamps,
+                    svn_boolean_t clear_dav_cache,
+                    svn_boolean_t vacuum_pristines,
                     svn_boolean_t include_externals,
-                    svn_boolean_t remove_unversioned_items,
-                    svn_boolean_t remove_ignored_items,
                     svn_client_ctx_t *ctx,
                     apr_pool_t *scratch_pool);
 
-/* Like svn_client_cleanup2(), but no support for removing unversioned items
- * and cleaning up externals.
+/* Like svn_client_cleanup2(), but no support for not breaking locks and
+ * cleaning up externals and using a potentially non absolute path.
  *
  * @deprecated Provided for limited backwards compatibility with the 1.8 API.
  */

Modified: subversion/trunk/subversion/libsvn_client/cleanup.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/cleanup.c?rev=1548088&r1=1548087&r2=1548088&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/cleanup.c (original)
+++ subversion/trunk/subversion/libsvn_client/cleanup.c Thu Dec  5 11:16:40 2013
@@ -46,9 +46,13 @@
 
 struct cleanup_status_walk_baton
 {
-  svn_boolean_t include_externals;
+  svn_boolean_t break_locks;
+  svn_boolean_t fix_timestamps;
+  svn_boolean_t clear_dav_cache;
+  svn_boolean_t vacuum_pristines;
   svn_boolean_t remove_unversioned_items;
   svn_boolean_t remove_ignored_items;
+  svn_boolean_t include_externals;
   svn_client_ctx_t *ctx;
 };
 
@@ -61,41 +65,38 @@ cleanup_status_walk(void *baton,
 
 static svn_error_t *
 do_cleanup(const char *local_abspath,
-           svn_boolean_t include_externals,
+           svn_boolean_t break_locks,
+           svn_boolean_t fix_timestamps,
+           svn_boolean_t clear_dav_cache,
+           svn_boolean_t vacuum_pristines,
            svn_boolean_t remove_unversioned_items,
            svn_boolean_t remove_ignored_items,
+           svn_boolean_t include_externals,
            svn_client_ctx_t *ctx,
            apr_pool_t *scratch_pool)
 {
-  svn_error_t *err;
+  SVN_ERR(svn_wc_cleanup4(ctx->wc_ctx,
+                          local_abspath,
+                          break_locks,
+                          fix_timestamps,
+                          clear_dav_cache,
+                          vacuum_pristines,
+                          ctx->cancel_func, ctx->cancel_baton,
+                          scratch_pool));
 
-  if (remove_unversioned_items || remove_ignored_items)
-    {
-      svn_boolean_t is_locked_here;
-      svn_boolean_t is_locked;
-
-      /* Check if someone else owns a lock for LOCAL_ABSPATH. */
-      SVN_ERR(svn_wc_locked2(&is_locked_here, &is_locked, ctx->wc_ctx,
-                             local_abspath, scratch_pool));
-      if (is_locked && !is_locked_here)
-        return svn_error_createf(SVN_ERR_WC_LOCKED, NULL,
-                                 _("Working copy at '%s' is already locked."),
-                                 svn_dirent_local_style(local_abspath,
-                                                        scratch_pool));
-    }
-
-  err = svn_wc_cleanup3(ctx->wc_ctx, local_abspath, ctx->cancel_func,
-                        ctx->cancel_baton, scratch_pool);
-  svn_io_sleep_for_timestamps(local_abspath, scratch_pool);
-  if (err)
-    return svn_error_trace(err);
+  if (fix_timestamps)
+    svn_io_sleep_for_timestamps(local_abspath, scratch_pool);
 
+  /* ### TODO: We should obtain a wc lock around the following block */
   if (remove_unversioned_items || remove_ignored_items || include_externals)
     {
       struct cleanup_status_walk_baton b;
       apr_array_header_t *ignores;
 
-      b.include_externals = include_externals;
+      b.break_locks = break_locks;
+      b.fix_timestamps = fix_timestamps;
+      b.clear_dav_cache = clear_dav_cache;
+      b.vacuum_pristines = vacuum_pristines;
       b.remove_unversioned_items = remove_unversioned_items;
       b.remove_ignored_items = remove_ignored_items;
       b.include_externals = include_externals;
@@ -145,10 +146,15 @@ cleanup_status_walk(void *baton,
                                       scratch_pool);
             }
 
-          err = do_cleanup(local_abspath, b->include_externals,
-                            b->remove_unversioned_items,
-                            b->remove_ignored_items,
-                            b->ctx, scratch_pool);
+          err = do_cleanup(local_abspath,
+                           b->break_locks,
+                           b->fix_timestamps,
+                           b->clear_dav_cache,
+                           b->vacuum_pristines,
+                           b->remove_unversioned_items,
+                           b->remove_ignored_items,
+                           TRUE /* include_externals */,
+                           b->ctx, scratch_pool);
           if (err && err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)
             {
               svn_error_clear(err);
@@ -203,22 +209,50 @@ cleanup_status_walk(void *baton,
 }
 
 svn_error_t *
-svn_client_cleanup2(const char *path,
+svn_client_cleanup2(const char *dir_abspath,
+                    svn_boolean_t break_locks,
+                    svn_boolean_t fix_recorded_timestamps,
+                    svn_boolean_t clear_dav_cache,
+                    svn_boolean_t vacuum_pristines,
                     svn_boolean_t include_externals,
-                    svn_boolean_t remove_unversioned_items,
-                    svn_boolean_t remove_ignored_items,
                     svn_client_ctx_t *ctx,
                     apr_pool_t *scratch_pool)
 {
-  const char *local_abspath;
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(dir_abspath));
+
+  SVN_ERR(do_cleanup(dir_abspath,
+                     break_locks,
+                     fix_recorded_timestamps,
+                     clear_dav_cache,
+                     vacuum_pristines,
+                     FALSE /* remove_unversioned_items */,
+                     FALSE /* remove_ignored_items */,
+                     include_externals,
+                     ctx, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_client_vacuum(const char *dir_abspath,
+                  svn_boolean_t remove_unversioned_items,
+                  svn_boolean_t remove_ignored_items,
+                  svn_boolean_t fix_recorded_timestamps,
+                  svn_boolean_t vacuum_pristines,
+                  svn_boolean_t include_externals,
+                  svn_client_ctx_t *ctx,
+                  apr_pool_t *scratch_pool)
+{
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(dir_abspath));
 
-  if (svn_path_is_url(path))
-    return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
-                             _("'%s' is not a local path"), path);
-
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, scratch_pool));
-  SVN_ERR(do_cleanup(local_abspath, include_externals,
-                     remove_unversioned_items, remove_ignored_items,
+  SVN_ERR(do_cleanup(dir_abspath,
+                     FALSE /* break_locks */,
+                     fix_recorded_timestamps,
+                     FALSE /* clear_dav_cache */,
+                     vacuum_pristines,
+                     remove_unversioned_items,
+                     remove_ignored_items,
+                     include_externals,
                      ctx, scratch_pool));
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_client/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/deprecated.c?rev=1548088&r1=1548087&r2=1548088&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_client/deprecated.c Thu Dec  5 11:16:40 2013
@@ -3006,6 +3006,19 @@ svn_client_cleanup(const char *path,
                    svn_client_ctx_t *ctx,
                    apr_pool_t *scratch_pool)
 {
-  return svn_error_trace(svn_client_cleanup2(path, FALSE, FALSE, FALSE, ctx,
-                                             scratch_pool));
+  const char *local_abspath;
+
+  if (svn_path_is_url(path))
+    return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                             _("'%s' is not a local path"), path);
+
+  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, scratch_pool));
+
+  return svn_error_trace(svn_client_cleanup2(local_abspath,
+                                             TRUE /* break_locks */,
+                                             TRUE /* fix_recorded_timestamps */,
+                                             TRUE /* clear_dav_cache */,
+                                             TRUE /* vacuum_pristines */,
+                                             FALSE /* include_externals */,
+                                             ctx, scratch_pool));
 }

Modified: subversion/trunk/subversion/svn/cleanup-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cleanup-cmd.c?rev=1548088&r1=1548087&r2=1548088&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cleanup-cmd.c (original)
+++ subversion/trunk/subversion/svn/cleanup-cmd.c Thu Dec  5 11:16:40 2013
@@ -47,7 +47,7 @@ svn_cl__cleanup(apr_getopt_t *os,
   svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_array_header_t *targets;
-  apr_pool_t *subpool;
+  apr_pool_t *iterpool;
   int i;
 
   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
@@ -61,43 +61,58 @@ svn_cl__cleanup(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
 
-  subpool = svn_pool_create(pool);
+  iterpool = svn_pool_create(pool);
   for (i = 0; i < targets->nelts; i++)
     {
       const char *target = APR_ARRAY_IDX(targets, i, const char *);
-      svn_error_t *err;
+      const char *target_abspath;
 
-      svn_pool_clear(subpool);
+      svn_pool_clear(iterpool);
       SVN_ERR(svn_cl__check_cancel(ctx->cancel_baton));
-      err = svn_client_cleanup2(target, opt_state->include_externals,
-                                opt_state->remove_unversioned,
-                                opt_state->remove_ignored,
-                                ctx, subpool);
-      if (err && err->apr_err == SVN_ERR_WC_LOCKED)
+
+      SVN_ERR(svn_dirent_get_absolute(&target_abspath, target, iterpool));
+
+      if (opt_state->remove_unversioned || opt_state->remove_ignored)
         {
-          const char *target_abspath;
-          svn_error_t *err2 = svn_dirent_get_absolute(&target_abspath,
-                                                      target, subpool);
-          if (err2)
-            {
-              err =  svn_error_compose_create(err, err2);
-            }
-          else if (opt_state->remove_unversioned || opt_state->remove_ignored)
-            {
-              err = svn_error_create(SVN_ERR_WC_LOCKED, err,
+          svn_error_t *err = svn_client_vacuum(target_abspath,
+                                               opt_state->remove_unversioned,
+                                               opt_state->remove_ignored,
+                                               TRUE /* fix_timestamps */,
+                                               FALSE /* vacuum_pristines */,
+                                               opt_state->include_externals,
+                                               ctx, iterpool);
+
+          if (err && err->apr_err == SVN_ERR_WC_LOCKED)
+            err = svn_error_create(SVN_ERR_WC_LOCKED, err,
                                      _("Working copy locked; if no other "
                                        "Subversion client is currently "
                                        "using the working copy, try running "
                                        "'svn cleanup' without the "
                                        "--remove-unversioned and "
                                        "--remove-ignored options first."));
-            }
-          else
+          else if (err && err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)
+            err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, err,
+                                     _("Cannot remove unversioned or ignored "
+                                       "items from something that is not a "
+                                       "working copy"));
+        }
+      else
+        {
+          svn_error_t *err = svn_client_cleanup2(target_abspath,
+                                                 TRUE /* break_locks */,
+                                                 TRUE /* fix_timestamps */,
+                                                 TRUE /* clear_dav_cache */,
+                                                 TRUE /* vacuum_pristines */,
+                                                 opt_state->include_externals,
+                                                 ctx, iterpool);
+
+          if (err && err->apr_err == SVN_ERR_WC_LOCKED)
             {
               const char *wcroot_abspath;
+              svn_error_t *err2;
 
               err2 = svn_client_get_wc_root(&wcroot_abspath, target_abspath,
-                                            ctx, subpool, subpool);
+                                            ctx, iterpool, iterpool);
               if (err2)
                 err =  svn_error_compose_create(err, err2);
               else
@@ -106,20 +121,12 @@ svn_cl__cleanup(apr_getopt_t *os,
                                           "'svn cleanup' on the root of the "
                                           "working copy ('%s') instead."),
                                           svn_dirent_local_style(wcroot_abspath,
-                                                                 subpool));
+                                                                 iterpool));
             }
+          SVN_ERR(err);
         }
-      else if (err && err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY &&
-               (opt_state->remove_unversioned || opt_state->remove_ignored))
-        {
-          err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, err,
-                                 _("Cannot remove unversioned or ignored "
-                                   "items from something that is not a "
-                                   "working copy"));
-        }
-      SVN_ERR(err);
     }
 
-  svn_pool_destroy(subpool);
+  svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
 }