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/15 14:43:57 UTC

svn commit: r1092686 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c wc_db.h workqueue.c

Author: rhuijben
Date: Fri Apr 15 12:43:56 2011
New Revision: 1092686

URL: http://svn.apache.org/viewvc?rev=1092686&view=rev
Log:
Replace an ugly, outdated hack in the commit processor by a 'simple'
recursive sql statement in the commit transaction.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_REPLACED_CHILDREN_FOR_DELETION): Remove query.
  (STMT_DELETE_SHADOWED_RECURSIVE): New query.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_read_replaced_children): Remove function.
  (commit_node): When committing a shadowing operation, remove child
    nodes that are now invalid.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_read_replaced_children): Remove function.

* subversion/libsvn_wc/workqueue.c
  (log_do_committed): Remove the replacement delete hack.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h
    subversion/trunk/subversion/libsvn_wc/workqueue.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=1092686&r1=1092685&r2=1092686&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Fri Apr 15 12:43:56 2011
@@ -162,13 +162,15 @@ UNION
 SELECT 1 FROM ACTUAL_NODE
 WHERE wc_id = ?1 AND parent_relpath = ?2
 
--- STMT_SELECT_REPLACED_CHILDREN_FOR_DELETION
-SELECT local_relpath FROM nodes
-WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth <= ?3
-  AND presence = 'base-deleted'
-  AND local_relpath NOT IN (
-    SELECT local_relpath FROM nodes
-    WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth > ?3)
+-- STMT_DELETE_SHADOWED_RECURSIVE
+DELETE FROM nodes
+WHERE wc_id = ?1 AND (local_relpath = ?2 OR local_relpath LIKE ?3 ESCAPE '#')
+  AND (op_depth < ?4
+       OR (presence = 'base-deleted'
+           AND op_depth = (SELECT MIN(op_depth) FROM nodes f
+                           WHERE f.wc_id = nodes.wc_id 
+                             AND f.local_relpath = nodes.local_relpath
+                             AND f.op_depth >= ?4)))
 
 -- STMT_SELECT_NODE_CHILDREN
 /* Return all paths that are children of the directory (?1, ?2) in any

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1092686&r1=1092685&r2=1092686&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri Apr 15 12:43:56 2011
@@ -6289,61 +6289,6 @@ svn_wc__db_read_children_of_working_node
                           result_pool, scratch_pool);
 }
 
-
-svn_error_t *
-svn_wc__db_read_replaced_children(const apr_array_header_t **children,
-                                  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;
-  apr_int64_t op_depth;
-  svn_sqlite__stmt_t *stmt;
-  svn_boolean_t have_row;
-  apr_array_header_t *result
-    = apr_array_make(result_pool, 0, sizeof(const char *));
-
-  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);
-
-  /* Gather deleted children with smaller or equal op_depth as this
-   * added node, for which no rows with greater op_depth exist.
-   *
-   * Any such children were deleted as part of a replace operation -- either
-   * on this directory (equal op_depth), or a parent directory (smaller
-   * op_depth; this implies that this added node is a nested replacement).
-   * Children deleted post-replace have a higher op_depth.
-   *
-   * It's OK if we find no children -- either this was a plain addition,
-   * or the replaced directory was empty. */
-  SVN_ERR(op_depth_of(&op_depth, wcroot, local_relpath));
-  SVN_ERR(svn_sqlite__get_statement(
-            &stmt, wcroot->sdb, STMT_SELECT_REPLACED_CHILDREN_FOR_DELETION));
-  SVN_ERR(svn_sqlite__bindf(stmt, "isi", wcroot->wc_id, local_relpath,
-                            op_depth));
-  SVN_ERR(svn_sqlite__step(&have_row, stmt));
-  while (have_row)
-    {
-      const char *child_relpath = svn_sqlite__column_text(stmt, 0, NULL);
-
-      /* Allocate the name in RESULT_POOL so we won't have to copy it. */
-      APR_ARRAY_PUSH(result, const char *)
-        = svn_relpath_basename(child_relpath, result_pool);
-
-      SVN_ERR(svn_sqlite__step(&have_row, stmt));
-    }
-  SVN_ERR(svn_sqlite__reset(stmt));
-
-  *children = result;
-  return SVN_NO_ERROR;
-}
-
 /* Baton for check_replace_txn */
 struct check_replace_baton
 {
@@ -6867,7 +6812,26 @@ commit_node(void *baton,
   SVN_ERR(svn_sqlite__reset(stmt_info));
   SVN_ERR(svn_sqlite__reset(stmt_act));
 
-  /* Update the BASE_NODE row with all the new information.  */
+  /* Do we commit a shadowing operation? */
+  if (op_depth > 0)
+    {
+      svn_sqlite__stmt_t *delete_stmt;
+
+      SVN_ERR(svn_sqlite__get_statement(&delete_stmt, wcroot->sdb,
+                                        STMT_DELETE_SHADOWED_RECURSIVE));
+
+      SVN_ERR(svn_sqlite__bindf(delete_stmt,
+                                "issi", 
+                                wcroot->wc_id,
+                                local_relpath,
+                                construct_like_arg(local_relpath,
+                                                   scratch_pool),
+                                op_depth));
+
+      SVN_ERR(svn_sqlite__step_done(delete_stmt));
+    }
+
+  /* Update or add the BASE_NODE row with all the new information.  */
 
   if (*local_relpath == '\0')
     parent_relpath = NULL;
@@ -6904,7 +6868,10 @@ commit_node(void *baton,
   if (op_depth > 0)
     {
       /* This removes all op_depth > 0 and so does both layers of a
-         two-layer replace. */
+         two-layer replace. 
+
+         Do this now, or we will remove the newly added base node. */
+
       SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                         STMT_DELETE_ALL_WORKING_NODES));
       SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
@@ -6958,12 +6925,6 @@ commit_node(void *baton,
       SVN_ERR(svn_sqlite__step_done(lock_stmt));
     }
 
-  if (op_depth > 0)
-    {
-      /* ### Remove all nodes of children with op_depth < 0
-         ### (and then potentially left over base-deleteds) */
-    }
-
   /* Install any work items into the queue, as part of this transaction.  */
   SVN_ERR(add_work_items(wcroot->sdb, cb->work_items, scratch_pool));
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1092686&r1=1092685&r2=1092686&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Fri Apr 15 12:43:56 2011
@@ -1711,31 +1711,6 @@ svn_wc__db_read_children_of_working_node
                                          apr_pool_t *result_pool,
                                          apr_pool_t *scratch_pool);
 
-/* Set *CHILDREN to a new array of the (const char *) basenames of the
-   immediate children of the working node at LOCAL_ABSPATH in DB which
-   where deleted as part of a replacement.
-
-   Return every path that refers to a child of the working node at
-   LOCAL_ABSPATH. Do not include paths that were not deleted due to
-   the replacement of LOCAL_ABSPATH.
-
-   ### This function is used during post-commit processing of replaced
-   ### directories and should probably not be called from elsewhere.
-   ### No attempt is made to verify that LOCAL_ABSPATH has in fact been
-   ### replaced. This allows the post-commit code to traverse the replaced
-   ### tree top-down and delete parent nodes from the DB before their
-   ### children have been removed (scan_addition() would fail in this case
-   ### since parent nodes, including the op_root, have disappeared).
-
-   Allocate *CHILDREN in RESULT_POOL and do temporary allocations in
-   SCRATCH_POOL. */
-svn_error_t *
-svn_wc__db_read_replaced_children(const apr_array_header_t **children,
-                                  svn_wc__db_t *db,
-                                  const char *local_abspath,
-                                  apr_pool_t *result_pool,
-                                  apr_pool_t *scratch_pool);
-
 /* Like svn_wc__db_read_children_of_working_node(), except also include any
    path that was a child of a deleted directory that existed at
    LOCAL_ABSPATH, even if that directory is now scheduled to be replaced by

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=1092686&r1=1092685&r2=1092686&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Fri Apr 15 12:43:56 2011
@@ -631,74 +631,6 @@ log_do_committed(svn_wc__db_t *db,
 
   /*** Mark the committed item committed-to-date ***/
 
-  /* ### this comment is quite old. originally, we looked for
-     ### schedule_replace here. that definition is:
-     ###
-     ### ((status == svn_wc__db_status_added
-     ###   || status == svn_wc__db_status_obstructed_add)
-     ###  && base_shadowed
-     ###  && base_status != svn_wc__db_status_not_present)
-     ###
-     ### An obstructed add cannot be committed, so we don't have to
-     ### worry about that.
-     ###
-     ### If the BASE node is not-present, then it has no children which
-     ### may be marked for deletion, so that won't contribute to this
-     ### loop either (ie. we won't accidentally remove something)
-     ###
-     ### Thus, we're simply looking for status == svn_wc__db_status_added
-
-     If "this dir" has been replaced (delete + add), remove those of
-     its children that were marked for deletion as part of the replace
-     operation of "this dir".
-
-     All its immmediate children *must* be either scheduled for deletion
-     (they were children of "this dir" during the "delete" phase of its
-     replacement, in which case we delete them, or they were deleted
-     post-replace, in which case we leave them alone),
-     added (they are new children of the replaced dir),
-     or replaced (they are new children of the replace dir that have
-     the same names as children that were present during the "delete"
-     phase of the replacement).
-
-     Children which are added, or replaced, or deleted post-replace, will
-     have been reported as individual commit targets, and thus will be
-     re-visited by log_do_committed().  Children which were marked for
-     deletion as part of the replacement of "this dir", however, need to
-     be outright removed from revision control.  */
-
-  if (status == svn_wc__db_status_added && kind == svn_wc__db_kind_dir)
-    {
-      /* Loop over all replaced children. */
-      const apr_array_header_t *children;
-      int i;
-      apr_pool_t *iterpool = svn_pool_create(pool);
-
-      /* ### We should probably have a function that recursively deletes
-       * ### these children, instead of just listing them. */
-      SVN_ERR(svn_wc__db_read_replaced_children(&children, db, local_abspath,
-                                                pool, pool));
-
-      for (i = 0; i < children->nelts; i++)
-        {
-          const char *child_name = APR_ARRAY_IDX(children, i, const char*);
-          const char *child_abspath;
-
-          svn_pool_clear(iterpool);
-          child_abspath = svn_dirent_join(local_abspath, child_name, iterpool);
-
-          /* Committing a deletion should remove the local nodes.  */
-          SVN_ERR(svn_wc__internal_remove_from_revision_control(
-                    db, child_abspath,
-                    FALSE /* destroy_wf */,
-                    FALSE /* instant_error */,
-                    cancel_func, cancel_baton,
-                    iterpool));
-        }
-
-      svn_pool_destroy(iterpool);
-    }
-
   /* Install the node's current working props as its new base props.
    * Remember some details about the prop changes, for later use. */
   if (prop_mods)