Author: philip
Date: Sun Mar 14 14:36:26 2010
New Revision: 922867

URL: http://svn.apache.org/viewvc?rev=922867&view=rev
Log:
Make acquire obtain all or no locks.

* subversion/libsvn_wc/lock.c
  (svn_wc__acquire_write_lock): Release acquired locks if a pre-existing
   lock is encountered during recursive locking.

* subversion/include/private/svn_wc_private.h
  (svn_wc__acquire_write_lock): Tweak doc string.

* subversion/libsvn_client/commit.c
  (svn_client_commit4): No need to release locks if acquire returns an error.

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/commit.c
    subversion/trunk/subversion/libsvn_wc/lock.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=922867&r1=922866&r2=922867&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Sun Mar 14 
14:36:26 2010
@@ -504,11 +504,10 @@ svn_wc__node_get_lock_token(const char *
  * and return the anchor path in @a *anchor_abspath.  Use @a wc_ctx
  * for working copy access.
  *
- * Returns @c SVN_ERR_WC_LOCKED an existing lock is encountered, but
- * may have set locks of it's own; it's not clear how the caller is
- * expected to handle this.
+ * Returns @c SVN_ERR_WC_LOCKED if an existing lock is encountered, in
+ * which case any locks acquired will have been released.
  *
- * If @a *anchor_abspath is not NULL it will be set evenwhen
+ * If @a *anchor_abspath is not NULL it will be set even when
  * SVN_ERR_WC_LOCKED is returned.
  *
  * ### @a anchor_abspath should be removed when we move to centralised

Modified: subversion/trunk/subversion/libsvn_client/commit.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit.c?rev=922867&r1=922866&r2=922867&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit.c Sun Mar 14 14:36:26 2010
@@ -1098,7 +1098,6 @@ svn_client_commit4(svn_commit_info_t **c
   apr_hash_t *tempfiles = NULL;
   apr_hash_t *checksums;
   apr_array_header_t *commit_items;
-  svn_error_t *lock_err;
   svn_error_t *cmt_err = SVN_NO_ERROR, *unlock_err = SVN_NO_ERROR;
   svn_error_t *bump_err = SVN_NO_ERROR, *cleanup_err = SVN_NO_ERROR;
   svn_boolean_t commit_in_progress = FALSE;
@@ -1155,10 +1154,7 @@ svn_client_commit4(svn_commit_info_t **c
         }
     }
 
-  if ((lock_err = svn_wc__acquire_write_lock(NULL, ctx->wc_ctx, base_dir,
-                                             pool, pool)))
-    return svn_error_return(svn_error_compose_create(lock_err,
-                     svn_wc__release_write_lock(ctx->wc_ctx, base_dir, pool)));
+  SVN_ERR(svn_wc__acquire_write_lock(NULL, ctx->wc_ctx, base_dir, pool, pool));
 
   /* One day we might support committing from multiple working copies, but
      we don't yet.  This check ensures that we don't silently commit a

Modified: subversion/trunk/subversion/libsvn_wc/lock.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/lock.c?rev=922867&r1=922866&r2=922867&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/lock.c (original)
+++ subversion/trunk/subversion/libsvn_wc/lock.c Sun Mar 14 14:36:26 2010
@@ -1789,8 +1789,19 @@ svn_wc__acquire_write_lock(const char **
       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(NULL, wc_ctx, child_abspath,
-                                           NULL, iterpool));
+        {
+          err = svn_wc__acquire_write_lock(NULL, wc_ctx, child_abspath, NULL,
+                                           iterpool);
+          if (err && err->apr_err == SVN_ERR_WC_LOCKED)
+            {
+              svn_error_t *err2 = svn_wc__release_write_lock(wc_ctx,
+                                                             child_abspath,
+                                                             iterpool);
+              if (err2)
+                svn_error_compose(err, err2);
+              return svn_error_return(err);
+            }
+        }
     }
 
   /* We don't want to try and lock an unversioned directory that


Reply via email to