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/01/09 16:10:51 UTC

svn commit: r1430878 - 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 Jan  9 15:10:50 2013
New Revision: 1430878

URL: http://svn.apache.org/viewvc?rev=1430878&view=rev
Log:
Basic support for updating moved-away NODES during the post-drive 
revision dump.  It doesn't yet handle finite depth updates.

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

* subversion/libsvn_wc/wc_db_update_move.c
  (svn_wc__db_bump_moved_away, bump_moved_away): New.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_MOVED_PAIR3, STMT_HAS_LAYER_BETWEEN): New.

* subversion/libsvn_wc/wc_db.c
  (bump_revisions_post_update): Call svn_wc__db_bump_moved_away.

* subversion/tests/libsvn_wc/op-depth-test.c
  (nested_move_update): Extend.
  (nested_move_update2): New.
  (test_funcs): Add new test.

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=1430878&r1=1430877&r2=1430878&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed Jan  9 15:10:50 2013
@@ -1419,6 +1419,17 @@ WHERE wc_id = ?1
   AND moved_to IS NOT NULL
   AND NOT IS_STRICT_DESCENDANT_OF(moved_to, ?2)
 
+-- STMT_SELECT_MOVED_PAIR3
+SELECT local_relpath, moved_to, op_depth FROM nodes
+WHERE wc_id = ?1
+  AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND op_depth > 0
+  AND moved_to IS NOT NULL
+
+-- STMT_HAS_LAYER_BETWEEN
+SELECT 1 FROM NODES
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3 AND op_depth < ?4
+
 /* ------------------------------------------------------------------------- */
 
 /* Queries for verification. */

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1430878&r1=1430877&r2=1430878&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Jan  9 15:10:50 2013
@@ -10391,6 +10391,9 @@ bump_revisions_post_update(svn_wc__db_wc
                              TRUE /* is_root */, FALSE, db,
                              scratch_pool));
 
+  SVN_ERR(svn_wc__db_bump_moved_away(wcroot, local_relpath, depth,
+                                     scratch_pool));
+
   return SVN_NO_ERROR;
 }
 

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=1430878&r1=1430877&r2=1430878&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_private.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_private.h Wed Jan  9 15:10:50 2013
@@ -367,4 +367,14 @@ svn_wc__db_retract_parent_delete(svn_wc_
                                  int op_depth,
                                  apr_pool_t *scratch_pool);
 
+/* Do a post-drive revision bump for the moved-away destination for
+   any move sources under LOCAL_RELPATH.  This is called from within
+   the revision bump transaction after the tree at LOCAL_RELPATH has
+   been bumped. */
+svn_error_t *
+svn_wc__db_bump_moved_away(svn_wc__db_wcroot_t *wcroot,
+                           const char *local_relpath,
+                           svn_depth_t 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=1430878&r1=1430877&r2=1430878&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c Wed Jan  9 15:10:50 2013
@@ -1359,3 +1359,92 @@ svn_wc__db_update_moved_away_conflict_vi
 
   return SVN_NO_ERROR;
 }
+
+static svn_error_t *
+bump_moved_away(svn_wc__db_wcroot_t *wcroot,
+                const char *local_relpath,
+                svn_depth_t depth,
+                int op_depth,
+                apr_pool_t *scratch_pool)
+{
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+  apr_pool_t *iterpool;
+
+  iterpool = svn_pool_create(scratch_pool);
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_SELECT_MOVED_PAIR3));
+  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  while(have_row)
+    {
+      svn_sqlite__stmt_t *stmt2;
+      const char *src_relpath, *dst_relpath;
+      int src_op_depth = svn_sqlite__column_int(stmt, 2);
+      svn_error_t *err;
+      svn_skel_t *conflict;
+
+      svn_pool_clear(iterpool);
+
+      src_relpath = svn_sqlite__column_text(stmt, 0, iterpool);
+      dst_relpath = svn_sqlite__column_text(stmt, 1, iterpool);
+
+      err = svn_sqlite__get_statement(&stmt2, wcroot->sdb,
+                                      STMT_HAS_LAYER_BETWEEN);
+      if (!err)
+       err = svn_sqlite__bindf(stmt2, "isdd", wcroot->wc_id, local_relpath,
+                               op_depth, src_op_depth);
+      if (!err)
+        err = svn_sqlite__step(&have_row, stmt2);
+      if (!err)
+        err = svn_sqlite__reset(stmt2);
+      if (!err && !have_row)
+        {
+          const char *src_root_relpath = src_relpath;
+
+          while (relpath_depth(src_root_relpath) > src_op_depth)
+            src_root_relpath = svn_relpath_dirname(src_root_relpath, iterpool);
+
+          err = svn_wc__db_read_conflict_internal(&conflict, wcroot,
+                                                  src_root_relpath,
+                                                  iterpool, iterpool);
+          /* ### TODO: check this is the right sort of tree-conflict? */
+          if (!err && !conflict)
+            {
+              /* ### TODO: verify moved_here? */
+              err = replace_moved_layer(src_relpath, dst_relpath, op_depth,
+                                        wcroot, iterpool);
+
+              if (!err)
+                err = bump_moved_away(wcroot, dst_relpath, depth,
+                                      relpath_depth(dst_relpath), iterpool);
+            }
+        }
+
+      if (err)
+        return svn_error_compose_create(err, svn_sqlite__reset(stmt));
+
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+    }
+  SVN_ERR(svn_sqlite__reset(stmt));
+
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__db_bump_moved_away(svn_wc__db_wcroot_t *wcroot,
+                           const char *local_relpath,
+                           svn_depth_t depth,
+                           apr_pool_t *scratch_pool)
+{
+  /* ### TODO: raise tree-conflicts? */
+  if (depth != svn_depth_infinity)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(bump_moved_away(wcroot, local_relpath, depth, 0, scratch_pool));
+
+  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=1430878&r1=1430877&r2=1430878&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c Wed Jan  9 15:10:50 2013
@@ -5164,6 +5164,10 @@ nested_move_update(const svn_test_opts_t
   sbox_file_write(&b, "A/B/C/f", "r1 content\nr2 content\n");
   SVN_ERR(sbox_wc_commit(&b, ""));
 
+  /* r3: Create 'X' */
+  SVN_ERR(sbox_wc_mkdir(&b, "X"));
+  SVN_ERR(sbox_wc_commit(&b, ""));
+
   SVN_ERR(sbox_wc_update(&b, "", 1));
 
   SVN_ERR(sbox_wc_move(&b, "A", "A2"));
@@ -5222,6 +5226,31 @@ nested_move_update(const svn_test_opts_t
     SVN_ERR(check_db_rows(&b, "", nodes));
   }
 
+  /* Update A to r3 brings no changes but updates the revisions. */
+  SVN_ERR(sbox_wc_update(&b, "A", 3));
+  {
+    nodes_row_t nodes[] = {
+      {0, "",          "normal",       2, ""},
+      {0, "A",         "normal",       3, "A"},
+      {0, "A/B",       "normal",       3, "A/B"},
+      {0, "A/B/C",     "normal",       3, "A/B/C"},
+      {0, "A/B/C/f",   "normal",       3, "A/B/C/f"},
+      {1, "A",         "base-deleted", NO_COPY_FROM, "A2"},
+      {1, "A/B",       "base-deleted", NO_COPY_FROM},
+      {1, "A/B/C",     "base-deleted", NO_COPY_FROM},
+      {1, "A/B/C/f",   "base-deleted", NO_COPY_FROM},
+      {1, "A2",        "normal",       3, "A", MOVED_HERE},
+      {1, "A2/B",      "normal",       3, "A/B", MOVED_HERE},
+      {1, "A2/B/C",    "normal",       3, "A/B/C", MOVED_HERE},
+      {1, "A2/B/C/f",  "normal",       3, "A/B/C/f", MOVED_HERE},
+      {3, "A2/B/C",    "base-deleted", NO_COPY_FROM, "A2/B/C2"},
+      {3, "A2/B/C/f",  "base-deleted", NO_COPY_FROM},
+      {3, "A2/B/C2",   "normal",       3, "A/B/C", MOVED_HERE},
+      {3, "A2/B/C2/f", "normal",       3, "A/B/C/f", MOVED_HERE},
+      {0}
+    };
+    SVN_ERR(check_db_rows(&b, "", nodes));
+  }
 
   return SVN_NO_ERROR;
 }
@@ -5390,6 +5419,72 @@ nested_move_commit(const svn_test_opts_t
                                  expected_from, moved_from);
   }
 
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+nested_move_update2(const svn_test_opts_t *opts, apr_pool_t *pool)
+{
+  svn_test__sandbox_t b;
+
+  SVN_ERR(svn_test__sandbox_create(&b, "nested_move_update2", opts, pool));
+
+  SVN_ERR(sbox_wc_mkdir(&b, "A"));
+  SVN_ERR(sbox_wc_mkdir(&b, "A/B"));
+  SVN_ERR(sbox_wc_mkdir(&b, "P"));
+  SVN_ERR(sbox_wc_mkdir(&b, "P/Q"));
+  SVN_ERR(sbox_wc_commit(&b, ""));
+  SVN_ERR(sbox_wc_mkdir(&b, "X"));
+  SVN_ERR(sbox_wc_commit(&b, ""));
+  SVN_ERR(sbox_wc_update(&b, "", 1));
+  SVN_ERR(sbox_wc_move(&b, "A", "A2"));
+  SVN_ERR(sbox_wc_move(&b, "P", "A"));
+  SVN_ERR(sbox_wc_move(&b, "A/Q", "A/Q2"));
+
+  {
+    nodes_row_t nodes[] = {
+      {0, "",          "normal",       1, ""},
+      {0, "A",         "normal",       1, "A"},
+      {0, "A/B",       "normal",       1, "A/B"},
+      {0, "P",         "normal",       1, "P"},
+      {0, "P/Q",       "normal",       1, "P/Q"},
+      {1, "A2",        "normal",       1, "A", MOVED_HERE},
+      {1, "A2/B",      "normal",       1, "A/B", MOVED_HERE},
+      {1, "A",         "normal",       1, "P", FALSE, "A2", TRUE},
+      {1, "A/B",       "base-deleted", NO_COPY_FROM},
+      {1, "A/Q",       "normal",       1, "P/Q", MOVED_HERE},
+      {1, "P",         "base-deleted", NO_COPY_FROM, "A"},
+      {1, "P/Q",       "base-deleted", NO_COPY_FROM},
+      {2, "A/Q",       "base-deleted", NO_COPY_FROM, "A/Q2"},
+      {2, "A/Q2",      "normal",       1, "P/Q", MOVED_HERE},
+      {0}
+    };
+    SVN_ERR(check_db_rows(&b, "", nodes));
+  }
+
+  /* Update A bumps revisions but only for moves originating in A.  In
+     particular A/Q to A/Q2 does not get bumped. */
+  SVN_ERR(sbox_wc_update(&b, "A", 2));
+  {
+    nodes_row_t nodes[] = {
+      {0, "",          "normal",       1, ""},
+      {0, "A",         "normal",       2, "A"},
+      {0, "A/B",       "normal",       2, "A/B"},
+      {0, "P",         "normal",       1, "P"},
+      {0, "P/Q",       "normal",       1, "P/Q"},
+      {1, "A2",        "normal",       2, "A", MOVED_HERE},
+      {1, "A2/B",      "normal",       2, "A/B", MOVED_HERE},
+      {1, "A",         "normal",       1, "P", FALSE, "A2", TRUE},
+      {1, "A/B",       "base-deleted", NO_COPY_FROM},
+      {1, "A/Q",       "normal",       1, "P/Q", MOVED_HERE},
+      {1, "P",         "base-deleted", NO_COPY_FROM, "A"},
+      {1, "P/Q",       "base-deleted", NO_COPY_FROM},
+      {2, "A/Q",       "base-deleted", NO_COPY_FROM, "A/Q2"},
+      {2, "A/Q2",      "normal",       1, "P/Q", MOVED_HERE},
+      {0}
+    };
+    SVN_ERR(check_db_rows(&b, "", nodes));
+  }
 
   return SVN_NO_ERROR;
 }
@@ -5497,5 +5592,7 @@ struct svn_test_descriptor_t test_funcs[
                        "nested_move_update"),
     SVN_TEST_OPTS_XFAIL(nested_move_commit,
                        "nested_move_commit"),
+    SVN_TEST_OPTS_PASS(nested_move_update2,
+                       "nested_move_update2"),
     SVN_TEST_NULL
   };