Author: cmpilato
Date: Mon Mar 21 18:51:02 2011
New Revision: 1083896
URL: http://svn.apache.org/viewvc?rev=1083896&view=rev
Log:
Eliminate another node walk, this time in the commit item harvesting
logic (specifically, the collection of lock tokens stored in the
working copy).
* subversion/libsvn_wc/wc-queries.sql
(STMT_SELECT_BASE_NODE_LOCK_TOKENS_RECURSIVE): New query.
* subversion/include/private/svn_wc_private.h,
* subversion/libsvn_wc/node.c
(svn_wc__node_get_lock_tokens_recursive): New function.
* subversion/libsvn_wc/wc_db.h,
* subversion/libsvn_wc/wc_db.c
(svn_wc__db_base_get_lock_tokens_recursive): New function.
* subversion/libsvn_client/commit_util.c
(struct add_lock_token_baton, add_lock_token): Remove as unused.
(harvest_committables): Use svn_wc__node_get_lock_tokens_recursive()
instead of an svn_wc__node_walk_children() callback system to fetch
lock tokens.
* notes/wc_node_walkers.txt
Remove this instance of a node walk.
Modified:
subversion/trunk/notes/wc_node_walkers.txt
subversion/trunk/subversion/include/private/svn_wc_private.h
subversion/trunk/subversion/libsvn_client/commit_util.c
subversion/trunk/subversion/libsvn_wc/node.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/notes/wc_node_walkers.txt
URL:
http://svn.apache.org/viewvc/subversion/trunk/notes/wc_node_walkers.txt?rev=1083896&r1=1083895&r2=1083896&view=diff
==============================================================================
--- subversion/trunk/notes/wc_node_walkers.txt (original)
+++ subversion/trunk/notes/wc_node_walkers.txt Mon Mar 21 18:51:02 2011
@@ -25,12 +25,6 @@ subversion/libsvn_client/changelist.c
svn_client_get_changelists() - Drive callback to report all
changelist associations in a tree up to a specified depth.
-subversion/libsvn_client/commit_util.c
-
- harvest_committables() - Crawl a tree to infinite depth harvesting
- lock tokens for storage in a hash thereof used during the commit
- process. No notifications.
-
subversion/libsvn_client/info.c
crawl_entries() - Crawl a tree (up to specified depth) driving an
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=1083896&r1=1083895&r2=1083896&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Mon Mar 21
18:51:02 2011
@@ -807,6 +807,20 @@ svn_wc__node_clear_dav_cache_recursive(s
const char *local_abspath,
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.
+ */
+svn_error_t *
+svn_wc__node_get_lock_tokens_recursive(apr_hash_t **lock_tokens,
+ svn_wc_context_t *wc_ctx,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
/* Set @ *min_revision and @ *max_revision to the lowest and highest revision
* numbers found within @a local_abspath, using context @a wc_ctx.
* If @ committed is TRUE, set @a *min_revision and @a *max_revision
Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1083896&r1=1083895&r2=1083896&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Mon Mar 21 18:51:02
2011
@@ -190,44 +190,6 @@ look_up_committable(apr_hash_t *committa
return NULL;
}
-/* Baton for add_lock_token() */
-struct add_lock_token_baton
-{
- apr_hash_t *lock_tokens;
- svn_wc_context_t *wc_ctx;
-};
-
-/* This implements the svn_wc__node_found_func_t interface. */
-static svn_error_t *
-add_lock_token(const char *local_abspath,
- svn_node_kind_t kind,
- void *walk_baton,
- apr_pool_t *scratch_pool)
-{
- struct add_lock_token_baton *altb = walk_baton;
- apr_pool_t *token_pool = apr_hash_pool_get(altb->lock_tokens);
- const char *lock_token;
- const char *url;
-
- /* I want every lock-token I can get my dirty hands on!
- If this entry is switched, so what. We will send an irrelevant lock
- token. */
- SVN_ERR(svn_wc__node_get_lock_info(&lock_token, NULL, NULL, NULL,
- altb->wc_ctx, local_abspath,
- scratch_pool, scratch_pool));
- if (!lock_token)
- return SVN_NO_ERROR;
-
- SVN_ERR(svn_wc__node_get_url(&url, altb->wc_ctx, local_abspath,
- token_pool, scratch_pool));
- if (url)
- apr_hash_set(altb->lock_tokens, url,
- APR_HASH_KEY_STRING,
- apr_pstrdup(token_pool, lock_token));
-
- return SVN_NO_ERROR;
-}
-
/* Helper for harvest_committables().
* If ENTRY is a dir, return an SVN_ERR_WC_FOUND_CONFLICT error when
* encountering a tree-conflicted immediate child node. However, do
@@ -835,19 +797,29 @@ harvest_committables(apr_hash_t *committ
if (lock_tokens && db_kind == svn_node_dir
&& (state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE))
{
- struct add_lock_token_baton altb;
- altb.wc_ctx = ctx->wc_ctx;
- altb.lock_tokens = lock_tokens;
-
- SVN_ERR(svn_wc__node_walk_children(ctx->wc_ctx,
- local_abspath,
- FALSE,
- add_lock_token,
- &altb,
- svn_depth_infinity,
- ctx->cancel_func,
- ctx->cancel_baton,
- scratch_pool));
+ apr_hash_t *local_relpath_tokens;
+ apr_hash_index_t *hi;
+
+ SVN_ERR(svn_wc__node_get_lock_tokens_recursive(
+ &local_relpath_tokens, ctx->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);
+
+ SVN_ERR(svn_wc__node_get_url(&item_url, ctx->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=1083896&r1=1083895&r2=1083896&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/node.c (original)
+++ subversion/trunk/subversion/libsvn_wc/node.c Mon Mar 21 18:51:02 2011
@@ -1532,3 +1532,16 @@ svn_wc__node_clear_dav_cache_recursive(s
return svn_error_return(svn_wc__db_base_clear_dav_cache_recursive(
wc_ctx->db, local_abspath, scratch_pool));
}
+
+
+svn_error_t *
+svn_wc__node_get_lock_tokens_recursive(apr_hash_t **lock_tokens,
+ svn_wc_context_t *wc_ctx,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ return svn_error_return(svn_wc__db_base_get_lock_tokens_recursive(
+ lock_tokens, wc_ctx->db, local_abspath,
+ result_pool, scratch_pool));
+}
Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1083896&r1=1083895&r2=1083896&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Mon Mar 21 18:51:02
2011
@@ -229,6 +229,14 @@ INSERT OR REPLACE INTO lock
lock_date)
VALUES (?1, ?2, ?3, ?4, ?5, ?6)
+-- STMT_SELECT_BASE_NODE_LOCK_TOKENS_RECURSIVE
+SELECT local_relpath, lock_token
+FROM nodes
+LEFT OUTER 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 '#')
+
-- STMT_INSERT_WCROOT
INSERT INTO wcroot (local_abspath)
VALUES (?1)
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1083896&r1=1083895&r2=1083896&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Mon Mar 21 18:51:02 2011
@@ -9885,3 +9885,52 @@ svn_wc__db_revision_status(svn_revnum_t
revision_status_txn, &rsb,
scratch_pool));
}
+
+
+svn_error_t *
+svn_wc__db_base_get_lock_tokens_recursive(apr_hash_t **lock_tokens,
+ svn_wc__db_t *db,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ svn_wc__db_wcroot_t *wcroot;
+ const char *local_relpath;
+ const char *like_arg;
+ svn_sqlite__stmt_t *stmt;
+ svn_boolean_t have_row;
+
+ SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+ SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath,
+ db, local_abspath,
+ scratch_pool, scratch_pool));
+ VERIFY_USABLE_WCROOT(wcroot);
+
+ *lock_tokens = apr_hash_make(result_pool);
+
+ /* Fetch all the lock tokens in and under LOCAL_RELPATH. */
+ 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));
+ 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);
+
+ if (lock_token)
+ {
+ 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_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=1083896&r1=1083895&r2=1083896&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Mon Mar 21 18:51:02 2011
@@ -822,6 +822,16 @@ 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.
+ * 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,
+ svn_wc__db_t *db,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
/* ### how to handle depth? empty != absent. thus, record depth on each
### directory? empty, files, immediates, infinity. recording depth