subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r967018 - in /subversion/trunk/subversion/libsvn_wc: lock.c wc_db.c
Date Fri, 23 Jul 2010 10:01:53 GMT
Author: rhuijben
Date: Fri Jul 23 10:01:53 2010
New Revision: 967018

URL: http://svn.apache.org/viewvc?rev=967018&view=rev
Log:
Revert to the original behavior that locking an unversioned directory is an
error. The current behavior of just ignoring this, moves the real problem
to other locations.

* subversion/libsvn_wc/lock.c
  (acquire_locks_recurively): New function, handling the recursive locking
    behavior for non-single db with knowledge about whether we are locking
    the root or a subdir. Return an error when locking the lock root
    fails.
  (svn_wc__acquire_write_lock): Move the recursive locking behavior to
    acquire_locks_recurively.

* subversion/libsvn_wc/wc_db.c
  (wclock_obtain_cb): When using single-db verify that the path to lock
    exists.

Modified:
    subversion/trunk/subversion/libsvn_wc/lock.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_wc/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/lock.c?rev=967018&r1=967017&r2=967018&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/lock.c (original)
+++ subversion/trunk/subversion/libsvn_wc/lock.c Fri Jul 23 10:01:53 2010
@@ -1526,6 +1526,93 @@ svn_wc__adm_missing(svn_wc__db_t *db,
   return (kind == svn_wc__db_kind_dir) && !available && obstructed;
 }
 
+#ifndef SVN_WC__SINGLE_DB
+static svn_error_t *
+acquire_locks_recurively(svn_wc_context_t *wc_ctx,
+                         const char* local_abspath,
+                         svn_boolean_t lock_root,
+                         apr_pool_t *scratch_pool)
+{
+ svn_wc__db_t *db = wc_ctx->db;
+  apr_array_header_t *children;
+  apr_pool_t *iterpool;
+  svn_error_t *err;
+  int i;
+  int format;
+
+  iterpool = svn_pool_create(scratch_pool);
+
+  SVN_ERR(svn_wc__db_read_children(&children, wc_ctx->db, local_abspath,
+                                   scratch_pool, iterpool));
+
+  /* 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(). */
+
+  for (i = 0; i < children->nelts; i ++)
+    {
+      svn_wc__db_kind_t kind;
+      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)
+        {
+          err = acquire_locks_recurively(wc_ctx, child_abspath, FALSE,
+                                         iterpool);
+          if (err && err->apr_err == SVN_ERR_WC_LOCKED)
+            {
+              while(i >= 0)
+                {
+                  svn_error_t *err2;
+                  svn_pool_clear(iterpool);
+                  child_relpath = APR_ARRAY_IDX(children, i, const char *);
+                  child_abspath = svn_dirent_join(local_abspath, child_relpath,
+                                                  iterpool);
+
+                  /* Don't release locks on non-directories as that will
+                     try to release the lock on the parent directory! */
+                  err2 = svn_wc__db_read_kind(&kind, wc_ctx->db, child_abspath,
+                                              FALSE, iterpool);
+
+                  if (!err2 && kind == svn_wc__db_kind_dir)
+                    err2 = svn_wc__release_write_lock(wc_ctx, child_abspath,
+                                                      iterpool);
+
+                  err = svn_error_compose_create(err, err2);
+                  --i;
+                }
+              return svn_error_return(err);
+            }
+        }
+    }
+
+  if (lock_root)
+    SVN_ERR(svn_wc__db_wclock_obtain(db, local_abspath, 0, FALSE, iterpool));
+  else
+    {
+      /* We don't want to try and lock an unversioned directory that
+         obstructs a versioned directory. */
+      err = svn_wc__internal_check_wc(&format, wc_ctx->db, local_abspath,
+                                      iterpool);
+
+      if (!err && format)
+          SVN_ERR(svn_wc__db_wclock_obtain(wc_ctx->db, local_abspath, 0, FALSE,
+                                          iterpool));
+
+      svn_error_clear(err);
+    }
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+#endif
 
 svn_error_t *
 svn_wc__acquire_write_lock(const char **lock_root_abspath,
@@ -1537,9 +1624,6 @@ svn_wc__acquire_write_lock(const char **
 {
   svn_wc__db_t *db = wc_ctx->db;
   svn_wc__db_kind_t kind;
-  apr_pool_t *iterpool;
-  const apr_array_header_t *children;
-  int format, i;
   svn_error_t *err;
   SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath,
                                (lock_root_abspath != NULL),
@@ -1608,68 +1692,7 @@ svn_wc__acquire_write_lock(const char **
     *lock_root_abspath = apr_pstrdup(result_pool, local_abspath);
 
 #ifndef SVN_WC__SINGLE_DB
-  SVN_ERR(svn_wc__db_read_children(&children, wc_ctx->db, local_abspath,
-                                   scratch_pool, 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(). */
-
-  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)
-        {
-          err = svn_wc__acquire_write_lock(NULL, wc_ctx, child_abspath, FALSE,
-                                           result_pool, iterpool);
-          if (err && err->apr_err == SVN_ERR_WC_LOCKED)
-            {
-              while(i >= 0)
-                {
-                  svn_error_t *err2;
-                  svn_pool_clear(iterpool);
-                  child_relpath = APR_ARRAY_IDX(children, i, const char *);
-                  child_abspath = svn_dirent_join(local_abspath, child_relpath,
-                                                  iterpool);
-
-                  /* Don't release locks on non-directories as that will
-                     try to release the lock on the parent directory! */
-                  err2 = svn_wc__db_read_kind(&kind, wc_ctx->db, child_abspath,
-                                              FALSE, iterpool);
-
-                  if (!err2 && kind == svn_wc__db_kind_dir)
-                    err2 = svn_wc__release_write_lock(wc_ctx, child_abspath,
-                                                      iterpool);
-
-                  err = svn_error_compose_create(err, err2);
-                  --i;
-                }
-              return svn_error_return(err);
-            }
-        }
-    }
-
-  /* We don't want to try and lock an unversioned directory that
-     obstructs a versioned directory. */
-  err = svn_wc__internal_check_wc(&format, wc_ctx->db, local_abspath,
-                                  iterpool);
-  if (!err && format)
-    {
-      SVN_ERR(svn_wc__db_wclock_obtain(wc_ctx->db, local_abspath, 0, FALSE,
-                                       iterpool));
-    }
-  svn_error_clear(err);
-  svn_pool_destroy(iterpool);
+  SVN_ERR(acquire_locks_recurively(wc_ctx, local_abspath, TRUE, scratch_pool));
 #else
   SVN_ERR(svn_wc__db_wclock_obtain(wc_ctx->db, local_abspath, -1, FALSE,
                                    scratch_pool));

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=967018&r1=967017&r2=967018&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri Jul 23 10:01:53 2010
@@ -7983,6 +7983,16 @@ wclock_obtain_cb(void *baton,
 
 #ifdef SVN_WC__SINGLE_DB
   svn_wc__db_wclock_t lock;
+  svn_boolean_t have_base, have_working;
+
+  SVN_ERR(which_trees_exist(&have_base, &have_working, sdb,
+                            bt->pdh->wcroot->wc_id, bt->local_relpath));
+
+  if (!have_base && !have_working)
+    return svn_error_createf(
+                SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                _("The node '%s' was not found."),
+                svn_dirent_local_style(bt->local_abspath, scratch_pool));
 #else
   /* ### Can only lock this directory in the per-dir layout.  This is
      ### a temporary restriction until metadata gets centralised.



Mime
View raw message