You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2013/03/14 18:59:24 UTC

svn commit: r1456577 - in /subversion/trunk/subversion: libsvn_wc/wc-queries.sql libsvn_wc/wc_db_update_move.c tests/libsvn_wc/op-depth-test.c

Author: philip
Date: Thu Mar 14 17:59:24 2013
New Revision: 1456577

URL: http://svn.apache.org/r1456577
Log:
Fix issue 4336, move-update needs to leave base-deleted rows.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_DELETE_NO_LOWER_LAYER, STMT_REPLACE_WITH_BASE_DELETED): New.

* subversion/libsvn_wc/wc_db_update_move.c
  (tc_editor_delete): Use new queries when a lower layer is present.

* subversion/tests/libsvn_wc/op-depth-test.c
  (test_funcs): Mark move_retract PASS.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c
    subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.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=1456577&r1=1456576&r2=1456577&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Thu Mar 14 17:59:24 2013
@@ -919,6 +919,27 @@ INSERT OR REPLACE INTO nodes (
     parent_relpath, presence, kind)
 VALUES(?1, ?2, ?3, ?4, MAP_BASE_DELETED, ?5)
 
+-- STMT_DELETE_NO_LOWER_LAYER
+DELETE FROM nodes
+ WHERE wc_id = ?1
+   AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+   AND op_depth = ?3
+   AND NOT EXISTS (SELECT 1 FROM nodes n
+                    WHERE n.wc_id = ?1
+                    AND n.local_relpath = nodes.local_relpath
+                    AND n.op_depth = ?4
+                    AND n.presence IN (MAP_NORMAL, MAP_INCOMPLETE))
+
+-- STMT_REPLACE_WITH_BASE_DELETED
+INSERT OR REPLACE INTO nodes (wc_id, local_relpath, op_depth, parent_relpath,
+                              kind, moved_to, presence)
+SELECT wc_id, local_relpath, op_depth, parent_relpath,
+       kind, moved_to, MAP_BASE_DELETED
+  FROM nodes
+ WHERE wc_id = ?1
+   AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+   AND op_depth = ?3
+
 /* If this query is updated, STMT_INSERT_DELETE_LIST should too. */
 -- STMT_INSERT_DELETE_FROM_NODE_RECURSIVE
 INSERT INTO nodes (

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c?rev=1456577&r1=1456576&r2=1456577&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c Thu Mar 14 17:59:24 2013
@@ -1093,6 +1093,9 @@ tc_editor_delete(void *baton,
   svn_boolean_t must_delete_working_nodes = FALSE;
   const char *local_abspath = svn_dirent_join(b->wcroot->abspath, relpath,
                                               scratch_pool);
+  const char *parent_relpath = svn_relpath_dirname(relpath, scratch_pool);
+  int op_depth_below;
+  svn_boolean_t have_row;
 
   SVN_ERR(svn_wc__db_depth_get_info(NULL, &move_dst_kind, NULL,
                                     &move_dst_repos_relpath, NULL, NULL, NULL,
@@ -1161,7 +1164,6 @@ tc_editor_delete(void *baton,
 
   if (!is_conflicted || must_delete_working_nodes)
     {
-      svn_boolean_t have_row;
       apr_pool_t *iterpool = svn_pool_create(scratch_pool);
       svn_skel_t *work_item;
       svn_node_kind_t del_kind;
@@ -1227,17 +1229,42 @@ tc_editor_delete(void *baton,
       svn_pool_destroy(iterpool);
     }
 
-  /* ### We might be shadowing other nodes here, so this delete
-         is not generally safe. See op-depth-test.c move_retract(),
-         for a few cases where this currently breaks the working copy
-         by not adding base-deleted nodes in its place. */
-
   /* Deleting the ROWS is valid so long as we update the parent before
-     committing the transaction. */
+     committing the transaction.  The removed rows could have been
+     replacing a lower layer in which case we need to add base-deleted
+     rows. */
   SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
-                                    STMT_DELETE_WORKING_OP_DEPTH));
-  SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, relpath, op_depth));
-  SVN_ERR(svn_sqlite__step_done(stmt));
+                                    STMT_SELECT_HIGHEST_WORKING_NODE));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, parent_relpath,
+                            op_depth));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  if (have_row)
+    op_depth_below = svn_sqlite__column_int(stmt, 0);
+  SVN_ERR(svn_sqlite__reset(stmt));
+  if (have_row)
+    {
+      /* Remove non-shadowing nodes. */
+      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
+                                        STMT_DELETE_NO_LOWER_LAYER));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isdd", b->wcroot->wc_id, relpath,
+                                op_depth, op_depth_below));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+
+      /* Convert remaining shadowing nodes to presence='base-deleted'. */
+      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
+                                        STMT_REPLACE_WITH_BASE_DELETED));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, relpath,
+                                op_depth));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+    }
+  else
+    {
+      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
+                                        STMT_DELETE_WORKING_OP_DEPTH));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, relpath,
+                                op_depth));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+    }
 
   /* Retract any base-delete. */
   SVN_ERR(svn_wc__db_retract_parent_delete(b->wcroot, relpath, op_depth,

Modified: subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c?rev=1456577&r1=1456576&r2=1456577&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c Thu Mar 14 17:59:24 2013
@@ -8069,7 +8069,7 @@ struct svn_test_descriptor_t test_funcs[
                        "move_parent_into_child (issue 4333)"),
     SVN_TEST_OPTS_PASS(move_depth_expand,
                        "move depth expansion"),
-    SVN_TEST_OPTS_XFAIL(move_retract,
-                        "move retract (issue 4336)"),
+    SVN_TEST_OPTS_PASS(move_retract,
+                       "move retract (issue 4336)"),
     SVN_TEST_NULL
   };