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/21 15:40:42 UTC

svn commit: r1095704 - in /subversion/trunk/subversion: libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c tests/cmdline/diff_tests.py

Author: rhuijben
Date: Thu Apr 21 13:40:42 2011
New Revision: 1095704

URL: http://svn.apache.org/viewvc?rev=1095704&view=rev
Log:
Don't install garbage in unrelevant columns of base-deleted nodes. To obtain
this data callers should really look at the right layer.

Welcome to the WC-NG world, svn_wc_entry_t has left the building.

Marking a diff test that relied on this behavior as work in progress.
(I assume it will be fixed in a few hours)

* subversion/libsvn_wc/wc-queries.sql
  (STMT_UPDATE_NODE_WORKING_PRESENCE): Callers should provide an explicit
    depth.
  (STMT_INSERT_WORKING_NODE_FROM_BASE): Rename to ...
  (STMT_INSTALL_WORKING_NODE_FOR_DELETE): ... this and only copy relevant data.
  (STMT_UPDATE_COPYFROM_TO_INHERIT): Rename to ...
  (STMT_UPDATE_WORKING_TO_DELETED): ... this and clear out unrelevant data.

* subversion/libsvn_wc/wc_db.c
  (extend_parent_delete): Update caller.
  (info_below_working): Update prototype to allow specifying the op_depth to
    look below.
  (db_working_insert): Only perform base-delete specific transformations for
    base-delete. Clear out information in deletes.
  (db_working_update_presence): Ensure that we are updating the right layer, by
    removing the assumption that we will only update the top layer.
    When a node is turned into a delete clear all the pristine values instead
    of just the copyfrom information.

* subversion/tests/cmdline/diff_tests.py
  (diff_schedule_delete): Mark as @XFail() + comment, because I don't get
    a @Wimp() marker working.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/tests/cmdline/diff_tests.py

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1095704&r1=1095703&r2=1095704&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Thu Apr 21 13:40:42 2011
@@ -569,10 +569,9 @@ UPDATE nodes SET presence = ?3
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
 
 -- STMT_UPDATE_NODE_WORKING_PRESENCE
-UPDATE nodes SET presence = ?3
+UPDATE nodes SET presence = ?4
 WHERE wc_id = ?1 AND local_relpath = ?2
-  AND op_depth = (SELECT MAX(op_depth) FROM nodes
-                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0)
+  AND op_depth = ?3
 
 -- STMT_UPDATE_BASE_NODE_PRESENCE_REVNUM_AND_REPOS_PATH
 UPDATE nodes SET presence = ?3, revision = ?4, repos_path = ?5
@@ -695,14 +694,12 @@ INSERT OR REPLACE INTO nodes (
 VALUES (?1, ?2, 0,
         ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16)
 
--- STMT_INSERT_WORKING_NODE_FROM_BASE
+-- STMT_INSTALL_WORKING_NODE_FOR_DELETE
 INSERT OR REPLACE INTO nodes (
-    wc_id, local_relpath, op_depth, parent_relpath, presence, kind, checksum,
-    changed_revision, changed_date, changed_author, depth, symlink_target,
-    translated_size, last_mod_time, properties)
-SELECT wc_id, local_relpath, ?3 /*op_depth*/, parent_relpath, ?4 /*presence*/,
-       kind, checksum, changed_revision, changed_date, changed_author, depth,
-       symlink_target, translated_size, last_mod_time, properties
+    wc_id, local_relpath, op_depth,
+    parent_relpath, presence, kind)
+SELECT wc_id, local_relpath, ?3 /*op_depth*/,
+       parent_relpath, ?4 /*presence*/, kind
 FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
 
@@ -787,15 +784,14 @@ DELETE FROM nodes
 WHERE wc_id = ?1 AND local_relpath LIKE ?2 ESCAPE '#' AND op_depth > ?3
   AND presence NOT IN ('base-deleted', 'not-present')
 
-
--- STMT_UPDATE_COPYFROM_TO_INHERIT
+-- STMT_UPDATE_WORKING_TO_DELETED
 UPDATE nodes SET
-  repos_id = NULL,
-  repos_path = NULL,
-  revision = NULL
-WHERE wc_id = ?1 AND local_relpath = ?2
-  AND op_depth = (SELECT MAX(op_depth) FROM nodes
-                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0)
+  repos_id = NULL, repos_path = NULL, revision = NULL,
+  moved_here = NULL, depth = NULL, properties = NULL,
+  symlink_target = NULL, checksum = NULL,
+  changed_revision = NULL, changed_date = NULL, changed_author = NULL,
+  translated_size = NULL, last_mod_time = NULL
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
 
 -- STMT_DETERMINE_WHICH_TREES_EXIST
 SELECT op_depth FROM nodes WHERE wc_id = ?1 AND local_relpath = ?2

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1095704&r1=1095703&r2=1095704&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Apr 21 13:40:42 2011
@@ -715,7 +715,7 @@ extend_parent_delete(svn_wc__db_wcroot_t
       if (!have_row || parent_op_depth < op_depth)
         {
           SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                          STMT_INSERT_WORKING_NODE_FROM_BASE));
+                                        STMT_INSTALL_WORKING_NODE_FOR_DELETE));
           SVN_ERR(svn_sqlite__bindf(stmt, "isit", wcroot->wc_id,
                                     local_relpath, parent_op_depth,
                                     presence_map,
@@ -4603,6 +4603,7 @@ info_below_working(svn_boolean_t *have_b
                    svn_wc__db_status_t *status,
                    svn_wc__db_wcroot_t *wcroot,
                    const char *local_relpath,
+                   apr_int64_t below_op_depth, /* < 0 is ignored */
                    apr_pool_t *scratch_pool);
 
 
@@ -4618,8 +4619,8 @@ db_working_update_presence(apr_int64_t o
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_UPDATE_NODE_WORKING_PRESENCE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "ist", wcroot->wc_id, local_relpath,
-                            presence_map, status));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isit", wcroot->wc_id, local_relpath,
+                            op_depth, presence_map, status));
   SVN_ERR(svn_sqlite__step_done(stmt));
 
   if (status == svn_wc__db_status_base_deleted)
@@ -4653,7 +4654,8 @@ db_working_update_presence(apr_int64_t o
 
           child_relpath = svn_relpath_join(local_relpath, name, iterpool);
           SVN_ERR(info_below_working(&below_base, &below_work, &below_status,
-                                     wcroot, child_relpath, iterpool));
+                                     wcroot, child_relpath, op_depth,
+                                     iterpool));
           if ((below_base || below_work)
               && (below_status == svn_wc__db_status_normal
                   || below_status == svn_wc__db_status_added
@@ -4667,15 +4669,15 @@ db_working_update_presence(apr_int64_t o
         }
       svn_pool_destroy(iterpool);
 
-      /* Reset the copyfrom in case this was a copy.
-         ### What else should be reset? Properties? Or copy the node again? */
+      /* Reset information that does not apply to deleted */
       SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                        STMT_UPDATE_COPYFROM_TO_INHERIT));
-      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+                                        STMT_UPDATE_WORKING_TO_DELETED));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isi", wcroot->wc_id, local_relpath,
+                                op_depth));
       SVN_ERR(svn_sqlite__step_done(stmt));
     }
-
-  /* ### Should the switch to not-present remove an ACTUAL row? */
+  else
+    SVN_ERR_MALFUNCTION();
 
   return SVN_NO_ERROR;
 }
@@ -4786,20 +4788,31 @@ db_working_insert(svn_wc__db_status_t st
                             local_relpath, op_depth, presence_map, status));
   SVN_ERR(svn_sqlite__insert(NULL, stmt));
 
-  /* Need to update the op_depth of all deleted child trees -- this
-     relies on the recursion having already deleted the trees so
-     that they are all at op_depth+1.
-
-     ### Rewriting the op_depth means that the number of queries is
-     ### O(depth^2).  Fix it by implementing svn_wc__db_op_delete so
-     ### that the recursion gets moved from adm_ops.c to wc_db.c and
-     ### one transaction does the whole tree and thus each op_depth
-     ### only gets written once. */
-  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                    STMT_UPDATE_OP_DEPTH_REDUCE_RECURSIVE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "isi",
-                            wcroot->wc_id, like_arg, op_depth + 1));
-  SVN_ERR(svn_sqlite__update(NULL, stmt));
+  if (status == svn_wc__db_status_base_deleted)
+    {
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                        STMT_UPDATE_WORKING_TO_DELETED));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isi", wcroot->wc_id, local_relpath,
+                                op_depth));
+      SVN_ERR(svn_sqlite__update(NULL, stmt));
+
+      /* Need to update the op_depth of all deleted child trees -- this
+         relies on the recursion having already deleted the trees so
+         that they are all at op_depth+1.
+    
+         ### Rewriting the op_depth means that the number of queries is
+         ### O(depth^2).  Fix it by implementing svn_wc__db_op_delete so
+         ### that the recursion gets moved from adm_ops.c to wc_db.c and
+         ### one transaction does the whole tree and thus each op_depth
+         ### only gets written once. */
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                        STMT_UPDATE_OP_DEPTH_REDUCE_RECURSIVE));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isi",
+                                wcroot->wc_id, like_arg, op_depth + 1));
+      SVN_ERR(svn_sqlite__update(NULL, stmt));
+    }
+  else
+    SVN_ERR_MALFUNCTION();
 
   return SVN_NO_ERROR;
 }
@@ -4876,15 +4889,18 @@ convert_to_working_status(svn_wc__db_sta
 }
 
 
-/* Return the status of the node, if any, below the "working" node.
+/* Return the status of the node, if any, below the "working" node (or
+   below BELOW_OP_DEPTH if >= 0).
    Set *HAVE_BASE or *HAVE_WORK to indicate if a base node or lower
-   working node is present, and *STATUS to the status of the node. */
+   working node is present, and *STATUS to the status of the first
+   layer below the selected node. */
 static svn_error_t *
 info_below_working(svn_boolean_t *have_base,
                    svn_boolean_t *have_work,
                    svn_wc__db_status_t *status,
                    svn_wc__db_wcroot_t *wcroot,
                    const char *local_relpath,
+                   apr_int64_t below_op_depth,
                    apr_pool_t *scratch_pool)
 {
   svn_sqlite__stmt_t *stmt;
@@ -4897,6 +4913,15 @@ info_below_working(svn_boolean_t *have_b
                                     STMT_SELECT_NODE_INFO));
   SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+  if (below_op_depth >= 0)
+    {
+      while (have_row && 
+             (svn_sqlite__column_int64(stmt, 0) > below_op_depth))
+        {
+          SVN_ERR(svn_sqlite__step(&have_row, stmt));
+        }
+    }
   if (have_row)
     {
       SVN_ERR(svn_sqlite__step(&have_row, stmt));
@@ -4977,7 +5002,7 @@ temp_op_delete_txn(void *baton,
           svn_wc__db_status_t below_status;
 
           SVN_ERR(info_below_working(&below_base, &below_work, &below_status,
-                                     wcroot, local_relpath, scratch_pool));
+                                     wcroot, local_relpath, -1, scratch_pool));
 
           if ((below_base || below_work)
               && below_status != svn_wc__db_status_not_present
@@ -10280,7 +10305,7 @@ svn_wc__db_info_below_working(svn_boolea
                               local_abspath, scratch_pool, scratch_pool));
   VERIFY_USABLE_WCROOT(wcroot);
   SVN_ERR(info_below_working(have_base, have_work, status,
-                             wcroot, local_relpath, scratch_pool));
+                             wcroot, local_relpath, -1, scratch_pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/tests/cmdline/diff_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/diff_tests.py?rev=1095704&r1=1095703&r2=1095704&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/diff_tests.py Thu Apr 21 13:40:42 2011
@@ -2138,6 +2138,9 @@ def diff_property_changes_to_base(sbox):
   svntest.actions.run_and_verify_svn(None, expected, [],
                                      'diff', '-r', 'BASE:1')
 
+# This test assumes garbage data in deleted nodes of WC-NG
+# BH: Working on a proper fix for this issue
+@XFail() # Should be fixed in the next couple of hours
 def diff_schedule_delete(sbox):
   "scheduled deleted"