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/13 12:17:22 UTC

svn commit: r1091728 - in /subversion/trunk/subversion: include/private/svn_wc_private.h libsvn_client/commit_util.c libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db.h

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,



Re: svn commit: r1091728 - in /subversion/trunk/subversion: include/private/svn_wc_private.h libsvn_client/commit_util.c libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db.h

Posted by Greg Stein <gs...@gmail.com>.
On Wed, Apr 13, 2011 at 15:07, Bert Huijben <be...@qqmail.nl> wrote:
>
>
>> -----Original Message-----
>> From: Greg Stein [mailto:gstein@gmail.com]
>> Sent: woensdag 13 april 2011 20:30
>> To: dev@subversion.apache.org
>> Subject: Re: svn commit: r1091728 - in /subversion/trunk/subversion:
>> include/private/svn_wc_private.h libsvn_client/commit_util.c libsvn_wc/wc-
>> queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db.h
>>
>> On Wed, Apr 13, 2011 at 06:17,  <rh...@apache.org> wrote:
>> >...
>> > +++ 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))
>>
>> This loop can be removed in favor of apr_hash_overlay().
>
> /**
>  * Merge two hash tables into one new hash table. The values of the overlay
>  * hash override the values of the base if both have the same key.  Both
>  * hash tables must use the same hash function.
>  * @param p The pool to use for the new hash table
>  * @param overlay The table to add to the initial table
>  * @param base The table that represents the initial values of the new table
>  * @return A new hash table containing all of the data from the two passed
> in
>  */
> APR_DECLARE(apr_hash_t *) apr_hash_overlay(apr_pool_t *p,
>                                           const apr_hash_t *overlay,
>                                           const apr_hash_t *base);
>
> This function returns a new apr_hash_t *, while the caller of this function
> expects us to update the existing hashtable.

Ah! Good point. Thanks!

RE: svn commit: r1091728 - in /subversion/trunk/subversion: include/private/svn_wc_private.h libsvn_client/commit_util.c libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db.h

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: Greg Stein [mailto:gstein@gmail.com]
> Sent: woensdag 13 april 2011 20:30
> To: dev@subversion.apache.org
> Subject: Re: svn commit: r1091728 - in /subversion/trunk/subversion:
> include/private/svn_wc_private.h libsvn_client/commit_util.c libsvn_wc/wc-
> queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db.h
> 
> On Wed, Apr 13, 2011 at 06:17,  <rh...@apache.org> wrote:
> >...
> > +++ 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))
> 
> This loop can be removed in favor of apr_hash_overlay().

/**
 * Merge two hash tables into one new hash table. The values of the overlay
 * hash override the values of the base if both have the same key.  Both
 * hash tables must use the same hash function.
 * @param p The pool to use for the new hash table
 * @param overlay The table to add to the initial table
 * @param base The table that represents the initial values of the new table
 * @return A new hash table containing all of the data from the two passed
in
 */
APR_DECLARE(apr_hash_t *) apr_hash_overlay(apr_pool_t *p,
                                           const apr_hash_t *overlay, 
                                           const apr_hash_t *base);

This function returns a new apr_hash_t *, while the caller of this function
expects us to update the existing hashtable.

	Bert


Re: svn commit: r1091728 - in /subversion/trunk/subversion: include/private/svn_wc_private.h libsvn_client/commit_util.c libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db.h

Posted by Greg Stein <gs...@gmail.com>.
On Wed, Apr 13, 2011 at 06:17,  <rh...@apache.org> wrote:
>...
> +++ 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))

This loop can be removed in favor of apr_hash_overlay().

>...

Cheers,
-g