Author: rhuijben
Date: Wed Jun 16 11:02:54 2010
New Revision: 955191

URL: http://svn.apache.org/viewvc?rev=955191&view=rev
Log:
Properly detect if we should really handle a parent stub to prepare for
when we don't have parent stubs.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_op_copy_dir,
   svn_wc__db_op_add_directory): Detect empty local_relpath before looking
     for a parent stub.
  (svn_wc__db_temp_op_remove_entry): Remove entry in the right place and
     maybe in the parent stub. Implement what we should do, instead of just
     documenting what we should do.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db.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=955191&r1=955190&r2=955191&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Jun 16 11:02:54 2010
@@ -2790,29 +2790,30 @@ svn_wc__db_op_copy_dir(svn_wc__db_t *db,
   flush_entries(pdh);
 
   /* Add a parent stub.  */
-  {
-    svn_error_t *err;
+  if (*local_relpath == '\0')
+    {
+      svn_error_t *err;
 
-    err = navigate_to_parent(&pdh, db, pdh, svn_sqlite__mode_readwrite,
-                             scratch_pool);
-    if (err)
-      {
-        /* Prolly fell off the top of the wcroot. Just call it a day.  */
-        svn_error_clear(err);
-        return SVN_NO_ERROR;
-      }
+      err = navigate_to_parent(&pdh, db, pdh, svn_sqlite__mode_readwrite,
+                               scratch_pool);
+      if (err)
+        {
+          /* Prolly fell off the top of the wcroot. Just call it a day.  */
+          svn_error_clear(err);
+          return SVN_NO_ERROR;
+        }
 
-    blank_iwb(&iwb);
+      blank_iwb(&iwb);
 
-    iwb.presence = svn_wc__db_status_normal;
-    iwb.kind = svn_wc__db_kind_subdir;
-    iwb.wc_id = pdh->wcroot->wc_id;
-    iwb.local_relpath = svn_dirent_basename(local_abspath, scratch_pool);
-
-    /* No children or work items, so a txn is not needed.  */
-    SVN_ERR(insert_working_node(&iwb, pdh->wcroot->sdb, scratch_pool));
-    flush_entries(pdh);
-  }
+      iwb.presence = svn_wc__db_status_normal;
+      iwb.kind = svn_wc__db_kind_subdir;
+      iwb.wc_id = pdh->wcroot->wc_id;
+      iwb.local_relpath = svn_dirent_basename(local_abspath, scratch_pool);
+
+      /* No children or work items, so a txn is not needed.  */
+      SVN_ERR(insert_working_node(&iwb, pdh->wcroot->sdb, scratch_pool));
+      flush_entries(pdh);
+    }
 
   return SVN_NO_ERROR;
 }
@@ -2988,29 +2989,30 @@ svn_wc__db_op_add_directory(svn_wc__db_t
   flush_entries(pdh);
 
   /* Add a parent stub.  */
-  {
-    svn_error_t *err;
+  if (*local_relpath == '\0')
+    {
+      svn_error_t *err;
 
-    err = navigate_to_parent(&pdh, db, pdh, svn_sqlite__mode_readwrite,
-                             scratch_pool);
-    if (err)
-      {
-        /* Prolly fell off the top of the wcroot. Just call it a day.  */
-        svn_error_clear(err);
-        return SVN_NO_ERROR;
-      }
+      err = navigate_to_parent(&pdh, db, pdh, svn_sqlite__mode_readwrite,
+                               scratch_pool);
+      if (err)
+        {
+          /* Prolly fell off the top of the wcroot. Just call it a day.  */
+          svn_error_clear(err);
+          return SVN_NO_ERROR;
+        }
 
-    blank_iwb(&iwb);
+      blank_iwb(&iwb);
 
-    iwb.presence = svn_wc__db_status_normal;
-    iwb.kind = svn_wc__db_kind_subdir;
-    iwb.wc_id = pdh->wcroot->wc_id;
-    iwb.local_relpath = svn_dirent_basename(local_abspath, scratch_pool);
-
-    /* No children or work items, so a txn is not needed.  */
-    SVN_ERR(insert_working_node(&iwb, pdh->wcroot->sdb, scratch_pool));
-    flush_entries(pdh);
-  }
+      iwb.presence = svn_wc__db_status_normal;
+      iwb.kind = svn_wc__db_kind_subdir;
+      iwb.wc_id = pdh->wcroot->wc_id;
+      iwb.local_relpath = svn_dirent_basename(local_abspath, scratch_pool);
+
+      /* No children or work items, so a txn is not needed.  */
+      SVN_ERR(insert_working_node(&iwb, pdh->wcroot->sdb, scratch_pool));
+      flush_entries(pdh);
+    }
 
   return SVN_NO_ERROR;
 }
@@ -3638,23 +3640,6 @@ svn_wc__db_temp_op_remove_entry(svn_wc__
 
   flush_entries(pdh);
 
-  /* Check if we should remove it from the parent db instead */
-  /* (In theory, we should remove it from the parent db *as well*.  However,
-     we must be looking at a separate per-directory database, and deleting
-     the "this-dir" entry implies the caller is about to delete this whole
-     directory including the database from disk, so we don't bother deleting
-     the rows from here as well.) */
-  if (*local_relpath == '\0')
-    {
-      SVN_ERR(navigate_to_parent(&pdh, db, pdh, svn_sqlite__mode_readwrite,
-                                 scratch_pool));
-      VERIFY_USABLE_PDH(pdh);
-
-      local_relpath = svn_dirent_basename(local_abspath, NULL);
-
-      flush_entries(pdh);
-    }
-
   sdb = pdh->wcroot->sdb;
   wc_id = pdh->wcroot->wc_id;
 
@@ -3669,7 +3654,37 @@ svn_wc__db_temp_op_remove_entry(svn_wc__
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_DELETE_ACTUAL_NODE));
   SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, local_relpath));
 
-  return svn_error_return(svn_sqlite__step_done(stmt));
+  SVN_ERR(svn_sqlite__step_done(stmt));
+
+  /* Check if we should also remove it from the parent db */
+  if (*local_relpath == '\0')
+    {
+      SVN_ERR(navigate_to_parent(&pdh, db, pdh, svn_sqlite__mode_readwrite,
+                                 scratch_pool));
+      VERIFY_USABLE_PDH(pdh);
+
+      local_relpath = svn_dirent_basename(local_abspath, NULL);
+
+      flush_entries(pdh);
+
+      sdb = pdh->wcroot->sdb;
+      wc_id = pdh->wcroot->wc_id;
+
+      SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_DELETE_BASE_NODE));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, local_relpath));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+
+      SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_DELETE_WORKING_NODE));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, local_relpath));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+
+      SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_DELETE_ACTUAL_NODE));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, local_relpath));
+
+      SVN_ERR(svn_sqlite__step_done(stmt));
+    }
+
+  return SVN_NO_ERROR;
 }
 
 


Reply via email to