You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/05/15 02:51:24 UTC
svn commit: r1103260 - in /subversion/trunk/subversion/libsvn_wc:
wc-queries.sql wc_db.c
Author: hwright
Date: Sun May 15 00:51:23 2011
New Revision: 1103260
URL: http://svn.apache.org/viewvc?rev=1103260&view=rev
Log:
When populating the targets array, replace some funky C code with some
SQL that's a bit more clean and efficient.
* subversion/libsvn_wc/wc-queries.sql
(STMT_INSERT_TARGET_WITH_CHANGELIST): New.
* subversion/libsvn_wc/wc_db.c
(populate_targets_tree): Rather than filter via changelists in C,
just iterate over the changelists, inserting the nodes which match.
Modified:
subversion/trunk/subversion/libsvn_wc/wc-queries.sql
subversion/trunk/subversion/libsvn_wc/wc_db.c
Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1103260&r1=1103259&r2=1103260&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Sun May 15 00:51:23 2011
@@ -445,6 +445,13 @@ DROP TABLE IF EXISTS targets_list;
INSERT INTO targets_list(local_relpath, parent_relpath, kind)
SELECT ?2, ?3, kind FROM nodes_current WHERE wc_id = ?1 AND local_relpath = ?2
+-- STMT_INSERT_TARGET_WITH_CHANGELIST
+INSERT INTO targets_list(local_relpath, parent_relpath, kind)
+SELECT N.local_relpath, N.parent_relpath, N.kind
+ FROM actual_node AS A JOIN nodes_current AS N
+ ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath
+ WHERE N.wc_id = ?1 AND N.local_relpath = ?2 AND A.changelist = ?3
+
-- STMT_SELECT_TARGETS
SELECT local_relpath, parent_relpath from targets_list
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1103260&r1=1103259&r2=1103260&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sun May 15 00:51:23 2011
@@ -4959,55 +4959,47 @@ populate_targets_tree(svn_wc__db_wcroot_
const apr_array_header_t *changelist_filter,
apr_pool_t *scratch_pool)
{
- apr_hash_t *changelist_hash = NULL;
svn_boolean_t have_row;
svn_sqlite__stmt_t *stmt;
const char *parent_relpath;
parent_relpath = svn_relpath_dirname(local_relpath, scratch_pool);
- if (changelist_filter && changelist_filter->nelts)
- SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelist_filter,
- scratch_pool));
-
SVN_ERR(svn_sqlite__exec_statements(wcroot->sdb,
STMT_CREATE_TARGETS_LIST));
switch (depth)
{
case svn_depth_empty:
- if (changelist_hash)
+ if (changelist_filter && changelist_filter->nelts > 0)
{
- const char *changelist;
+ /* Iterate over the changelists, adding the nodes which match.
+ Common case: we only have one changelist, so this only
+ happens once. */
- SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
- STMT_SELECT_ACTUAL_CHANGELIST));
- SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id,
- local_relpath));
- SVN_ERR(svn_sqlite__step(&have_row, stmt));
- changelist = svn_sqlite__column_text(stmt, 0, scratch_pool);
- SVN_ERR(svn_sqlite__reset(stmt));
+ int i;
- if (changelist == NULL)
+ for (i = 0; i < changelist_filter->nelts; i++)
{
- /* No changelist, so return. */
- return SVN_NO_ERROR;
- }
+ const char *changelist = APR_ARRAY_IDX(changelist_filter, i,
+ const char *);
- if (apr_hash_get(changelist_hash, changelist,
- APR_HASH_KEY_STRING) == NULL)
- {
- /* Changelist exists, but doesn't match. */
- return SVN_NO_ERROR;
+ SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+ STMT_INSERT_TARGET_WITH_CHANGELIST));
+ SVN_ERR(svn_sqlite__bindf(stmt, "iss", wcroot->wc_id,
+ local_relpath, changelist));
+ SVN_ERR(svn_sqlite__step_done(stmt));
}
}
-
- /* Insert this single path. */
- SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
- STMT_INSERT_TARGET));
- SVN_ERR(svn_sqlite__bindf(stmt, "iss", wcroot->wc_id, local_relpath,
- parent_relpath));
- SVN_ERR(svn_sqlite__step_done(stmt));
+ else
+ {
+ /* Insert this single path. */
+ SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+ STMT_INSERT_TARGET));
+ SVN_ERR(svn_sqlite__bindf(stmt, "iss", wcroot->wc_id,
+ local_relpath, parent_relpath));
+ SVN_ERR(svn_sqlite__step_done(stmt));
+ }
break;