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 2012/12/05 19:17:20 UTC

svn commit: r1417563 - in /subversion/trunk/subversion: libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db_private.h libsvn_wc/wc_db_update_move.c tests/libsvn_wc/op-depth-test.c

Author: philip
Date: Wed Dec  5 18:17:18 2012
New Revision: 1417563

URL: http://svn.apache.org/viewvc?rev=1417563&view=rev
Log:
When resolve adds/deletes files when following a move have it
extend/retract any parent delete just like update does for base
nodes.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_LOWEST_WORKING_NODE,
   STMT_DELETE_LOWEST_WORKING_NODE): Add op-depth parameter.
  (STMT_INSTALL_WORKING_NODE_FOR_DELETE): Rename to ...
  (STMT_INSTALL_WORKING_NODE_FOR_DELETE_FROM_BASE): ...this, remove kind
   paremater.
  (STMT_INSTALL_WORKING_NODE_FOR_DELETE): New.

* subversion/libsvn_wc/wc_db.c
  (extend_parent_delete): Bind op-depth, don't bind kind.
  (retract_parent_delete): Rename to ...
  (svn_wc__db_retract_parent_delete): ... this, bind op-depth.
  (db_base_remove): Rename call.
  (make_copy_txn): Bind op-depth.

* subversion/libsvn_wc/wc_db_private.h
  (svn_wc__db_retract_parent_delete): New.

* subversion/libsvn_wc/wc_db_update_move.c
  (tc_editor_add_file): Extend any parent delete.
  (tc_editor_delete): Retract any parent delete.

* subversion/tests/libsvn_wc/op-depth-test.c
  (move_update): Extend.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db_private.h
    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=1417563&r1=1417562&r2=1417563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed Dec  5 18:17:18 2012
@@ -98,7 +98,7 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 -- STMT_SELECT_LOWEST_WORKING_NODE
 SELECT op_depth, presence
 FROM nodes
-WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3
 ORDER BY op_depth
 LIMIT 1
 
@@ -640,7 +640,7 @@ WHERE wc_id = ?1 AND local_relpath = ?2
 DELETE FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2
   AND op_depth = (SELECT MIN(op_depth) FROM nodes
-                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0)
+                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3)
   AND presence = 'base-deleted'
 
 -- STMT_DELETE_ALL_LAYERS
@@ -827,15 +827,21 @@ VALUES (?1, ?2, 0,
             AND local_relpath = ?2
             AND op_depth = 0))
 
--- STMT_INSTALL_WORKING_NODE_FOR_DELETE
+-- STMT_INSTALL_WORKING_NODE_FOR_DELETE_FROM_BASE
 INSERT OR REPLACE INTO nodes (
     wc_id, local_relpath, op_depth,
     parent_relpath, presence, kind)
 SELECT wc_id, local_relpath, ?3 /*op_depth*/,
-       parent_relpath, ?4 /*presence*/, kind
+       parent_relpath, 'base-deleted', kind
 FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
 
+-- STMT_INSTALL_WORKING_NODE_FOR_DELETE
+INSERT OR REPLACE INTO nodes (
+    wc_id, local_relpath, op_depth,
+    parent_relpath, presence, kind)
+VALUES(?1, ?2, ?3, ?4, 'base-deleted', ?5)
+
 /* 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.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1417563&r1=1417562&r2=1417563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Dec  5 18:17:18 2012
@@ -658,7 +658,7 @@ extend_parent_delete(svn_wc__db_wcroot_t
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_SELECT_LOWEST_WORKING_NODE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, parent_relpath));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, parent_relpath, 0));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   if (have_row)
     parent_op_depth = svn_sqlite__column_int(stmt, 0);
@@ -667,7 +667,7 @@ extend_parent_delete(svn_wc__db_wcroot_t
     {
       int op_depth;
 
-      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, local_relpath, 0));
       SVN_ERR(svn_sqlite__step(&have_row, stmt));
       if (have_row)
         op_depth = svn_sqlite__column_int(stmt, 0);
@@ -675,11 +675,9 @@ 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_INSTALL_WORKING_NODE_FOR_DELETE));
-          SVN_ERR(svn_sqlite__bindf(stmt, "isdt", wcroot->wc_id,
-                                    local_relpath, parent_op_depth,
-                                    presence_map,
-                                    svn_wc__db_status_base_deleted));
+                              STMT_INSTALL_WORKING_NODE_FOR_DELETE_FROM_BASE));
+          SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id,
+                                    local_relpath, parent_op_depth));
           SVN_ERR(svn_sqlite__update(NULL, stmt));
         }
     }
@@ -694,16 +692,18 @@ extend_parent_delete(svn_wc__db_wcroot_t
    parent base and this node are both deleted and so the delete of
    this node must be removed.
  */
-static svn_error_t *
-retract_parent_delete(svn_wc__db_wcroot_t *wcroot,
-                      const char *local_relpath,
-                      apr_pool_t *scratch_pool)
+svn_error_t *
+svn_wc__db_retract_parent_delete(svn_wc__db_wcroot_t *wcroot,
+                                 const char *local_relpath,
+                                 int op_depth,
+                                 apr_pool_t *scratch_pool)
 {
   svn_sqlite__stmt_t *stmt;
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_DELETE_LOWEST_WORKING_NODE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, local_relpath,
+                            op_depth));
   SVN_ERR(svn_sqlite__step_done(stmt));
 
   return SVN_NO_ERROR;
@@ -856,7 +856,8 @@ insert_base_node(void *baton,
                || pibb->status == svn_wc__db_status_server_excluded
                || pibb->status == svn_wc__db_status_excluded)
         {
-          SVN_ERR(retract_parent_delete(wcroot, local_relpath, scratch_pool));
+          SVN_ERR(svn_wc__db_retract_parent_delete(wcroot, local_relpath, 0,
+                                                   scratch_pool));
         }
     }
 
@@ -2264,7 +2265,8 @@ db_base_remove(void *baton,
   SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
   SVN_ERR(svn_sqlite__step_done(stmt));
 
-  SVN_ERR(retract_parent_delete(wcroot, local_relpath, scratch_pool));
+  SVN_ERR(svn_wc__db_retract_parent_delete(wcroot, local_relpath, 0,
+                                           scratch_pool));
 
   /* Step 6: Delete actual node if we don't keep working */
   if (! keep_working)
@@ -13580,7 +13582,7 @@ make_copy_txn(void *baton,
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_SELECT_LOWEST_WORKING_NODE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, local_relpath, 0));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
 
   if (have_row)

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_private.h?rev=1417563&r1=1417562&r2=1417563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_private.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_private.h Wed Dec  5 18:17:18 2012
@@ -332,4 +332,12 @@ svn_wc__db_get_children_op_depth(apr_has
                                  int op_depth,
                                  apr_pool_t *result_pool,
                                  apr_pool_t *scratch_pool);
+
+
+svn_error_t *
+svn_wc__db_retract_parent_delete(svn_wc__db_wcroot_t *wcroot,
+                                 const char *local_relpath,
+                                 int op_depth,
+                                 apr_pool_t *scratch_pool);
+
 #endif /* WC_DB_PRIVATE_H */

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=1417563&r1=1417562&r2=1417563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c Wed Dec  5 18:17:18 2012
@@ -92,9 +92,35 @@ tc_editor_add_file(void *baton,
                    svn_revnum_t replaces_rev,
                    apr_pool_t *scratch_pool)
 {
+  struct tc_editor_baton *b = baton;
+  int parent_op_depth, op_depth = relpath_depth(b->move_root_dst_relpath);
+  const char *parent_relpath = svn_relpath_dirname(relpath, scratch_pool);
+  svn_boolean_t have_row;
+  svn_sqlite__stmt_t *stmt;
+
+  /* Extend base-delete. */
+  SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
+                                    STMT_SELECT_LOWEST_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)
+    parent_op_depth = svn_sqlite__column_int(stmt, 0);
+  SVN_ERR(svn_sqlite__reset(stmt));
+  if (have_row)
+    {
+      /* Adding this deleted NODES row is valid if we add the
+         underlying normal row before completing the transaction. */
+      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
+                                        STMT_INSTALL_WORKING_NODE_FOR_DELETE));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isdss", b->wcroot->wc_id, relpath,
+                                parent_op_depth, parent_relpath,
+                                "file" /* ### TODO use kind_map */ ));
+      SVN_ERR(svn_sqlite__update(NULL, stmt));
+    }
+
   /* ### TODO check for, and flag, tree conflict */
 
-  /* ### TODO Extend base-delete. */
   return SVN_NO_ERROR;
 }
 
@@ -357,16 +383,18 @@ tc_editor_delete(void *baton,
 {
   struct tc_editor_baton *b = baton;
   svn_sqlite__stmt_t *stmt;
+  int op_depth = relpath_depth(b->move_root_dst_relpath);
 
   /* Deleting the ROWS is valid so long as we update the parent before
      committing the transaction. */
   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,
-                            relpath_depth(b->move_root_dst_relpath)));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, relpath, op_depth));
   SVN_ERR(svn_sqlite__step_done(stmt));
 
-  /* ### TODO Retract base-delete. */
+  /* Retract any base-delete. */
+  SVN_ERR(svn_wc__db_retract_parent_delete(b->wcroot, relpath, op_depth,
+                                           scratch_pool));
 
   /* ### TODO check for, and flag, tree conflict */
   return SVN_NO_ERROR;

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=1417563&r1=1417562&r2=1417563&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c Wed Dec  5 18:17:18 2012
@@ -4415,6 +4415,55 @@ move_update(const svn_test_opts_t *opts,
     SVN_ERR(check_db_rows(&b, "", nodes));
   }
 
+  SVN_ERR(sbox_wc_delete(&b, "A2/B"));
+  {
+    nodes_row_t nodes[] = {
+      {0, "",         "normal",       3, ""},
+      {0, "A",        "normal",       3, "A"},
+      {0, "A/B",      "normal",       3, "A/B"},
+      {0, "A/B/f",    "normal",       3, "A/B/f"},
+      {0, "A/B/g",    "normal",       3, "A/B/g"},
+      {1, "A",        "base-deleted", NO_COPY_FROM, "A2"},
+      {1, "A/B",      "base-deleted", NO_COPY_FROM},
+      {1, "A/B/f",    "base-deleted", NO_COPY_FROM},
+      {1, "A/B/g",    "base-deleted", NO_COPY_FROM},
+      {1, "A2",       "normal",       3, "A", MOVED_HERE},
+      {1, "A2/B",     "normal",       3, "A/B", MOVED_HERE},
+      {1, "A2/B/f",   "normal",       3, "A/B/f", MOVED_HERE},
+      {1, "A2/B/g",   "normal",       3, "A/B/g", MOVED_HERE},
+      {2, "A2/B",     "base-deleted", NO_COPY_FROM},
+      {2, "A2/B/f",   "base-deleted", NO_COPY_FROM},
+      {2, "A2/B/g",   "base-deleted", NO_COPY_FROM},
+      {0}
+    };
+    SVN_ERR(check_db_rows(&b, "", nodes));
+  }
+
+  SVN_ERR(sbox_wc_update(&b, "", 2));
+  SVN_ERR(sbox_wc_resolve(&b, "A"));
+  {
+    nodes_row_t nodes[] = {
+      {0, "",         "normal",       2, ""},
+      {0, "A",        "normal",       2, "A"},
+      {0, "A/B",      "normal",       2, "A/B"},
+      {0, "A/B/f",    "normal",       2, "A/B/f"},
+      {0, "A/B/h",    "normal",       2, "A/B/h"},
+      {1, "A",        "base-deleted", NO_COPY_FROM, "A2"},
+      {1, "A/B",      "base-deleted", NO_COPY_FROM},
+      {1, "A/B/f",    "base-deleted", NO_COPY_FROM},
+      {1, "A/B/h",    "base-deleted", NO_COPY_FROM},
+      {1, "A2",       "normal",       2, "A", MOVED_HERE},
+      {1, "A2/B",     "normal",       2, "A/B", MOVED_HERE},
+      {1, "A2/B/f",   "normal",       2, "A/B/f", MOVED_HERE},
+      {1, "A2/B/h",   "normal",       2, "A/B/h", MOVED_HERE},
+      {2, "A2/B",     "base-deleted", NO_COPY_FROM},
+      {2, "A2/B/f",   "base-deleted", NO_COPY_FROM},
+      {2, "A2/B/h",   "base-deleted", NO_COPY_FROM},
+      {0}
+    };
+    SVN_ERR(check_db_rows(&b, "", nodes));
+  }
+
   return SVN_NO_ERROR;
 }