subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r881970 - in /subversion/trunk/subversion: include/private/svn_wc_private.h libsvn_client/add.c libsvn_wc/lock.c libsvn_wc/wc_db.c
Date Wed, 18 Nov 2009 22:32:27 GMT
Author: hwright
Date: Wed Nov 18 22:32:27 2009
New Revision: 881970

URL: http://svn.apache.org/viewvc?rev=881970&view=rev
Log:
Add a couple of working copy APIs to allow the client library to lock the
working copy, without the use of an intermediate access baton.  Use these
APIs in svn_client_add4().

* subversion/include/private/svn_wc_private.h
  (svn_wc__acquire_write_lock, svn_wc__release_write_lock): New.

* subversion/libsvn_wc/lock.c
  (svn_wc__acquire_write_lock, svn_wc__release_write_lock): New.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_temp_mark_locked): When marking the pdh locked, create it
    if needed.

* subversion/libsvn_client/add.c
  (svn_client_add4): Replace access baton use with lock APIs instead.

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/add.c
    subversion/trunk/subversion/libsvn_wc/lock.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=881970&r1=881969&r2=881970&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Wed Nov 18 22:32:27 2009
@@ -514,6 +514,26 @@
                             apr_pool_t *result_pool,
                             apr_pool_t *scratch_pool);
 
+
+/**
+ * Recursively acquire write locks for @a local_abspath, using @a wc_ctx
+ * for working copy access.
+ */
+svn_error_t *
+svn_wc__acquire_write_lock(svn_wc_context_t *wc_ctx,
+                           const char *local_abspath,
+                           apr_pool_t *scratch_pool);
+
+
+/**
+ * Recursively release write locks for @a local_abspath, using @a wc_ctx
+ * for working copy access.
+ */
+svn_error_t *
+svn_wc__release_write_lock(svn_wc_context_t *wc_ctx,
+                           const char *local_abspath,
+                           apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/trunk/subversion/libsvn_client/add.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/add.c?rev=881970&r1=881969&r2=881970&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/add.c (original)
+++ subversion/trunk/subversion/libsvn_client/add.c Wed Nov 18 22:32:27 2009
@@ -578,7 +578,6 @@
                 apr_pool_t *pool)
 {
   svn_error_t *err;
-  svn_wc_adm_access_t *adm_access;
   const char *parent_abspath;
   const char *local_abspath;
 
@@ -596,6 +595,8 @@
   else
     parent_abspath = svn_dirent_dirname(local_abspath, pool);
 
+  SVN_ERR(svn_wc__acquire_write_lock(ctx->wc_ctx, parent_abspath, pool));
+
   if (add_parents)
     {
       apr_pool_t *subpool;
@@ -605,18 +606,14 @@
       svn_pool_destroy(subpool);
     }
 
-  SVN_ERR(svn_wc__adm_open_in_context(&adm_access, ctx->wc_ctx, parent_abspath,
-                                      TRUE, 0, ctx->cancel_func,
-                                      ctx->cancel_baton, pool));
-
   err = add(local_abspath, depth, force, no_ignore, ctx, pool);
 
-  /* ### Currently we rely on the fact that this close (like all other access
-         baton close operations), closes all batons opened by svn_wc_add4(). */
+  /* ### Currently we rely on the fact that this releases all our write locks
+     ### recursively. */
   return svn_error_return(
             svn_error_compose_create(
-                 err,
-                 svn_wc_adm_close2(adm_access, pool)));
+              err,
+              svn_wc__release_write_lock(ctx->wc_ctx, parent_abspath, pool)));
 }
 
 

Modified: subversion/trunk/subversion/libsvn_wc/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/lock.c?rev=881970&r1=881969&r2=881970&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/lock.c (original)
+++ subversion/trunk/subversion/libsvn_wc/lock.c Wed Nov 18 22:32:27 2009
@@ -1744,3 +1744,92 @@
   }
 }
 
+
+svn_error_t *
+svn_wc__acquire_write_lock(svn_wc_context_t *wc_ctx,
+                           const char *local_abspath,
+                           apr_pool_t *scratch_pool)
+{
+  svn_wc__db_kind_t kind;
+  apr_pool_t *iterpool;
+  const apr_array_header_t *children;
+  int i;
+
+  SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath, TRUE,
+                               scratch_pool));
+  if (kind == svn_wc__db_kind_file)
+    local_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
+
+  /* The current lock paradigm is that each directory holds a lock for itself,
+     and there are no inherited locks.  In the eventual wc-ng paradigm, a
+     lock on a directory, would imply a infinite-depth lock on the children.
+     But since we aren't quite there yet, we do the infinite locking
+     manually (and be sure to release them in svn_wc__release_write_lock(). */
+
+  SVN_ERR(svn_wc__db_read_children(&children, wc_ctx->db, local_abspath,
+                                   scratch_pool, scratch_pool));
+  iterpool = svn_pool_create(scratch_pool);
+  for (i = 0; i < children->nelts; i ++)
+    {
+      const char *child_relpath = APR_ARRAY_IDX(children, i, const char *);
+      const char *child_abspath;
+
+      svn_pool_clear(iterpool);
+      child_abspath = svn_dirent_join(local_abspath, child_relpath, iterpool);
+
+      SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, child_abspath, FALSE,
+                                   iterpool));
+      if (kind == svn_wc__db_kind_dir)
+        SVN_ERR(svn_wc__acquire_write_lock(wc_ctx, child_abspath, iterpool));
+    }
+
+  SVN_ERR(svn_wc__db_wclock_set(wc_ctx->db, local_abspath, iterpool));
+  SVN_ERR(svn_wc__db_temp_mark_locked(wc_ctx->db, local_abspath, iterpool));
+
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_wc__release_write_lock(svn_wc_context_t *wc_ctx,
+                           const char *local_abspath,
+                           apr_pool_t *scratch_pool)
+{
+  svn_wc__db_kind_t kind;
+  apr_pool_t *iterpool;
+  const apr_array_header_t *children;
+  int i;
+
+  SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath, TRUE,
+                               scratch_pool));
+  if (kind == svn_wc__db_kind_file)
+    local_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
+
+  /* We need to recursively remove locks (see comment in
+     svn_wc__acquire_write_lock(). */
+
+  SVN_ERR(svn_wc__db_read_children(&children, wc_ctx->db, local_abspath,
+                                   scratch_pool, scratch_pool));
+  iterpool = svn_pool_create(scratch_pool);
+  for (i = 0; i < children->nelts; i ++)
+    {
+      const char *child_relpath = APR_ARRAY_IDX(children, i, const char *);
+      const char *child_abspath;
+
+      svn_pool_clear(iterpool);
+      child_abspath = svn_dirent_join(local_abspath, child_relpath, iterpool);
+
+      SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, child_abspath, FALSE,
+                                   iterpool));
+      if (kind == svn_wc__db_kind_dir)
+        SVN_ERR(svn_wc__release_write_lock(wc_ctx, child_abspath, iterpool));
+    }
+
+  SVN_ERR(svn_wc__db_wclock_remove(wc_ctx->db, local_abspath, iterpool));
+
+  svn_pool_destroy(iterpool);
+
+  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=881970&r1=881969&r2=881970&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Nov 18 22:32:27 2009
@@ -5644,7 +5644,7 @@
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_dir_abspath));
 
-  pdh = get_or_create_pdh(db, local_dir_abspath, FALSE, scratch_pool);
+  pdh = get_or_create_pdh(db, local_dir_abspath, TRUE, scratch_pool);
   pdh->locked = TRUE;
 
   return SVN_NO_ERROR;



Mime
View raw message