Author: rhuijben
Date: Wed Apr 13 10:17:21 2011
New Revision: 1091728

URL: http://svn.apache.org/viewvc?rev=1091728&view=rev
Log:
When retrieving lock tokens for the commit processor, make wc_db directly
key them on their url instead of walking all the results to fetch their
url in the only user of this api.

* subversion/include/private/svn_wc_private.h
  (svn_wc__node_get_lock_tokens_recursive): Update documentation.

* subversion/libsvn_client/commit_util.c
  (harvest_committables): Just merge the result instead of walking the result.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_BASE_NODE_LOCK_TOKENS_RECURSIVE): Fetch other columns and don't
    use an outer join if we are not interested in NULL values.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_base_get_lock_tokens_recursive): Fetch urls instead of
    constructing local abspaths.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_base_get_lock_tokens_recursive): Update documentation.

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/commit_util.c
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h

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=1091728&r1=1091727&r2=1091728&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Wed Apr 13 
10:17:21 2011
@@ -804,11 +804,10 @@ svn_wc__node_clear_dav_cache_recursive(s
                                        apr_pool_t *scratch_pool);
 
 /**
- * Set @a lock_tokens to a hash mapping <tt>const char *</tt> local
- * absolute paths to <tt>const char *</tt> lock tokens for every path
- * at or under @a local_abspath in @a wc_ctx which has such a lock
- * token set on it.  Allocate the hash and all items therein from
- * @a result_pool.
+ * Set @a lock_tokens to a hash mapping <tt>const char *</tt> URL
+ * to <tt>const char *</tt> lock tokens for every path at or under
+ * @a local_abspath in @a wc_ctx which has such a lock token set on it.
+ * Allocate the hash and all items therein from @a result_pool.
  */
 svn_error_t *
 svn_wc__node_get_lock_tokens_recursive(apr_hash_t **lock_tokens,

Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1091728&r1=1091727&r2=1091728&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Wed Apr 13 10:17:21 
2011
@@ -661,29 +661,24 @@ harvest_committables(svn_wc_context_t *w
     {
       apr_hash_t *local_relpath_tokens;
       apr_hash_index_t *hi;
+      apr_pool_t *token_pool = apr_hash_pool_get(lock_tokens);
 
       SVN_ERR(svn_wc__node_get_lock_tokens_recursive(
                   &local_relpath_tokens, wc_ctx, local_abspath,
-                  scratch_pool, scratch_pool));
+                  token_pool, scratch_pool));
 
-      /* Map local_relpaths to URLs. */
+      /* Add tokens to existing hash. */
       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));
+          const void *key;
+          apr_ssize_t klen;
+          void * val;
+
+          apr_hash_this(hi, &key, &klen, &val);
+
+          apr_hash_set(lock_tokens, key, klen, val);
         }
     }
 

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1091728&r1=1091727&r2=1091728&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed Apr 13 10:17:21 
2011
@@ -238,9 +238,9 @@ INSERT OR REPLACE INTO lock
 VALUES (?1, ?2, ?3, ?4, ?5, ?6)
 
 -- STMT_SELECT_BASE_NODE_LOCK_TOKENS_RECURSIVE
-SELECT local_relpath, lock_token
+SELECT nodes.repos_id, nodes.repos_path, lock_token
 FROM nodes
-LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id
+LEFT JOIN lock ON nodes.repos_id = lock.repos_id
   AND nodes.repos_path = lock.repos_relpath
 WHERE wc_id = ?1 AND op_depth = 0
   AND (local_relpath = ?2 OR local_relpath LIKE ?3 ESCAPE '#')

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1091728&r1=1091727&r2=1091728&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Apr 13 10:17:21 2011
@@ -10626,9 +10626,10 @@ svn_wc__db_base_get_lock_tokens_recursiv
 {
   svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath; 
-  const char *like_arg;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
+  apr_int64_t last_repos_id = INVALID_REPOS_ID;
+  const char *last_repos_root_url;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
@@ -10643,23 +10644,39 @@ svn_wc__db_base_get_lock_tokens_recursiv
   SVN_ERR(svn_sqlite__get_statement(
               &stmt, wcroot->sdb,
               STMT_SELECT_BASE_NODE_LOCK_TOKENS_RECURSIVE));
-  like_arg = construct_like_arg(local_relpath, scratch_pool);
+
   SVN_ERR(svn_sqlite__bindf(stmt, "iss", wcroot->wc_id, local_relpath,
-                            like_arg));
+                            construct_like_arg(local_relpath, scratch_pool)));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   while (have_row)
     {
-      const char *child_relpath = svn_sqlite__column_text(stmt, 0, NULL);
-      const char *lock_token = svn_sqlite__column_text(stmt, 1, result_pool);
+      apr_int64_t child_repos_id = svn_sqlite__column_int64(stmt, 0);
+      const char *child_relpath = svn_sqlite__column_text(stmt, 1, NULL);
+      const char *lock_token = svn_sqlite__column_text(stmt, 2, result_pool);
 
-      if (lock_token)
+      if (child_repos_id != last_repos_id)
         {
-          const char *child_abspath =
-            svn_dirent_join(wcroot->abspath, child_relpath, result_pool);
-          apr_hash_set(*lock_tokens, child_abspath,
-                       APR_HASH_KEY_STRING, lock_token);
+          svn_error_t *err = fetch_repos_info(&last_repos_root_url, NULL,
+                                              wcroot->sdb, child_repos_id,
+                                              scratch_pool);
+
+          if (err)
+            {
+              return svn_error_return(
+                            svn_error_compose_create(err,
+                                                     svn_sqlite__reset(stmt)));
+            }
+
+          last_repos_id = child_repos_id;
         }
 
+      apr_hash_set(*lock_tokens,
+                   svn_path_url_add_component2(last_repos_root_url,
+                                               child_relpath,
+                                               result_pool),
+                   APR_HASH_KEY_STRING,
+                   lock_token);
+
       SVN_ERR(svn_sqlite__step(&have_row, stmt));
     }
   return svn_sqlite__reset(stmt);

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1091728&r1=1091727&r2=1091728&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Wed Apr 13 10:17:21 2011
@@ -822,9 +822,9 @@ svn_wc__db_base_clear_dav_cache_recursiv
                                           const char *local_abspath,
                                           apr_pool_t *scratch_pool);
 
-/* Set LOCK_TOKENS to a hash mapping const char * local absolute paths
- * to const char * lock tokens for every base node at or under
- * LOCAL_ABSPATH in DB which has such a lock token set on it.
+/* Set LOCK_TOKENS to a hash mapping const char * full URLs to const char *
+ * lock tokens for every base node at or under LOCAL_ABSPATH in DB which has
+ * such a lock token set on it.
  * Allocate the hash and all items therein from RESULT_POOL.  */
 svn_error_t *
 svn_wc__db_base_get_lock_tokens_recursive(apr_hash_t **lock_tokens,


Reply via email to