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/16 12:46:43 UTC

svn commit: r1103686 - in /subversion/trunk/subversion/libsvn_wc: adm_ops.c wc-queries.sql wc_db.c

Author: hwright
Date: Mon May 16 10:46:43 2011
New Revision: 1103686

URL: http://svn.apache.org/viewvc?rev=1103686&view=rev
Log:
Implement full depth filtering when populating the target list, and modify
the way we set changelists to validate this approach.

* subversion/libsvn_wc/adm_ops.c
  (changelist_walker_baton, changelist_walker): Remove.
  (svn_wc_set_changelist2): Don't use a node walker, use the target list
    instead.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_INSERT_TARGET_DEPTH_FILES,
   STMT_INSERT_TARGET_DEPTH_IMMEDIATES,
   STMT_INSERT_TARGET_DEPTH_INFINITY,
   STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_FILES,
   STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_IMMEDIATES,
   STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_INFINITY):
    New.
  (STMT_INSERT_TARGET_WITH_CHANGELIST): Reorder some params.
 
* subversion/libsvn_wc/wc_db.c
  (populate_targets_tree): Switch on the depth to determine which statement
    to execute when populating the targets list.
  (svn_wc__db_op_set_changelist): Remove restriction on depth for this
    operation.

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_ops.c
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=1103686&r1=1103685&r2=1103686&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Mon May 16 10:46:43 2011
@@ -2159,41 +2159,6 @@ svn_wc_remove_lock2(svn_wc_context_t *wc
 }
 
 
-struct changelist_walker_baton
-{
-  const char *new_changelist;
-  const apr_array_header_t *changelist_filter;
-
-  svn_wc__db_t *db;
-
-  svn_cancel_func_t cancel_func;
-  void *cancel_baton;
-  svn_wc_notify_func2_t notify_func;
-  void *notify_baton;
-};
-
-
-static svn_error_t *
-changelist_walker(const char *local_abspath,
-                  svn_node_kind_t kind,
-                  void *baton,
-                  apr_pool_t *scratch_pool)
-{
-  struct changelist_walker_baton *cwb = baton;
-
-  /* Set the changelist. */
-  SVN_ERR(svn_wc__db_op_set_changelist(cwb->db, local_abspath,
-                                       cwb->new_changelist,
-                                       cwb->changelist_filter,
-                                       svn_depth_empty,
-                                       cwb->notify_func, cwb->notify_baton,
-                                       cwb->cancel_func, cwb->cancel_baton,
-                                       scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-
 svn_error_t *
 svn_wc_set_changelist2(svn_wc_context_t *wc_ctx,
                        const char *local_abspath,
@@ -2206,21 +2171,16 @@ svn_wc_set_changelist2(svn_wc_context_t 
                        void *notify_baton,
                        apr_pool_t *scratch_pool)
 {
-  struct changelist_walker_baton cwb = { new_changelist,
-                                         changelist_filter,
-                                         wc_ctx->db,
-                                         cancel_func, cancel_baton,
-                                         notify_func, notify_baton };
-
   /* Assert that we aren't being asked to set an empty changelist. */
   SVN_ERR_ASSERT(! (new_changelist && new_changelist[0] == '\0'));
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
-  SVN_ERR(svn_wc__internal_walk_children(wc_ctx->db, local_abspath, FALSE,
-                                         NULL, changelist_walker, &cwb,
-                                         depth, cancel_func, cancel_baton,
-                                         scratch_pool));
+  SVN_ERR(svn_wc__db_op_set_changelist(wc_ctx->db, local_abspath,
+                                       new_changelist, changelist_filter,
+                                       depth, notify_func, notify_baton,
+                                       cancel_func, cancel_baton,
+                                       scratch_pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1103686&r1=1103685&r2=1103686&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Mon May 16 10:46:43 2011
@@ -448,12 +448,55 @@ INSERT INTO targets_list(wc_id, local_re
 SELECT wc_id, local_relpath, parent_relpath, kind
 FROM nodes_current WHERE wc_id = ?1 AND local_relpath = ?2
 
+-- STMT_INSERT_TARGET_DEPTH_FILES
+INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
+SELECT wc_id, local_relpath, parent_relpath, kind
+FROM nodes_current
+WHERE wc_id = ?1 AND ((parent_relpath = ?2 AND kind = 'file')
+                      OR local_relpath = ?2)
+
+-- STMT_INSERT_TARGET_DEPTH_IMMEDIATES
+INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
+SELECT wc_id, local_relpath, parent_relpath, kind
+FROM nodes_current
+WHERE wc_id = ?1 AND (parent_relpath = ?2 OR local_relpath = ?2)
+
+-- STMT_INSERT_TARGET_DEPTH_INFINITY
+INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
+SELECT wc_id, local_relpath, parent_relpath, kind
+FROM nodes_current
+WHERE wc_id = ?1 AND (local_relpath = ?2 OR local_relpath LIKE ?3 ESCAPE '#')
+
 -- STMT_INSERT_TARGET_WITH_CHANGELIST
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
 SELECT N.wc_id, 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
+ WHERE N.wc_id = ?1 AND A.changelist = ?3 AND N.local_relpath = ?2
+
+-- STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_FILES
+INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
+SELECT N.wc_id, 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 A.changelist = ?3
+       AND ((N.parent_relpath = ?2 AND kind = 'file') OR N.local_relpath = ?2)
+
+-- STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_IMMEDIATES
+INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
+SELECT N.wc_id, 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 A.changelist = ?3
+       AND (N.parent_relpath = ?2 OR N.local_relpath = ?2)
+
+-- STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_INFINITY
+INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
+SELECT N.wc_id, 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 A.changelist = ?3
+       AND (N.local_relpath = ?2 OR N.local_relpath LIKE ?4 ESCAPE '#')
 
 -- 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=1103686&r1=1103685&r2=1103686&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Mon May 16 10:46:43 2011
@@ -4962,6 +4962,13 @@ populate_targets_tree(svn_wc__db_wcroot_
                       apr_pool_t *scratch_pool)
 {
   svn_sqlite__stmt_t *stmt;
+  const char *like_arg;
+
+  if (depth == svn_depth_infinity)
+    {
+      /* Calculate a value we're going to need later. */
+      like_arg = construct_like_arg(local_relpath, scratch_pool);
+    }
 
   SVN_ERR(svn_sqlite__exec_statements(wcroot->sdb,
                                       STMT_CREATE_TARGETS_LIST));
@@ -4972,46 +4979,78 @@ populate_targets_tree(svn_wc__db_wcroot_
          Common case: we only have one changelist, so this only
          happens once. */
       int i;
+      int stmt_idx;
+
+      switch (depth)
+        {
+          case svn_depth_empty:
+            stmt_idx = STMT_INSERT_TARGET_WITH_CHANGELIST;
+            break;
+
+          case svn_depth_files:
+            stmt_idx = STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_FILES;
+            break;
+
+          case svn_depth_immediates:
+            stmt_idx = STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_IMMEDIATES;
+            break;
+
+          case svn_depth_infinity:
+            stmt_idx = STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_INFINITY;
+            break;
+
+          default:
+            /* We don't know how to handle unknown or exclude. */
+            SVN_ERR_MALFUNCTION();
+            break;
+        }
+
       for (i = 0; i < changelist_filter->nelts; i++)
         {
           const char *changelist = APR_ARRAY_IDX(changelist_filter, i,
                                                  const char *);
 
-          switch (depth)
-            {
-              case svn_depth_empty:
-                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));
-                break;
-
-              default:
-                /* Currently only defined for depth == empty */
-                SVN_ERR_MALFUNCTION();
-                break;
-            }
+          SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, stmt_idx));
+          SVN_ERR(svn_sqlite__bindf(stmt, "iss", wcroot->wc_id,
+                                    local_relpath, changelist));
+          if (depth == svn_depth_infinity)
+            SVN_ERR(svn_sqlite__bind_text(stmt, 4, like_arg));
+          SVN_ERR(svn_sqlite__step_done(stmt));
         }
     }
   else /* No changelist filtering */
     {
+      int stmt_idx;
+
       switch (depth)
         {
           case svn_depth_empty:
-            /* Insert this single path. */
-            SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                              STMT_INSERT_TARGET));
-            SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id,
-                                      local_relpath));
-            SVN_ERR(svn_sqlite__step_done(stmt));
+            stmt_idx = STMT_INSERT_TARGET;
+            break;
+
+          case svn_depth_files:
+            stmt_idx = STMT_INSERT_TARGET_DEPTH_FILES;
+            break;
+
+          case svn_depth_immediates:
+            stmt_idx = STMT_INSERT_TARGET_DEPTH_IMMEDIATES;
+            break;
+
+          case svn_depth_infinity:
+            stmt_idx = STMT_INSERT_TARGET_DEPTH_INFINITY;
             break;
 
           default:
-            /* Currently only defined for depth == empty */
+            /* We don't know how to handle unknown or exclude. */
             SVN_ERR_MALFUNCTION();
             break;
         }
+
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, stmt_idx));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+      if (depth == svn_depth_infinity)
+        SVN_ERR(svn_sqlite__bind_text(stmt, 3, like_arg));
+      SVN_ERR(svn_sqlite__step_done(stmt));
     }
 
   return SVN_NO_ERROR;
@@ -5169,7 +5208,6 @@ svn_wc__db_op_set_changelist(svn_wc__db_
                           -1 };
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
-  SVN_ERR_ASSERT(depth == svn_depth_empty);
 
   SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath,
                                                 db, local_abspath,