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 2012/11/29 15:06:03 UTC

svn commit: r1415168 - in /subversion/trunk/subversion: libsvn_client/add.c libsvn_wc/adm_ops.c libsvn_wc/wc_db.c

Author: rhuijben
Date: Thu Nov 29 14:06:01 2012
New Revision: 1415168

URL: http://svn.apache.org/viewvc?rev=1415168&view=rev
Log:
Make the wc_db property handling code report an error when accessing
properties on deleted (and hidden) nodes, when not explicitly asking for
the pristine properties.

This change will (in a followup commit) allow removing some expensive checks
in higher level apis.

* subversion/libsvn_client/add.c
  (svn_client__get_all_ignores): Handle getting the error
    SVN_ERR_WC_PATH_UNEXPECTED_STATUS as if touching an unversioned
    path.

* subversion/libsvn_wc/adm_ops.c
  (svn_wc_add_lock2): When a node doesn't have properties, we can assume
    it doesn't need svn:needs-lock special handling.

* subversion/libsvn_wc/wc_db.c
  (db_read_pristine_props): Add argument.
  (cross_db_copy,
   set_props_txn,
   db_read_props): Update callers. Expect errors when reading deleted nodes.
  (db_read_pristine_props): Add boolean argument to trigger reading while
    in an unexpected state errors.
  (svn_wc__db_read_pristine_props): Update caller. Suppress deleted node
    errors.

Modified:
    subversion/trunk/subversion/libsvn_client/add.c
    subversion/trunk/subversion/libsvn_wc/adm_ops.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_client/add.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/add.c?rev=1415168&r1=1415167&r2=1415168&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/add.c (original)
+++ subversion/trunk/subversion/libsvn_client/add.c Thu Nov 29 14:06:01 2012
@@ -922,7 +922,9 @@ svn_error_t *svn_client__get_all_ignores
                                 scratch_pool, scratch_pool);
       if (err)
         {
-          if (err->apr_err != SVN_ERR_UNVERSIONED_RESOURCE)
+          /* Unversioned and deleted nodes don't have properties */
+          if (err->apr_err != SVN_ERR_UNVERSIONED_RESOURCE
+              && err->apr_err != SVN_ERR_WC_PATH_UNEXPECTED_STATUS)
             return svn_error_trace(err);
 
           svn_error_clear(err);

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=1415168&r1=1415167&r2=1415168&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Thu Nov 29 14:06:01 2012
@@ -2446,9 +2446,19 @@ svn_wc_add_lock2(svn_wc_context_t *wc_ct
     }
 
   /* if svn:needs-lock is present, then make the file read-write. */
-  SVN_ERR(svn_wc__internal_propget(&needs_lock, wc_ctx->db, local_abspath,
-                                   SVN_PROP_NEEDS_LOCK, scratch_pool,
-                                   scratch_pool));
+  err = svn_wc__internal_propget(&needs_lock, wc_ctx->db, local_abspath,
+                                 SVN_PROP_NEEDS_LOCK, scratch_pool,
+                                 scratch_pool);
+
+  if (err && err->apr_err == SVN_ERR_WC_PATH_UNEXPECTED_STATUS)
+    {
+      /* The node has non wc representation (e.g. deleted), so
+         we don't want to touch the in-wc file */
+      svn_error_clear(err);
+      return SVN_NO_ERROR;
+    }
+  SVN_ERR(err);
+
   if (needs_lock)
     SVN_ERR(svn_io_set_file_read_write(local_abspath, FALSE, scratch_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=1415168&r1=1415167&r2=1415168&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Nov 29 14:06:01 2012
@@ -321,6 +321,7 @@ static svn_error_t *
 db_read_pristine_props(apr_hash_t **props,
                        svn_wc__db_wcroot_t *wcroot,
                        const char *local_relpath,
+                       svn_boolean_t deleted_ok,
                        apr_pool_t *result_pool,
                        apr_pool_t *scratch_pool);
 
@@ -3652,7 +3653,7 @@ cross_db_copy(svn_wc__db_wcroot_t *src_w
                     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     src_wcroot, src_relpath, scratch_pool, scratch_pool));
 
-  SVN_ERR(db_read_pristine_props(&props, src_wcroot, src_relpath,
+  SVN_ERR(db_read_pristine_props(&props, src_wcroot, src_relpath, FALSE,
                                  scratch_pool, scratch_pool));
 
   blank_iwb(&iwb);
@@ -5101,7 +5102,7 @@ set_props_txn(void *baton,
   /* Check if the props are modified. If no changes, then wipe out the
      ACTUAL props.  PRISTINE_PROPS==NULL means that any
      ACTUAL props are okay as provided, so go ahead and set them.  */
-  SVN_ERR(db_read_pristine_props(&pristine_props, wcroot, local_relpath,
+  SVN_ERR(db_read_pristine_props(&pristine_props, wcroot, local_relpath, FALSE,
                                  scratch_pool, scratch_pool));
   if (spb->props && pristine_props)
     {
@@ -8841,7 +8842,7 @@ db_read_props(void *baton,
     return SVN_NO_ERROR;
 
   /* No local changes. Return the pristine props for this node.  */
-  SVN_ERR(db_read_pristine_props(&rpb->props, wcroot, local_relpath,
+  SVN_ERR(db_read_pristine_props(&rpb->props, wcroot, local_relpath, FALSE,
                                  rpb->result_pool, scratch_pool));
   if (rpb->props == NULL)
     {
@@ -8889,6 +8890,7 @@ static svn_error_t *
 db_read_pristine_props(apr_hash_t **props,
                        svn_wc__db_wcroot_t *wcroot,
                        const char *local_relpath,
+                       svn_boolean_t deleted_ok,
                        apr_pool_t *result_pool,
                        apr_pool_t *scratch_pool)
 {
@@ -8916,9 +8918,8 @@ db_read_pristine_props(apr_hash_t **prop
   presence = svn_sqlite__column_token(stmt, 1, presence_map);
 
   /* For "base-deleted", it is obvious the pristine props are located
-     in the BASE table. Fall through to fetch them.
-     ### BH: Is this really the behavior we want here? */
-  if (presence == svn_wc__db_status_base_deleted)
+     below the current node. Fetch the NODE from the next record. */
+  if (presence == svn_wc__db_status_base_deleted && deleted_ok)
     {
       SVN_ERR(svn_sqlite__step(&have_row, stmt));
 
@@ -8943,7 +8944,16 @@ db_read_pristine_props(apr_hash_t **prop
 
       return SVN_NO_ERROR;
     }
-
+  else if (!deleted_ok)
+    {
+      return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS,
+                               svn_sqlite__reset(stmt),
+                               _("The node '%s' has a status that"
+                                 " has no properties."),
+                               path_for_error_message(wcroot,
+                                                      local_relpath,
+                                                      scratch_pool));
+    }
   *props = NULL;
   return svn_error_trace(svn_sqlite__reset(stmt));
 }
@@ -8965,7 +8975,7 @@ svn_wc__db_read_pristine_props(apr_hash_
                               local_abspath, scratch_pool, scratch_pool));
   VERIFY_USABLE_WCROOT(wcroot);
 
-  SVN_ERR(db_read_pristine_props(props, wcroot, local_relpath,
+  SVN_ERR(db_read_pristine_props(props, wcroot, local_relpath, TRUE,
                                  result_pool, scratch_pool));
   return SVN_NO_ERROR;
 }