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/02/17 16:52:17 UTC

svn commit: r911027 - in /subversion/trunk/subversion/libsvn_wc: adm_ops.c wc_db.c wc_db.h workqueue.c

Author: rhuijben
Date: Wed Feb 17 15:52:17 2010
New Revision: 911027

URL: http://svn.apache.org/viewvc?rev=911027&view=rev
Log:
Consolidate the entry modify operations to svn_wc_schedule_delete to a
single location in wc_db.c. This allows reimplementing this functions in
terms of WC-NG in a future commit.

* subversion/libsvn_wc/adm_ops.c
  (mark_tree_deleted): Call svn_wc__db_temp_op_delete() instead of modifying
    an entry.
  (svn_wc_delete4): Call svn_wc__db_temp_op_delete() for deleting the db portions
    of the path. Add note for moving the operations into a transaction

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_temp_op_delete): New function with temporary implementation
    based on the old entry based code from its callers.
* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_temp_op_delete): New function.

* subversion/libsvn_wc/workqueue.c
  (run_delete): Remove entry update code. This should be handled inside the
    operation that inserts the wq item(and not inside the wq-operation)

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_ops.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h
    subversion/trunk/subversion/libsvn_wc/workqueue.c

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=911027&r1=911026&r2=911027&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Wed Feb 17 15:52:17 2010
@@ -836,7 +836,6 @@
   apr_pool_t *iterpool = svn_pool_create(pool);
   const apr_array_header_t *children;
   const svn_wc_entry_t *entry;
-  svn_wc_entry_t tmp_entry;
   int i;
 
   /* Read the entries file for this directory. */
@@ -848,6 +847,7 @@
       const char *child_basename = APR_ARRAY_IDX(children, i, const char *);
       const char *child_abspath;
       svn_boolean_t hidden;
+      svn_wc__db_kind_t kind;
 
       /* Clear our per-iteration pool. */
       svn_pool_clear(iterpool);
@@ -859,11 +859,10 @@
       if (hidden)
         continue;
 
-      SVN_ERR(svn_wc__get_entry(&entry, db, child_abspath, FALSE,
-                                svn_node_unknown, FALSE, iterpool, iterpool));
+      SVN_ERR(svn_wc__db_read_kind(&kind, db, child_abspath, FALSE, iterpool));
 
       /* If this is a directory, recurse. */
-      if (entry->kind == svn_node_dir)
+      if (kind == svn_wc__db_kind_dir)
         {
           SVN_ERR(mark_tree_deleted(db, child_abspath,
                                     keep_local,
@@ -872,24 +871,7 @@
                                     iterpool));
         }
 
-      /* If this node has no function after the delete, remove it
-         directly. Otherwise svn_wc__entry_modify2 would do this for us,
-         but using the entries api would leave the db handle open */
-      /* ### BH: This check matches the only case in fold_scheduling()
-                 that removes the entry via delete scheduling */
-      if (entry->schedule == svn_wc_schedule_add && !entry->deleted)
-        {
-          SVN_ERR(svn_wc__entry_remove(db, child_abspath, pool));
-          SVN_ERR(svn_wc__db_temp_forget_directory(db, dir_abspath, pool));
-        }
-      else
-        {
-          tmp_entry.schedule = svn_wc_schedule_delete;
-          SVN_ERR(svn_wc__entry_modify2(db, child_abspath, svn_node_unknown,
-                                        TRUE, &tmp_entry,
-                                        SVN_WC__ENTRY_MODIFY_SCHEDULE,
-                                        iterpool));
-        }
+      SVN_ERR(svn_wc__db_temp_op_delete(db, child_abspath, pool));
 
       /* Tell someone what we've done. */
       if (notify_func != NULL)
@@ -911,14 +893,18 @@
      case, so KEEP_LOCAL doesn't need to be set either. */
   if (entry->schedule != svn_wc_schedule_add)
     {
-      tmp_entry.schedule = svn_wc_schedule_delete;
-      tmp_entry.keep_local = keep_local;
+      SVN_ERR(svn_wc__db_temp_op_delete(db, dir_abspath, iterpool));
 
-      SVN_ERR(svn_wc__entry_modify2(db, dir_abspath, svn_node_dir, FALSE,
-                                    &tmp_entry,
-                                    SVN_WC__ENTRY_MODIFY_SCHEDULE |
-                                    SVN_WC__ENTRY_MODIFY_KEEP_LOCAL,
-                                    iterpool));
+      if (keep_local)
+      {
+        svn_wc_entry_t tmp_entry;
+        tmp_entry.keep_local = keep_local;
+
+        SVN_ERR(svn_wc__entry_modify2(db, dir_abspath, svn_node_dir, FALSE,
+                                      &tmp_entry,
+                                      SVN_WC__ENTRY_MODIFY_KEEP_LOCAL,
+                                      iterpool));
+      }
     }
 
   /* Destroy our per-iteration pool. */
@@ -1230,6 +1216,12 @@
     {
       const char *parent_abspath = svn_dirent_dirname(local_abspath, pool);
 
+      /* ### The following two operations should be inside one SqLite
+             transaction. For even better behavior the tree operation
+             before this block needs the same handling. 
+             Luckily most of this is for free once properties and pristine
+             are handled in the WC-NG way. */
+      SVN_ERR(svn_wc__db_temp_op_delete(wc_ctx->db, local_abspath, pool));
       SVN_ERR(svn_wc__wq_add_delete(wc_ctx->db, parent_abspath, local_abspath,
                                     kind, was_add, was_copied, was_replace,
                                     base_shadowed, pool));

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=911027&r1=911026&r2=911027&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Feb 17 15:52:17 2010
@@ -3112,6 +3112,70 @@
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__db_temp_op_delete(svn_wc__db_t *db,
+                          const char *local_abspath,
+                          apr_pool_t *scratch_pool)
+{
+  const svn_wc_entry_t *entry;
+  svn_error_t *err;
+
+  /* ### Initial implementation: Copy the entry based code here. This will be
+         more logical when we look at BASE_NODE and WORKING_NODE */
+
+  err = svn_wc__get_entry(&entry, db, local_abspath, FALSE, svn_node_unknown,
+                          FALSE, scratch_pool, scratch_pool);
+
+  if (err && err->apr_err == SVN_ERR_NODE_UNEXPECTED_KIND)
+    {
+      svn_error_clear(err);
+      err = NULL;
+    }
+  else
+    SVN_ERR(err);
+
+  if (entry->schedule == svn_wc_schedule_add)
+    {
+      svn_boolean_t deleted;
+
+      SVN_ERR(svn_wc__node_is_deleted(&deleted, db, local_abspath, scratch_pool));
+
+      if (!deleted)
+        {
+          /* This case is easy.. Just delete the entry */
+          SVN_ERR(svn_wc__entry_remove(db, local_abspath, scratch_pool));
+          SVN_ERR(svn_wc__db_temp_forget_directory(db, local_abspath, scratch_pool));
+
+          return SVN_NO_ERROR;
+        }
+    }
+
+    {
+      svn_wc_entry_t tmp_entry;
+      const char *name = entry->name;
+
+      tmp_entry.schedule = svn_wc_schedule_delete;
+
+      /* Don't update the directory entries for locally added directories
+         and directories that are missing. (The first scenario abort()s
+         and the second gives a WC missing error) */
+      if (entry->kind != svn_node_dir ||
+          (entry->schedule != svn_wc_schedule_add && *entry->name == '\0'))
+        SVN_ERR(svn_wc__entry_modify2(db, local_abspath, entry->kind,
+                                      FALSE, &tmp_entry,
+                                      SVN_WC__ENTRY_MODIFY_SCHEDULE,
+                                      scratch_pool));
+
+      /* And update the parent stub */
+      if (entry->kind == svn_node_dir)
+        SVN_ERR(svn_wc__entry_modify2(db, local_abspath, svn_node_dir,
+                                      TRUE, &tmp_entry,
+                                      SVN_WC__ENTRY_MODIFY_SCHEDULE,
+                                      scratch_pool));
+    }
+
+  return SVN_NO_ERROR;
+}
 
 svn_error_t *
 svn_wc__db_read_info(svn_wc__db_status_t *status,

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=911027&r1=911026&r2=911027&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Wed Feb 17 15:52:17 2010
@@ -1912,6 +1912,13 @@
                                  svn_boolean_t flush_entry_cache,
                                  apr_pool_t *scratch_pool);
 
+/* Performs a non-recursive delete on local_abspath, just like a
+   schedule delete on a local_abspath entry would have been performed
+   before. */
+svn_error_t *
+svn_wc__db_temp_op_delete(svn_wc__db_t *db,
+                          const char *local_abspath,
+                          apr_pool_t *scratch_pool);
 
 /* ### temp function. return the FORMAT for the directory LOCAL_ABSPATH.  */
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=911027&r1=911026&r2=911027&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Wed Feb 17 15:52:17 2010
@@ -1680,7 +1680,6 @@
   const char *local_abspath;
   svn_wc__db_kind_t kind;
   svn_boolean_t was_added, was_copied, was_replaced, base_shadowed;
-  svn_wc_entry_t tmp_entry;
 
   local_abspath = apr_pstrmemdup(scratch_pool, arg->data, arg->len);
   arg = arg->next;
@@ -1694,14 +1693,6 @@
   arg = arg->next;
   base_shadowed = svn_skel__parse_int(arg, scratch_pool);
 
-  /* Edit the entry to reflect the now deleted state.
-     entries.c:fold_entry() clears the values of copied, copyfrom_rev
-     and copyfrom_url. */
-  tmp_entry.schedule = svn_wc_schedule_delete;
-  SVN_ERR(svn_wc__entry_modify2(db, local_abspath, svn_node_unknown, TRUE,
-                                &tmp_entry, SVN_WC__ENTRY_MODIFY_SCHEDULE,
-                                scratch_pool));
-
   if (was_replaced && was_copied)
     {
       const char *props_base, *props_revert;