subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1548075 - in /subversion/trunk/subversion: include/svn_wc.h libsvn_client/cleanup.c libsvn_wc/cleanup.c libsvn_wc/deprecated.c
Date Thu, 05 Dec 2013 10:19:31 GMT
Author: rhuijben
Date: Thu Dec  5 10:19:31 2013
New Revision: 1548075

URL: http://svn.apache.org/r1548075
Log:
Make it possible to selectively use the cleanup features break locks, fix
timestamps, clear dav cache and vacuum pristines, to allow api users to
use them in a safe way.

Without this patch there is no safe way to use these features as that would
require an external locking agent to verify if no other subversion client
is using the same working copy.

* subversion/include/svn_wc.h
  (svn_wc_cleanup4): New function.

* subversion/libsvn_client/cleanup.c
  (do_cleanup): Remove hack that works for SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE,
    but not for SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE_CLIENTS. This case is now
    properly handled by svn_wc_cleanup4().

* subversion/libsvn_wc/cleanup.c
  (cleanup_internal): Make several features optional.
  (svn_wc_cleanup3): Rename to...
  (svn_wc_cleanup4): ... this. Make features optional.

* subversion/libsvn_wc/deprecated.c
  (svn_wc_cleanup3): new function.

Modified:
    subversion/trunk/subversion/include/svn_wc.h
    subversion/trunk/subversion/libsvn_client/cleanup.c
    subversion/trunk/subversion/libsvn_wc/cleanup.c
    subversion/trunk/subversion/libsvn_wc/deprecated.c

Modified: subversion/trunk/subversion/include/svn_wc.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1548075&r1=1548074&r2=1548075&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Thu Dec  5 10:19:31 2013
@@ -7324,19 +7324,45 @@ svn_wc_get_pristine_copy_path(const char
 
 
 /**
- * Recurse from @a local_abspath, cleaning up unfinished log business.  Perform
- * any temporary allocations in @a scratch_pool.  Any working copy locks under
- * @a local_abspath will be taken over and then cleared by this function.
+ * Recurse from @a local_abspath, cleaning up unfinished tasks.  Perform
+ * any temporary allocations in @a scratch_pool.  If @a break_locks is TRUE
+ * Any working copy locks under @a local_abspath will be taken over and then
+ * cleared by this function.
+ * WARNING: If @a break_locks is TRUE there is no mechanism that will protect
+ * locks that are still being used.
+ *
+ * If @a fix_recorded_timestamps is TRUE the recorded timestamps of unmodified
+ * files will be updated, which will improve performance of future is-modified
+ * checks.
  *
- * WARNING: there is no mechanism that will protect locks that are still being
- * used.
+ * If @a vacuum_pristines is TRUE, try to remove unreferenced pristines from
+ * the working copy.
  *
  * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at various
  * points during the operation.  If it returns an error (typically
  * #SVN_ERR_CANCELLED), return that error immediately.
  *
+ * @since New in 1.9.
+ */
+svn_error_t *
+svn_wc_cleanup4(svn_wc_context_t *wc_ctx,
+                const char *local_abspath,
+                svn_boolean_t break_locks,
+                svn_boolean_t fix_recorded_timestamps,
+                svn_boolean_t clear_dav_cache,
+                svn_boolean_t vacuum_pristines,
+                svn_cancel_func_t cancel_func,
+                void *cancel_baton,
+                apr_pool_t *scratch_pool);
+
+/**
+ * Similar to svn_wc_cleanup4() but will always break locks, fix recorded
+ * timestamps, clear the dav cache and vacuum pristines.
+ *
  * @since New in 1.7.
+ * @deprecated Provided for backward compatibility with the 1.8 API.
  */
+SVN_DEPRECATED
 svn_error_t *
 svn_wc_cleanup3(svn_wc_context_t *wc_ctx,
                 const char *local_abspath,

Modified: subversion/trunk/subversion/libsvn_client/cleanup.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/cleanup.c?rev=1548075&r1=1548074&r2=1548075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/cleanup.c (original)
+++ subversion/trunk/subversion/libsvn_client/cleanup.c Thu Dec  5 10:19:31 2013
@@ -73,11 +73,6 @@ do_cleanup(const char *local_abspath,
     {
       svn_boolean_t is_locked_here;
       svn_boolean_t is_locked;
-      svn_boolean_t sqlite_exclusive;
-      svn_config_t *cfg = ctx->config
-                          ? svn_hash_gets(ctx->config,
-                                          SVN_CONFIG_CATEGORY_CONFIG)
-                          : NULL;
 
       /* Check if someone else owns a lock for LOCAL_ABSPATH. */
       SVN_ERR(svn_wc_locked2(&is_locked_here, &is_locked, ctx->wc_ctx,
@@ -87,17 +82,6 @@ do_cleanup(const char *local_abspath,
                                  _("Working copy at '%s' is already locked."),
                                  svn_dirent_local_style(local_abspath,
                                                         scratch_pool));
-
-      SVN_ERR(svn_config_get_bool(cfg, &sqlite_exclusive,
-                                  SVN_CONFIG_SECTION_WORKING_COPY,
-                                  SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE,
-                                  FALSE));
-      if (sqlite_exclusive)
-        {
-          /* Close the db because svn_wc_cleanup3() will try to open it again,
-           * which doesn't work if exclusive sqlite locking mode is enabled. */
-          SVN_ERR(svn_wc__close_db(local_abspath, ctx->wc_ctx, scratch_pool));
-        }
     }
 
   err = svn_wc_cleanup3(ctx->wc_ctx, local_abspath, ctx->cancel_func,

Modified: subversion/trunk/subversion/libsvn_wc/cleanup.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/cleanup.c?rev=1548075&r1=1548074&r2=1548075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/cleanup.c (original)
+++ subversion/trunk/subversion/libsvn_wc/cleanup.c Thu Dec  5 10:19:31 2013
@@ -137,6 +137,9 @@ repair_timestamps(svn_wc__db_t *db,
 static svn_error_t *
 cleanup_internal(svn_wc__db_t *db,
                  const char *dir_abspath,
+                 svn_boolean_t break_locks,
+                 svn_boolean_t fix_recorded_timestamps,
+                 svn_boolean_t vacuum_pristines,
                  svn_cancel_func_t cancel_func,
                  void *cancel_baton,
                  apr_pool_t *scratch_pool)
@@ -154,7 +157,7 @@ cleanup_internal(svn_wc__db_t *db,
                                       scratch_pool, scratch_pool));
   if (lock_abspath)
     dir_abspath = lock_abspath;
-  SVN_ERR(svn_wc__db_wclock_obtain(db, dir_abspath, -1, TRUE, scratch_pool));
+  SVN_ERR(svn_wc__db_wclock_obtain(db, dir_abspath, -1, break_locks, scratch_pool));
 
   /* Run our changes before the subdirectories. We may not have to recurse
      if we blow away a subdir.  */
@@ -173,7 +176,7 @@ cleanup_internal(svn_wc__db_t *db,
      svn_wc__check_wcroot() as that function, will just return true
      once we start sharing databases with externals.
    */
-  if (is_wcroot)
+  if (is_wcroot && vacuum_pristines)
     {
     /* Cleanup the tmp area of the admin subdir, if running the log has not
        removed it!  The logs have been run, so anything left here has no hope
@@ -184,8 +187,9 @@ cleanup_internal(svn_wc__db_t *db,
       SVN_ERR(svn_wc__db_pristine_cleanup(db, dir_abspath, scratch_pool));
     }
 
-  SVN_ERR(repair_timestamps(db, dir_abspath, cancel_func, cancel_baton,
-                            scratch_pool));
+  if (fix_recorded_timestamps)
+    SVN_ERR(repair_timestamps(db, dir_abspath, cancel_func, cancel_baton,
+                              scratch_pool));
 
   /* All done, toss the lock */
   SVN_ERR(svn_wc__db_wclock_release(db, dir_abspath, scratch_pool));
@@ -193,13 +197,13 @@ cleanup_internal(svn_wc__db_t *db,
   return SVN_NO_ERROR;
 }
 
-
-/* ### possibly eliminate the WC_CTX parameter? callers really shouldn't
-   ### be doing anything *but* running a cleanup, and we need a special
-   ### DB anyway. ... *shrug* ... consider later.  */
 svn_error_t *
-svn_wc_cleanup3(svn_wc_context_t *wc_ctx,
+svn_wc_cleanup4(svn_wc_context_t *wc_ctx,
                 const char *local_abspath,
+                svn_boolean_t break_locks,
+                svn_boolean_t fix_recorded_timestamps,
+                svn_boolean_t clear_dav_cache,
+                svn_boolean_t vacuum_pristines,
                 svn_cancel_func_t cancel_func,
                 void *cancel_baton,
                 apr_pool_t *scratch_pool)
@@ -207,25 +211,43 @@ svn_wc_cleanup3(svn_wc_context_t *wc_ctx
   svn_wc__db_t *db;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+  SVN_ERR_ASSERT(wc_ctx != NULL);
+
+  if (break_locks)
+    {
+      /* We'll handle everything manually.  */
 
-  /* We need a DB that allows a non-empty work queue (though it *will*
-     auto-upgrade). We'll handle everything manually.  */
-  SVN_ERR(svn_wc__db_open(&db,
-                          NULL /* ### config */, FALSE, FALSE,
-                          scratch_pool, scratch_pool));
+      /* Close the existing database (if any) to avoid problems with
+         exclusive database usage */
+      SVN_ERR(svn_wc__db_drop_root(wc_ctx->db, local_abspath,
+                                   scratch_pool));
+
+      SVN_ERR(svn_wc__db_open(&db,
+                              NULL /* ### config */, FALSE, FALSE,
+                              scratch_pool, scratch_pool));
+    }
+  else
+    db = wc_ctx->db;
 
-  SVN_ERR(cleanup_internal(db, local_abspath, cancel_func, cancel_baton,
+  SVN_ERR(cleanup_internal(db, local_abspath,
+                           break_locks,
+                           fix_recorded_timestamps,
+                           vacuum_pristines,
+                           cancel_func, cancel_baton,
                            scratch_pool));
 
   /* The DAV cache suffers from flakiness from time to time, and the
      pre-1.7 prescribed workarounds aren't as user-friendly in WC-NG. */
-  SVN_ERR(svn_wc__db_base_clear_dav_cache_recursive(db, local_abspath,
-                                                    scratch_pool));
+  if (clear_dav_cache)
+    SVN_ERR(svn_wc__db_base_clear_dav_cache_recursive(db, local_abspath,
+                                                      scratch_pool));
 
-  SVN_ERR(svn_wc__db_vacuum(db, local_abspath, scratch_pool));
+  if (vacuum_pristines)
+    SVN_ERR(svn_wc__db_vacuum(db, local_abspath, scratch_pool));
 
   /* We're done with this DB, so proactively close it.  */
-  SVN_ERR(svn_wc__db_close(db));
+  if (break_locks)
+    SVN_ERR(svn_wc__db_close(db));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_wc/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/deprecated.c?rev=1548075&r1=1548074&r2=1548075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_wc/deprecated.c Thu Dec  5 10:19:31 2013
@@ -4185,7 +4185,25 @@ svn_wc_relocate(const char *path,
 }
 
 
-/*** From log.c ***/
+/*** From log.c / cleanup.c ***/
+
+svn_error_t *
+svn_wc_cleanup3(svn_wc_context_t *wc_ctx,
+                const char *local_abspath,
+                svn_cancel_func_t cancel_func,
+                void *cancel_baton,
+                apr_pool_t *scratch_pool)
+{
+  return svn_error_trace(
+            svn_wc_cleanup4(wc_ctx,
+                            local_abspath,
+                            TRUE /* break_locks */,
+                            TRUE /* fix_recorded_timestamps */,
+                            TRUE /* clear_dav_cache */,
+                            TRUE /* clean_pristines */,
+                            cancel_func, cancel_baton,
+                            scratch_pool));
+}
 
 svn_error_t *
 svn_wc_cleanup2(const char *path,



Mime
View raw message