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 2011/04/12 17:36:19 UTC

svn commit: r1091474 - in /subversion/trunk/subversion: include/private/svn_wc_private.h libsvn_client/commit_util.c libsvn_wc/node.c

Author: rhuijben
Date: Tue Apr 12 15:36:19 2011
New Revision: 1091474

URL: http://svn.apache.org/viewvc?rev=1091474&view=rev
Log:
Another small step in cleaning up the commit harvester: Directly obtain
lock tokens for nodes, instead of using a separate db operation. Walk all
BASE descendants of a deleted node to find lock tokens to properly handle
directories replaced by files.

* subversion/include/private/svn_wc_private.h
  (svn_wc__node_get_commit_status): Add argument.
  (harvest_committables): Rename a few variables. Always obtain locks. Walk
    all BASE descendants of deleted nodes to find locks, instead of only those
    of directories.
* subversion/libsvn_client/commit_util.c
* subversion/libsvn_wc/node.c

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/commit_util.c
    subversion/trunk/subversion/libsvn_wc/node.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=1091474&r1=1091473&r2=1091474&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Tue Apr 12 15:36:19 2011
@@ -929,6 +929,7 @@ svn_wc__node_get_commit_status(svn_node_
                                const char **changelist,
                                svn_boolean_t *props_mod,
                                svn_boolean_t *update_root,
+                               const char **lock_token,
                                svn_wc_context_t *wc_ctx,
                                const char *local_abspath,
                                apr_pool_t *result_pool,

Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1091474&r1=1091473&r2=1091474&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Tue Apr 12 15:36:19 2011
@@ -344,10 +344,11 @@ harvest_committables(svn_wc_context_t *w
   apr_byte_t state_flags = 0;
   svn_node_kind_t working_kind;
   svn_node_kind_t db_kind;
-  const char *entry_relpath;
-  const char *entry_lock_token;
+  const char *node_relpath;
+  const char *node_lock_token;
+  svn_revnum_t node_rev;
   const char *cf_relpath = NULL;
-  svn_revnum_t entry_rev, cf_rev = SVN_INVALID_REVNUM;
+  svn_revnum_t cf_rev = SVN_INVALID_REVNUM;
   svn_boolean_t matches_changelists;
   svn_boolean_t is_special;
   svn_boolean_t is_added;
@@ -385,19 +386,20 @@ harvest_committables(svn_wc_context_t *w
                                          &is_replaced,
                                          &is_not_present, &is_excluded,
                                          &is_op_root, &is_symlink,
-                                         &entry_rev, &entry_relpath,
+                                         &node_rev, &node_relpath,
                                          &original_rev, &original_relpath,
                                          &conflicted,
                                          &node_changelist,
                                          &prop_mod, &is_update_root,
+                                         &node_lock_token,
                                          wc_ctx, local_abspath,
                                          scratch_pool, scratch_pool));
 
   if ((skip_files && db_kind == svn_node_file) || is_excluded)
     return SVN_NO_ERROR;
 
-  if (!entry_relpath && commit_relpath)
-    entry_relpath = commit_relpath;
+  if (!node_relpath && commit_relpath)
+    node_relpath = commit_relpath;
 
   SVN_ERR(svn_io_check_special_path(local_abspath, &working_kind, &is_special,
                                     scratch_pool));
@@ -473,8 +475,8 @@ harvest_committables(svn_wc_context_t *w
         }
     }
 
-  if (entry_relpath == NULL)
-    SVN_ERR(svn_wc__node_get_repos_relpath(&entry_relpath,
+  if (node_relpath == NULL)
+    SVN_ERR(svn_wc__node_get_repos_relpath(&node_relpath,
                                            wc_ctx, local_abspath,
                                            scratch_pool, scratch_pool));
   /* Check for the deletion case.
@@ -491,8 +493,6 @@ harvest_committables(svn_wc_context_t *w
      We also note whether or not this is an add with history here.  */
   if (is_added)
     {
-      svn_boolean_t is_copy_target;
-
       if (is_op_root)
         {
           /* Root of local add or copy */
@@ -587,7 +587,7 @@ harvest_committables(svn_wc_context_t *w
                                                              scratch_pool),
                                           scratch_pool));
 
-      if (copy_mode_root || entry_rev != dir_rev)
+      if (copy_mode_root || node_rev != dir_rev)
         {
           state_flags |= SVN_CLIENT_COMMIT_ITEM_ADD;
           if (node_copyfrom_relpath)
@@ -596,11 +596,11 @@ harvest_committables(svn_wc_context_t *w
               cf_relpath = node_copyfrom_relpath;
               cf_rev = node_copyfrom_rev;
             }
-          else if (entry_rev != SVN_INVALID_REVNUM)
+          else if (node_rev != SVN_INVALID_REVNUM)
             {
               state_flags |= SVN_CLIENT_COMMIT_ITEM_IS_COPY;
-              cf_relpath = entry_relpath;
-              cf_rev = entry_rev;
+              cf_relpath = node_relpath;
+              cf_rev = node_rev;
             }
         }
     }
@@ -679,14 +679,9 @@ harvest_committables(svn_wc_context_t *w
   /* If the entry has a lock token and it is already a commit candidate,
      or the caller wants unmodified locked items to be treated as
      such, note this fact. */
-  if (lock_tokens && (state_flags || just_locked))
+  if (node_lock_token && lock_tokens && (state_flags || just_locked))
     {
-      SVN_ERR(svn_wc__node_get_lock_info(&entry_lock_token, NULL, NULL, NULL,
-                                         wc_ctx, local_abspath,
-                                         apr_hash_pool_get(lock_tokens),
-                                         scratch_pool));
-      if (entry_lock_token)
-        state_flags |= SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN;
+      state_flags |= SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN;
     }
 
   /* Now, if this is something to commit, add it to our list. */
@@ -699,8 +694,8 @@ harvest_committables(svn_wc_context_t *w
                                   repos_root_url,
                                   commit_relpath 
                                       ? commit_relpath
-                                      : entry_relpath,
-                                  entry_rev,
+                                      : node_relpath,
+                                  node_rev,
                                   cf_relpath,
                                   cf_rev,
                                   state_flags,
@@ -708,9 +703,41 @@ harvest_committables(svn_wc_context_t *w
           if (state_flags & SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN)
             apr_hash_set(lock_tokens,
                          svn_path_url_add_component2(
-                             repos_root_url, entry_relpath,
+                             repos_root_url, node_relpath,
                              apr_hash_pool_get(lock_tokens)),
-                         APR_HASH_KEY_STRING, entry_lock_token);
+                         APR_HASH_KEY_STRING, node_lock_token);
+        }
+    }
+
+    /* Fetch lock tokens for descendants of deleted nodes. */
+  if (lock_tokens
+      && (state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE))
+    {
+      apr_hash_t *local_relpath_tokens;
+      apr_hash_index_t *hi;
+
+      SVN_ERR(svn_wc__node_get_lock_tokens_recursive(
+                  &local_relpath_tokens, wc_ctx, local_abspath,
+                  scratch_pool, scratch_pool));
+
+      /* Map local_relpaths to URLs. */
+      for (hi = apr_hash_first(scratch_pool, local_relpath_tokens);
+           hi;
+           hi = apr_hash_next(hi))
+        {
+          const char *item_abspath = svn__apr_hash_index_key(hi);
+          const char *lock_token = svn__apr_hash_index_val(hi);
+          const char *item_url;
+          apr_pool_t *token_pool = apr_hash_pool_get(lock_tokens);
+
+          if (cancel_func)
+            SVN_ERR(cancel_func(cancel_baton));
+
+          SVN_ERR(svn_wc__node_get_url(&item_url, wc_ctx, item_abspath,
+                                       token_pool, scratch_pool));
+          if (item_url)
+            apr_hash_set(lock_tokens, item_url, APR_HASH_KEY_STRING,
+                         apr_pstrdup(token_pool, lock_token));
         }
     }
 
@@ -769,38 +796,6 @@ harvest_committables(svn_wc_context_t *w
       svn_pool_destroy(iterpool);
     }
 
-  /* Fetch lock tokens for descendants of deleted directories. */
-  if (lock_tokens
-      && (state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE))
-    {
-      apr_hash_t *local_relpath_tokens;
-      apr_hash_index_t *hi;
-
-      SVN_ERR(svn_wc__node_get_lock_tokens_recursive(
-                  &local_relpath_tokens, wc_ctx, local_abspath,
-                  scratch_pool, scratch_pool));
-
-      /* Map local_relpaths to URLs. */
-      for (hi = apr_hash_first(scratch_pool, local_relpath_tokens);
-           hi;
-           hi = apr_hash_next(hi))
-        {
-          const char *item_abspath = svn__apr_hash_index_key(hi);
-          const char *lock_token = svn__apr_hash_index_val(hi);
-          const char *item_url;
-          apr_pool_t *token_pool = apr_hash_pool_get(lock_tokens);
-
-          if (cancel_func)
-            SVN_ERR(cancel_func(cancel_baton));
-
-          SVN_ERR(svn_wc__node_get_url(&item_url, wc_ctx, item_abspath,
-                                       token_pool, scratch_pool));
-          if (item_url)
-            apr_hash_set(lock_tokens, item_url, APR_HASH_KEY_STRING,
-                         apr_pstrdup(token_pool, lock_token));
-        }
-    }
-
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_wc/node.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/node.c?rev=1091474&r1=1091473&r2=1091474&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/node.c (original)
+++ subversion/trunk/subversion/libsvn_wc/node.c Tue Apr 12 15:36:19 2011
@@ -1551,6 +1551,7 @@ svn_wc__node_get_commit_status(svn_node_
                                const char **changelist,
                                svn_boolean_t *props_mod,
                                svn_boolean_t *update_root,
+                               const char **lock_token,
                                svn_wc_context_t *wc_ctx,
                                const char *local_abspath,
                                apr_pool_t *result_pool,
@@ -1558,6 +1559,7 @@ svn_wc__node_get_commit_status(svn_node_
 {
   svn_wc__db_status_t status;
   svn_wc__db_kind_t db_kind;
+  svn_wc__db_lock_t *lock;
   svn_boolean_t have_base;
 
   /* ### All of this should be handled inside a single read transaction */
@@ -1565,7 +1567,7 @@ svn_wc__node_get_commit_status(svn_node_
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL,NULL, changelist, original_repos_relpath,
                                NULL, NULL, original_revision, props_mod,
-                               &have_base, NULL, conflicted, NULL,
+                               &have_base, NULL, conflicted, &lock,
                                wc_ctx->db, local_abspath,
                                result_pool, scratch_pool));
 
@@ -1649,6 +1651,8 @@ svn_wc__node_get_commit_status(svn_node_
         }
     }
 
+  /* Retrieve some information from BASE which is needed for replacing
+     and/or deleting BASE nodes. (We don't need lock here) */
   if (have_base
       && ((revision && !SVN_IS_VALID_REVNUM(*revision))
           || (update_root && status == svn_wc__db_status_normal)))
@@ -1662,6 +1666,9 @@ svn_wc__node_get_commit_status(svn_node_
   else if (update_root)
     *update_root = FALSE;
 
+  if (lock_token)
+    *lock_token = lock ? lock->token : NULL;
+
   return SVN_NO_ERROR;
 }
 



Re: svn commit: r1091474 - in /subversion/trunk/subversion: include/private/svn_wc_private.h libsvn_client/commit_util.c libsvn_wc/node.c

Posted by Philip Martin <ph...@wandisco.com>.
rhuijben@apache.org writes:

> Author: rhuijben
> Date: Tue Apr 12 15:36:19 2011
> New Revision: 1091474
>
> URL: http://svn.apache.org/viewvc?rev=1091474&view=rev
> Log:
> Another small step in cleaning up the commit harvester: Directly obtain
> lock tokens for nodes, instead of using a separate db operation. Walk all
> BASE descendants of a deleted node to find lock tokens to properly handle
> directories replaced by files.
>
> * subversion/include/private/svn_wc_private.h
>   (svn_wc__node_get_commit_status): Add argument.
>   (harvest_committables): Rename a few variables. Always obtain locks. Walk
>     all BASE descendants of deleted nodes to find locks, instead of only those
>     of directories.
> * subversion/libsvn_client/commit_util.c
> * subversion/libsvn_wc/node.c

This log message isn't right.  I think this causes some of the lock
tests to fail (I can't be sure since this rev doesn't compile on my
machine, they fail with the next rev r1091475).

-- 
Philip