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 2010/06/13 14:50:53 UTC

svn commit: r954215 - in /subversion/trunk/subversion: libsvn_wc/adm_ops.c libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db.h tests/cmdline/update_tests.py

Author: rhuijben
Date: Sun Jun 13 12:50:52 2010
New Revision: 954215

URL: http://svn.apache.org/viewvc?rev=954215&view=rev
Log:
Replace the entry processing from tweak_node() by using a temporary db
operation.

* subversion/libsvn_wc/adm_ops.c
  (tweak_node): Remove check for accidentally editting a working node and
    use db operation for editting the base node.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_UPDATE_BASE_REVISION,
   STMT_UPDATE_BASE_REPOS): New statements.

* subversion/libsvn_wc/wc_db.c
  (set_rev_relpath_baton): New struct.
  (set_rev_relpath_txn): New function.
  (svn_wc__db_temp_op_set_rev_and_repos_relpath): New function.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_temp_op_set_rev_and_repos_relpath): New function.

* subversion/tests/cmdline/update_tests.py
  (update_ignores_added): Expect that the revision of the replaced file is
    bumped.

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_ops.c
    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/tests/cmdline/update_tests.py

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=954215&r1=954214&r2=954215&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Sun Jun 13 12:50:52 2010
@@ -125,16 +125,12 @@ tweak_node(svn_wc__db_t *db,
            svn_boolean_t allow_removal,
            apr_pool_t *scratch_pool)
 {
-  svn_wc_entry_t tmp_entry;
-  int modify_flags = 0;
   svn_wc__db_status_t status;
   svn_wc__db_kind_t db_kind;
   svn_revnum_t revision;
   const char *repos_relpath, *repos_root_url, *repos_uuid;
+  svn_boolean_t set_repos_relpath = FALSE;
   svn_error_t *err;
-  svn_node_kind_t node_kind = (kind == svn_wc__db_kind_dir)
-                                     ? svn_node_dir
-                                     : svn_node_file;
 
   err = svn_wc__db_base_get_info(&status, &db_kind, &revision,
                                  &repos_relpath, &repos_root_url,
@@ -186,41 +182,26 @@ tweak_node(svn_wc__db_t *db,
                                            &repos_uuid, db, local_abspath,
                                            scratch_pool, scratch_pool));
 
-      if (strcmp(repos_relpath, new_repos_relpath)
-          || strcmp(repos_root_url, repos_root_url))
-        {
-          modify_flags |= SVN_WC__ENTRY_MODIFY_URL;
-          tmp_entry.url = svn_path_url_add_component2(new_repos_root_url,
-                                                      new_repos_relpath,
-                                                      scratch_pool);
-        }
+      if (strcmp(repos_relpath, new_repos_relpath))
+          set_repos_relpath = TRUE;
     }
 
-  if (SVN_IS_VALID_REVNUM(new_rev) && new_rev != revision)
-    {
-      const svn_wc_entry_t *entry;
-      SVN_ERR(svn_wc__get_entry(&entry, db, local_abspath, FALSE, node_kind,
-                                parent_stub, scratch_pool, scratch_pool));
+  if (SVN_IS_VALID_REVNUM(new_rev) && new_rev == revision)
+    new_rev = SVN_INVALID_REVNUM;
 
-      if ((entry->schedule != svn_wc_schedule_add)
-          && (entry->schedule != svn_wc_schedule_replace)
-          && (entry->copied != TRUE)
-          && (entry->revision != new_rev))
-        {
-          modify_flags |= SVN_WC__ENTRY_MODIFY_REVISION;
-          tmp_entry.revision = new_rev;
-        }
-    }
-
-  if (modify_flags)
+  if (SVN_IS_VALID_REVNUM(new_rev) || set_repos_relpath)
     {
-      if (db_kind == svn_wc__db_kind_dir && parent_stub)
-        SVN_ERR(svn_wc__entry_modify_stub(db, local_abspath,
-                                          &tmp_entry, modify_flags,
-                                          scratch_pool));
-      else
-        SVN_ERR(svn_wc__entry_modify(db, local_abspath, node_kind,
-                                     &tmp_entry, modify_flags, scratch_pool));
+      svn_boolean_t update_stub = 
+            (db_kind == svn_wc__db_kind_dir && parent_stub);
+
+      SVN_ERR(svn_wc__db_temp_op_set_rev_and_repos_relpath(db, local_abspath,
+                                                          new_rev,
+                                                          set_repos_relpath,
+                                                          new_repos_relpath,
+                                                          repos_root_url,
+                                                          repos_uuid,
+                                                          update_stub,
+                                                          scratch_pool));
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=954215&r1=954214&r2=954215&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Sun Jun 13 12:50:52 2010
@@ -480,6 +480,14 @@ SELECT 1 FROM BASE_NODE WHERE wc_id = ?1
 UNION
 SELECT 0 FROM WORKING_NODE WHERE wc_id = ?1 and local_relpath = ?2 and kind = 'subdir';
 
+-- STMT_UPDATE_BASE_REVISION
+UPDATE BASE_NODE SET revnum=?3
+WHERE wc_id = ?1 AND local_relpath = ?2;
+
+-- STMT_UPDATE_BASE_REPOS
+UPDATE BASE_NODE SET repos_id = ?3, repos_relpath = ?4
+WHERE wc_id = ?1 AND local_relpath = ?2;
+
 /* ------------------------------------------------------------------------- */
 
 /* these are used in entries.c  */

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=954215&r1=954214&r2=954215&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sun Jun 13 12:50:52 2010
@@ -8367,3 +8367,111 @@ svn_wc__db_temp_set_parent_stub_to_norma
   return SVN_NO_ERROR;
 }
 
+/* Baton for set_rev_relpath_txn */
+struct set_rev_relpath_baton
+{
+  svn_wc__db_pdh_t *pdh;
+  const char *local_relpath;
+  svn_revnum_t rev;
+  svn_boolean_t set_repos_relpath;
+  const char *repos_relpath;
+  const char *repos_root_url;
+  const char *repos_uuid;
+};
+
+/* Implements svn_sqlite__transaction_callback_t for handling
+   svn_wc__db_temp_op_set_rev_and_repos_relpath() db operations. */
+static svn_error_t *
+set_rev_relpath_txn(void *baton,
+                    svn_sqlite__db_t *sdb,
+                    apr_pool_t *scratch_pool)
+{
+  struct set_rev_relpath_baton *rrb = baton;
+  svn_sqlite__stmt_t *stmt;
+
+  if (SVN_IS_VALID_REVNUM(rrb->rev))
+    {
+      SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                        STMT_UPDATE_BASE_REVISION));
+
+      SVN_ERR(svn_sqlite__bindf(stmt, "isi", rrb->pdh->wcroot->wc_id,
+                                             rrb->local_relpath,
+                                             (apr_int64_t)rrb->rev));
+
+      SVN_ERR(svn_sqlite__step_done(stmt));
+    }
+
+  if (rrb->set_repos_relpath)
+    {
+      apr_int64_t repos_id;
+      SVN_ERR(create_repos_id(&repos_id, rrb->repos_root_url, rrb->repos_uuid,
+                              rrb->pdh->wcroot->sdb, scratch_pool));
+
+      SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                        STMT_UPDATE_BASE_REPOS));
+
+      SVN_ERR(svn_sqlite__bindf(stmt, "isis", rrb->pdh->wcroot->wc_id,
+                                              rrb->local_relpath,
+                                              repos_id,
+                                              rrb->repos_relpath));
+
+      SVN_ERR(svn_sqlite__step_done(stmt));
+    }
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__db_temp_op_set_rev_and_repos_relpath(svn_wc__db_t *db,
+                                             const char *local_abspath,
+                                             svn_revnum_t rev,
+                                             svn_boolean_t set_repos_relpath,
+                                             const char *repos_relpath,
+                                             const char *repos_root_url,
+                                             const char *repos_uuid,
+                                             svn_boolean_t update_stub,
+                                             apr_pool_t *scratch_pool)
+{
+  struct set_rev_relpath_baton baton;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+  SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(rev) || set_repos_relpath);
+
+  baton.rev = rev;
+  baton.set_repos_relpath = set_repos_relpath;
+  baton.repos_relpath = repos_relpath;
+  baton.repos_root_url = repos_root_url;
+  baton.repos_uuid = repos_uuid;
+
+  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&baton.pdh, &baton.local_relpath,
+                                             db, local_abspath,
+                                             svn_sqlite__mode_readwrite,
+                                             scratch_pool, scratch_pool));
+
+  VERIFY_USABLE_PDH(baton.pdh);
+
+  flush_entries(baton.pdh);
+
+#ifdef SINGLE_DB
+  SVN_ERR_ASSERT(!update_stub);
+#else
+  if (update_stub)
+    {
+      if (*baton.local_relpath != '\0')
+        return SVN_NO_ERROR; /* There is no stub */
+
+      SVN_ERR(navigate_to_parent(&baton.pdh, db, baton.pdh,
+                                 svn_sqlite__mode_readwrite, scratch_pool));
+
+      VERIFY_USABLE_PDH(baton.pdh);
+
+      baton.local_relpath = svn_dirent_basename(local_abspath, NULL);
+    }
+#endif
+
+  SVN_ERR(svn_sqlite__with_transaction(baton.pdh->wcroot->sdb,
+                                       set_rev_relpath_txn,
+                                       &baton, scratch_pool));
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=954215&r1=954214&r2=954215&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Sun Jun 13 12:50:52 2010
@@ -2440,6 +2440,24 @@ svn_wc__db_temp_set_parent_stub_to_norma
                                           svn_boolean_t delete_working,
                                           apr_pool_t *scratch_pool);
 
+/* Sets a base nodes revision and/or repository relative path. If
+   LOCAL_ABSPATH's rev (REV) is valid, set is revision and if SET_REPOS_RELPATH
+   is TRUE set its repository relative path to REPOS_RELPATH (and make sure its
+   REPOS_ROOT_URL and REPOS_ROOT_UUID are still valid).
+ */
+svn_error_t *
+svn_wc__db_temp_op_set_rev_and_repos_relpath(svn_wc__db_t *db,
+                                             const char *local_abspath,
+                                             svn_revnum_t rev,
+                                             svn_boolean_t set_repos_relpath,
+                                             const char *repos_relpath,
+                                             const char *repos_root_url,
+                                             const char *repos_uuid,
+                                             svn_boolean_t update_stub,
+                                             apr_pool_t *scratch_pool);
+
+
+
 /* @} */
 
 

Modified: subversion/trunk/subversion/tests/cmdline/update_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/update_tests.py?rev=954215&r1=954214&r2=954215&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/update_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/update_tests.py Sun Jun 13 12:50:52 2010
@@ -396,7 +396,11 @@ def update_ignores_added(sbox):
 
   # Create expected status tree for the update.
   expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
-  expected_status.tweak('A/D/gamma', wc_rev=1, status='R ')
+
+  # Before WC-NG we couldn't bump the wc_rev for gamma from 1 to 2 because it could
+  # be replaced with history and we couldn't store all the revision information.
+  # WC-NG just bumps the revision as it can easily store different revisions.
+  expected_status.tweak('A/D/gamma', wc_rev=2, status='R ')
   expected_status.add({
     'A/B/zeta' : Item(status='A ', wc_rev=0),
     })