subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r933732 - in /subversion/trunk/subversion/libsvn_wc: crop.c entries.c entries.h update_editor.c wc-queries.sql wc_db.c wc_db.h
Date Tue, 13 Apr 2010 18:23:08 GMT
Author: gstein
Date: Tue Apr 13 18:23:07 2010
New Revision: 933732

URL: http://svn.apache.org/viewvc?rev=933732&view=rev
Log:
Simplify some of the depth storage code. We don't need to worry about
keeping the entries, so allow them to be flushed. This eliminates
svn_wc__set_depth(), leaving just the temp function in wc_db.

The old code didn't properly handle setting presence=excluded, so do that.

* subversion/libsvn_wc/wc_db.h:
  (svn_wc__db_temp_op_set_dir_depth): remove the FLUSH_ENTRY_CACHE param

* subversion/libsvn_wc/wc_db.c:
  (update_depth_values): new helper function to set the depth and presence
    values on both BASE and WORKING nodes, whether for "this dir" or for
    the stub in the parent.
  (svn_wc__db_temp_op_set_dir_depth): revamp. always flush. use the new
    helper function. actually set values in the parent stub, rather than
    just flushing its entries. use LOCAL_RELPATH naming for consistency.

* subversion/libsvn_wc/wc-queries.sql:
  (STMT_UPDATE_BASE_EXCLUDED, STMT_UPDATE_WORKING_EXCLUDED): two new
    statements to handle excluding nodes.

* subversion/libsvn_wc/entries.h:
* subversion/libsvn_wc/entries.h:
  (svn_wc__set_depth): removed. no longer needed.

* subversion/libsvn_wc/crop.c:
  (crop_children): call db_temp_op_set_dir_depth instead of set_depth

* subversion/libsvn_wc/update_editor.c:
  (complete_directory): call db_temp_op_set_dir_depth instead of set_depth

Modified:
    subversion/trunk/subversion/libsvn_wc/crop.c
    subversion/trunk/subversion/libsvn_wc/entries.c
    subversion/trunk/subversion/libsvn_wc/entries.h
    subversion/trunk/subversion/libsvn_wc/update_editor.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

Modified: subversion/trunk/subversion/libsvn_wc/crop.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/crop.c?rev=933732&r1=933731&r2=933732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/crop.c (original)
+++ subversion/trunk/subversion/libsvn_wc/crop.c Tue Apr 13 18:23:07 2010
@@ -91,7 +91,8 @@ crop_children(svn_wc__db_t *db,
   /* Update the depth of target first, if needed. */
   if (dir_depth > depth)
     {
-      SVN_ERR(svn_wc__set_depth(db, local_abspath, depth, iterpool));
+      SVN_ERR(svn_wc__db_temp_op_set_dir_depth(db, local_abspath, depth,
+                                               iterpool));
     }
 
   /* Looping over current directory's SVN entries: */

Modified: subversion/trunk/subversion/libsvn_wc/entries.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/entries.c?rev=933732&r1=933731&r2=933732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/entries.c (original)
+++ subversion/trunk/subversion/libsvn_wc/entries.c Tue Apr 13 18:23:07 2010
@@ -1605,65 +1605,6 @@ svn_wc_entries_read(apr_hash_t **entries
 }
 
 
-svn_error_t *
-svn_wc__set_depth(svn_wc__db_t *db,
-                  const char *local_dir_abspath,
-                  svn_depth_t depth,
-                  apr_pool_t *scratch_pool)
-{
-  const char *parent_abspath;
-  const char *base_name;
-  svn_wc_adm_access_t *adm_access;
-  svn_wc_entry_t *entry;
-
-  SVN_ERR_ASSERT(depth >= svn_depth_empty && depth <= svn_depth_infinity);
-
-  svn_dirent_split(local_dir_abspath, &parent_abspath, &base_name,
-                   scratch_pool);
-
-  /* Update the entry cache */
-  adm_access = svn_wc__adm_retrieve_internal2(db, parent_abspath,
-                                              scratch_pool);
-
-  /* Update parent? */
-  if (adm_access != NULL)
-    {
-      apr_hash_t *entries = svn_wc__adm_access_entries(adm_access);
-
-      entry = (entries != NULL)
-                       ? apr_hash_get(entries, base_name, APR_HASH_KEY_STRING)
-                       : NULL;
-
-      if (entry != NULL)
-        {
-          /* The entries in the parent stub only store excluded vs infinity. */
-          entry->depth = (depth == svn_depth_exclude) ? svn_depth_exclude
-                                                      : svn_depth_infinity;
-        }
-    }
-
-   /* Fetch the entries for the directory, and write our depth there. */
-  adm_access = svn_wc__adm_retrieve_internal2(db, local_dir_abspath,
-                                              scratch_pool);
-  if (adm_access != NULL)
-    {
-      apr_hash_t *entries = svn_wc__adm_access_entries(adm_access);
-
-      entry = (entries != NULL)
-                       ? apr_hash_get(entries, "", APR_HASH_KEY_STRING)
-                       : NULL;
-
-      if (entry != NULL)
-        entry->depth = depth;
-    }
-
-  return svn_error_return(svn_wc__db_temp_op_set_dir_depth(db,
-                                                           local_dir_abspath,
-                                                           depth,
-                                                           FALSE,
-                                                           scratch_pool));
-}
-
 /* */
 static svn_error_t *
 insert_base_node(svn_sqlite__db_t *sdb,

Modified: subversion/trunk/subversion/libsvn_wc/entries.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/entries.h?rev=933732&r1=933731&r2=933732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/entries.h (original)
+++ subversion/trunk/subversion/libsvn_wc/entries.h Tue Apr 13 18:23:07 2010
@@ -255,14 +255,6 @@ svn_error_t *
 svn_wc__entry_is_hidden(svn_boolean_t *hidden, const svn_wc_entry_t *entry);
 
 
-/* Set the depth of a directory.  */
-svn_error_t *
-svn_wc__set_depth(svn_wc__db_t *db,
-                  const char *local_dir_abspath,
-                  svn_depth_t depth,
-                  apr_pool_t *scratch_pool);
-
-
 /* For internal use by entries.c to read/write old-format working copies. */
 svn_error_t *
 svn_wc__read_entries_old(apr_hash_t **entries,

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=933732&r1=933731&r2=933732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr 13 18:23:07 2010
@@ -817,8 +817,10 @@ complete_directory(struct edit_baton *eb
               || (strcmp(local_abspath, eb->target_abspath) == 0
                   && eb->requested_depth > depth))
             {
-              SVN_ERR(svn_wc__set_depth(eb->db, local_abspath,
-                                        eb->requested_depth, iterpool));
+              SVN_ERR(svn_wc__db_temp_op_set_dir_depth(eb->db,
+                                                       local_abspath,
+                                                       eb->requested_depth,
+                                                       iterpool));
             }
         }
     }

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=933732&r1=933731&r2=933732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Tue Apr 13 18:23:07 2010
@@ -232,12 +232,20 @@ delete from actual_node
 where wc_id = ?1 and local_relpath = ?2;
 
 -- STMT_UPDATE_BASE_DEPTH
-update base_node set depth = ?3
-where wc_id = ?1 and local_relpath = ?2;
+UPDATE BASE_NODE SET depth = ?3
+WHERE wc_id = ?1 AND local_relpath = ?2;
 
 -- STMT_UPDATE_WORKING_DEPTH
-update working_node set depth = ?3
-where wc_id = ?1 and local_relpath = ?2;
+UPDATE WORKING_NODE SET depth = ?3
+WHERE wc_id = ?1 AND local_relpath = ?2;
+
+-- STMT_UPDATE_BASE_EXCLUDED
+UPDATE BASE_NODE SET presence = 'excluded', depth = 'infinity'
+WHERE wc_id = ?1 AND local_relpath = ?2;
+
+-- STMT_UPDATE_WORKING_EXCLUDED
+UPDATE WORKING_NODE SET presence = 'excluded', depth = 'infinity'
+WHERE wc_id = ?1 AND local_relpath = ?2;
 
 -- STMT_UPDATE_BASE_PRESENCE
 update base_node set presence= ?3

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=933732&r1=933731&r2=933732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Apr 13 18:23:07 2010
@@ -3296,21 +3296,56 @@ svn_wc__db_temp_op_remove_entry(svn_wc__
 }
 
 
+static svn_error_t *
+update_depth_values(svn_wc__db_pdh_t *pdh,
+                    const char *local_relpath,
+                    svn_depth_t depth)
+{
+  svn_boolean_t excluded = (depth == svn_depth_exclude);
+  svn_sqlite__stmt_t *stmt;
+
+  /* Flush any entries before we start monkeying the database.  */
+  flush_entries(pdh);
+
+  /* Parent stubs have only two depth options: excluded, or infinity.  */
+  if (*local_relpath != '\0' && !excluded)
+    depth = svn_depth_infinity;
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+                                    excluded
+                                      ? STMT_UPDATE_BASE_EXCLUDED
+                                      : STMT_UPDATE_BASE_DEPTH));
+  SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath));
+  if (!excluded)
+    SVN_ERR(svn_sqlite__bind_text(stmt, 3, svn_depth_to_word(depth)));
+  SVN_ERR(svn_sqlite__step_done(stmt));
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+                                    excluded
+                                      ? STMT_UPDATE_WORKING_EXCLUDED
+                                      : STMT_UPDATE_WORKING_DEPTH));
+  SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath));
+  if (!excluded)
+    SVN_ERR(svn_sqlite__bind_text(stmt, 3, svn_depth_to_word(depth)));
+  SVN_ERR(svn_sqlite__step_done(stmt));
+
+  return SVN_NO_ERROR;
+}
+
+
 svn_error_t *
 svn_wc__db_temp_op_set_dir_depth(svn_wc__db_t *db,
                                  const char *local_abspath,
                                  svn_depth_t depth,
-                                 svn_boolean_t flush_entry_cache,
-                                 apr_pool_t *scratch_pool)
+                                  apr_pool_t *scratch_pool)
 {
   svn_wc__db_pdh_t *pdh;
-  svn_sqlite__stmt_t *stmt;
-  const char *current_relpath;
+  const char *local_relpath;
 
-  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath) &&
-                 depth >= svn_depth_empty && depth <= svn_depth_infinity);
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+  SVN_ERR_ASSERT(depth >= svn_depth_empty && depth <= svn_depth_infinity);
 
-  SVN_ERR(parse_local_abspath(&pdh, &current_relpath, db, local_abspath,
+  SVN_ERR(parse_local_abspath(&pdh, &local_relpath, db, local_abspath,
                               svn_sqlite__mode_readwrite,
                               scratch_pool, scratch_pool));
   VERIFY_USABLE_PDH(pdh);
@@ -3318,38 +3353,29 @@ svn_wc__db_temp_op_set_dir_depth(svn_wc_
   /* ### We set depth on working and base to match entry behavior.
          Maybe these should be separated later? */
 
-  if (flush_entry_cache)
-    flush_entries(pdh);
-
-  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                    STMT_UPDATE_BASE_DEPTH));
-  SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, current_relpath));
-  SVN_ERR(svn_sqlite__bind_text(stmt, 3, svn_depth_to_word(depth)));
-  SVN_ERR(svn_sqlite__step_done(stmt));
+  SVN_ERR(update_depth_values(pdh, local_relpath, depth));
 
-  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                    STMT_UPDATE_WORKING_DEPTH));
-  SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, current_relpath));
-  SVN_ERR(svn_sqlite__bind_text(stmt, 3, svn_depth_to_word(depth)));
-  SVN_ERR(svn_sqlite__step_done(stmt));
-
-  /* Check if we should also set depth in the parent db */
-  if (flush_entry_cache && strcmp(current_relpath, "") == 0)
+  /* If we're in the subdir, then navigate to the parent to set its
+     depth value.  */
+  if (*local_relpath == '\0')
     {
       svn_error_t *err;
 
       err = navigate_to_parent(&pdh, db, pdh, svn_sqlite__mode_readwrite,
                                scratch_pool);
-      if (err && err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)
+      if (err)
         {
+          if (err->apr_err != SVN_ERR_WC_NOT_WORKING_COPY)
+            return svn_error_return(err);
+
           /* No parent to update */
           svn_error_clear(err);
           return SVN_NO_ERROR;
         }
-      else
-        SVN_ERR(err);
 
-      flush_entries(pdh);
+      /* Get the stub name, and update the depth.  */
+      local_relpath = svn_dirent_basename(local_abspath, scratch_pool);
+      SVN_ERR(update_depth_values(pdh, local_relpath, depth));
     }
 
   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=933732&r1=933731&r2=933732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Tue Apr 13 18:23:07 2010
@@ -2006,7 +2006,6 @@ svn_error_t *
 svn_wc__db_temp_op_set_dir_depth(svn_wc__db_t *db,
                                  const char *local_abspath,
                                  svn_depth_t depth,
-                                 svn_boolean_t flush_entry_cache,
                                  apr_pool_t *scratch_pool);
 
 /* Performs a non-recursive delete on local_abspath, just like a



Mime
View raw message