You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/12/21 12:10:36 UTC

svn commit: r1051452 - in /subversion/trunk/subversion: include/private/ libsvn_client/ libsvn_wc/ tests/cmdline/

Author: stsp
Date: Tue Dec 21 11:10:35 2010
New Revision: 1051452

URL: http://svn.apache.org/viewvc?rev=1051452&view=rev
Log:
Make the node walker pass the node kind to the walker callback to
remove a few redundant sqlite queries.

This has been suggested in a comment and makes a lot of sense for
upcoming proplist changes I'm planning to make.

However, this change also shows that concurrently maintaining two node
kind types in the code is starting to become a burden.
But I'm leaving this problem as an open question in a comment.

Because I'm on a train and about to arrive I couldn't run all tests.
Apologies if this breaks the bots.

* subversion/tests/cmdline/entries-dump.c
  (print_dir): Adjust svn_wc__node_found_func_t implementation.

* subversion/include/private/svn_wc_private.h
  (svn_wc__node_found_func_t): Add svn_node_kind_t argument.

* subversion/libsvn_wc/revision_status.c
  (analyze_status): Adjust svn_wc__node_found_func_t implementation.

* subversion/libsvn_wc/update_editor.c
  (modcheck_found_node): Adjust svn_wc__node_found_func_t implementation.
   Add comment about a possible future enhancement.

* subversion/libsvn_wc/node.c
  (convert_db_kind_to_node_kind): New, split off from ...
  (svn_wc_read_kind): ... this function, so that the same code can be used ...
  (walker_helper): ... here to convert the DB kind into a node kind.
   Pass the resulting node kind to the walker callback.
  (svn_wc__internal_walk_children): Pass a node kind to the walker callback.

* subversion/libsvn_client/info.c
  (info_found_node_callback): Adjust svn_wc__node_found_func_t implementation.

* subversion/libsvn_client/merge.c
  (get_mergeinfo_walk_cb, get_subtree_mergeinfo_walk_cb): Adjust
   svn_wc__node_found_func_t implementations.

* subversion/libsvn_client/prop_commands.c
  (propset_walk_cb, propget_walk_cb, proplist_walk_cb): Adjust
   svn_wc__node_found_func_t implementations.
  (get_prop_from_wc): Pass node kind to walker callback.

* subversion/libsvn_client/ra.c
  (invalidate_wcprop_for_node): Adjust svn_wc__node_found_func_t implementation.

* subversion/libsvn_client/mergeinfo.c
  (get_subtree_mergeinfo_walk_cb): Adjust svn_wc__node_found_func_t
   implementation.

* subversion/libsvn_client/changelist.c
  (set_node_changelist, get_node_changelist): Adjust
   svn_wc__node_found_func_t implementations.

* subversion/libsvn_client/commit_util.c
  (add_lock_token): Adjust svn_wc__node_found_func_t implementation.

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/changelist.c
    subversion/trunk/subversion/libsvn_client/commit_util.c
    subversion/trunk/subversion/libsvn_client/info.c
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/libsvn_client/mergeinfo.c
    subversion/trunk/subversion/libsvn_client/prop_commands.c
    subversion/trunk/subversion/libsvn_client/ra.c
    subversion/trunk/subversion/libsvn_wc/node.c
    subversion/trunk/subversion/libsvn_wc/revision_status.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/tests/cmdline/entries-dump.c

Modified: subversion/trunk/subversion/include/private/svn_wc_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_wc_private.h?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Tue Dec 21 11:10:35 2010
@@ -159,6 +159,7 @@ svn_wc__strictly_is_wc_root(svn_boolean_
 
 /** A callback invoked by the generic node-walker function.  */
 typedef svn_error_t *(*svn_wc__node_found_func_t)(const char *local_abspath,
+                                                  svn_node_kind_t kind,
                                                   void *walk_baton,
                                                   apr_pool_t *scratch_pool);
 

Modified: subversion/trunk/subversion/libsvn_client/changelist.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/changelist.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/changelist.c (original)
+++ subversion/trunk/subversion/libsvn_client/changelist.c Tue Dec 21 11:10:35 2010
@@ -56,19 +56,17 @@ struct set_cl_fn_baton
    as LOCAL_ABSPATH is deemed a valid target of that association.  */
 static svn_error_t *
 set_node_changelist(const char *local_abspath,
+                    svn_node_kind_t kind,
                     void *baton,
                     apr_pool_t *pool)
 {
   struct set_cl_fn_baton *b = (struct set_cl_fn_baton *)baton;
-  svn_node_kind_t kind;
 
   /* See if this entry passes our changelist filtering. */
   if (! svn_wc__changelist_match(b->ctx->wc_ctx, local_abspath,
                                  b->changelist_hash, pool))
     return SVN_NO_ERROR;
 
-  SVN_ERR(svn_wc_read_kind(&kind, b->ctx->wc_ctx, local_abspath, FALSE, pool));
-
   /* We only care about files right now. */
   if (kind != svn_node_file)
     {
@@ -213,14 +211,13 @@ struct get_cl_fn_baton
 
 static svn_error_t *
 get_node_changelist(const char *local_abspath,
+                    svn_node_kind_t kind,
                     void *baton,
                     apr_pool_t *pool)
 {
   struct get_cl_fn_baton *b = (struct get_cl_fn_baton *)baton;
-  svn_node_kind_t kind;
   const char *changelist;
 
-  SVN_ERR(svn_wc_read_kind(&kind, b->wc_ctx, local_abspath, FALSE, pool));
   SVN_ERR(svn_wc__node_get_changelist(&changelist, b->wc_ctx,
                                       local_abspath, pool, pool));
 

Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Tue Dec 21 11:10:35 2010
@@ -200,6 +200,7 @@ struct add_lock_token_baton
 /* This implements the svn_wc__node_found_func_t interface. */
 static svn_error_t *
 add_lock_token(const char *local_abspath,
+               svn_node_kind_t kind,
                void *walk_baton,
                apr_pool_t *scratch_pool)
 {

Modified: subversion/trunk/subversion/libsvn_client/info.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/info.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/info.c (original)
+++ subversion/trunk/subversion/libsvn_client/info.c Tue Dec 21 11:10:35 2010
@@ -334,6 +334,7 @@ struct found_entry_baton
 /* An svn_wc__node_found_func_t callback function. */
 static svn_error_t *
 info_found_node_callback(const char *local_abspath,
+                         svn_node_kind_t kind,
                          void *walk_baton,
                          apr_pool_t *pool)
 {

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Tue Dec 21 11:10:35 2010
@@ -5572,6 +5572,7 @@ record_missing_subtree_roots(const char 
    WB->CHILDREN_WITH_MERGEINFO array. */
 static svn_error_t *
 get_mergeinfo_walk_cb(const char *local_abspath,
+                      svn_node_kind_t kind,
                       void *walk_baton,
                       apr_pool_t *scratch_pool)
 {
@@ -5583,7 +5584,6 @@ get_mergeinfo_walk_cb(const char *local_
     !svn_path_compare_paths(local_abspath, wb->merge_target_abspath);
   const char *abs_parent_path = svn_dirent_dirname(local_abspath,
                                                    scratch_pool);
-  svn_node_kind_t kind;
   svn_depth_t depth;
   svn_boolean_t is_present;
   svn_boolean_t deleted;
@@ -5623,9 +5623,6 @@ get_mergeinfo_walk_cb(const char *local_
                                     scratch_pool));
     }
 
-  SVN_ERR(svn_wc_read_kind(&kind, wb->ctx->wc_ctx, local_abspath, TRUE,
-                           scratch_pool));
-
   immediate_child_dir = ((wb->depth == svn_depth_immediates)
                          &&(kind == svn_node_dir)
                          && (strcmp(abs_parent_path,
@@ -10305,6 +10302,7 @@ struct get_subtree_mergeinfo_walk_baton
    POOL is used only for temporary allocations. */
 static svn_error_t *
 get_subtree_mergeinfo_walk_cb(const char *local_abspath,
+                              svn_node_kind_t kind,
                               void *walk_baton,
                               apr_pool_t *pool)
 {

Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_client/mergeinfo.c Tue Dec 21 11:10:35 2010
@@ -323,6 +323,7 @@ struct get_mergeinfo_catalog_walk_baton
 
 static svn_error_t *
 get_subtree_mergeinfo_walk_cb(const char *local_abspath,
+                              svn_node_kind_t kind,
                               void *walk_baton,
                               apr_pool_t *scratch_pool)
 {

Modified: subversion/trunk/subversion/libsvn_client/prop_commands.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/prop_commands.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/prop_commands.c (original)
+++ subversion/trunk/subversion/libsvn_client/prop_commands.c Tue Dec 21 11:10:35 2010
@@ -105,6 +105,7 @@ struct propset_walk_baton
  */
 static svn_error_t *
 propset_walk_cb(const char *local_abspath,
+                svn_node_kind_t kind,
                 void *walk_baton,
                 apr_pool_t *pool)
 {
@@ -679,8 +680,9 @@ struct propget_walk_baton
  */
 static svn_error_t *
 propget_walk_cb(const char *local_abspath,
-                  void *walk_baton,
-                  apr_pool_t *pool)
+                svn_node_kind_t kind,
+                void *walk_baton,
+                apr_pool_t *pool)
 {
   struct propget_walk_baton *wb = walk_baton;
   const svn_string_t *propval;
@@ -895,7 +897,7 @@ get_prop_from_wc(apr_hash_t *props,
   else if (svn_wc__changelist_match(ctx->wc_ctx, target_abspath,
                                     changelist_hash, pool))
     {
-      SVN_ERR(propget_walk_cb(target_abspath, &wb, pool));
+      SVN_ERR(propget_walk_cb(target_abspath, kind, &wb, pool));
     }
 
   return SVN_NO_ERROR;
@@ -1186,6 +1188,7 @@ struct proplist_walk_baton
  */
 static svn_error_t *
 proplist_walk_cb(const char *local_abspath,
+                 svn_node_kind_t kind,
                  void *walk_baton,
                  apr_pool_t *scratch_pool)
 {

Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Tue Dec 21 11:10:35 2010
@@ -215,6 +215,7 @@ struct invalidate_wcprop_walk_baton
    `svn_wc_entry_callbacks_t'. */
 static svn_error_t *
 invalidate_wcprop_for_node(const char *local_abspath,
+                           svn_node_kind_t kind,
                            void *walk_baton,
                            apr_pool_t *pool)
 {

Modified: subversion/trunk/subversion/libsvn_wc/node.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/node.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/node.c (original)
+++ subversion/trunk/subversion/libsvn_wc/node.c Tue Dec 21 11:10:35 2010
@@ -165,6 +165,55 @@ svn_wc__node_get_repos_info(const char *
   return SVN_NO_ERROR;
 }
 
+/* Convert DB_KIND into the appropriate NODE_KIND value.
+ * If SHOW_HIDDEN is TRUE, report the node kind as found in the DB
+ * even if DB_STATUS indicates that the node is hidden.
+ * Else, return svn_kind_none for such nodes.
+ *
+ * ### This is a bit ugly. We should consider promoting svn_wc__db_kind_t
+ * ### to the de-facto node kind type instead of converting between them
+ * ### in non-backwards compat code.
+ * ### See also comments at the definition of svn_wc__db_kind_t. */
+static svn_error_t *
+convert_db_kind_to_node_kind(svn_node_kind_t *node_kind,
+                             svn_wc__db_kind_t db_kind,
+                             svn_wc__db_status_t db_status,
+                             svn_boolean_t show_hidden)
+{
+  switch (db_kind)
+    {
+      case svn_wc__db_kind_file:
+        *node_kind = svn_node_file;
+        break;
+      case svn_wc__db_kind_dir:
+        *node_kind = svn_node_dir;
+        break;
+      case svn_wc__db_kind_symlink:
+        *node_kind = svn_node_file;
+        break;
+      case svn_wc__db_kind_unknown:
+        *node_kind = svn_node_unknown;
+        break;
+      default:
+        SVN_ERR_MALFUNCTION();
+    }
+
+  /* Make sure hidden nodes return svn_node_none. */
+  if (! show_hidden)
+    switch (db_status)
+      {
+        case svn_wc__db_status_not_present:
+        case svn_wc__db_status_absent:
+        case svn_wc__db_status_excluded:
+          *node_kind = svn_node_none;
+
+        default:
+          break;
+      }
+
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_wc_read_kind(svn_node_kind_t *kind,
                  svn_wc_context_t *wc_ctx,
@@ -192,36 +241,7 @@ svn_wc_read_kind(svn_node_kind_t *kind,
   else
     SVN_ERR(err);
 
-  switch (db_kind)
-    {
-      case svn_wc__db_kind_file:
-        *kind = svn_node_file;
-        break;
-      case svn_wc__db_kind_dir:
-        *kind = svn_node_dir;
-        break;
-      case svn_wc__db_kind_symlink:
-        *kind = svn_node_file;
-        break;
-      case svn_wc__db_kind_unknown:
-        *kind = svn_node_unknown;
-        break;
-      default:
-        SVN_ERR_MALFUNCTION();
-    }
-
-  /* Make sure hidden nodes return svn_node_none. */
-  if (! show_hidden)
-    switch (db_status)
-      {
-        case svn_wc__db_status_not_present:
-        case svn_wc__db_status_absent:
-        case svn_wc__db_status_excluded:
-          *kind = svn_node_none;
-
-        default:
-          break;
-      }
+  SVN_ERR(convert_db_kind_to_node_kind(kind, db_kind, db_status, show_hidden));
 
   return SVN_NO_ERROR;
 }
@@ -695,9 +715,14 @@ walker_helper(svn_wc__db_t *db,
       if (child_kind == svn_wc__db_kind_file
             || depth >= svn_depth_immediates)
         {
-          /* ### Maybe we should pass kind to the callback?.
-             ### almost every callee starts by asking for this */
-          SVN_ERR(walk_callback(child_abspath, walk_baton, iterpool));
+          svn_node_kind_t kind;
+
+          SVN_ERR(convert_db_kind_to_node_kind(&kind, child_kind,
+                                               child_status, show_hidden));
+          /* ### We might want to pass child_status as well because at least
+           * ### one callee is asking for it.
+           * ### But is it OK to use an svn_wc__db type in this API? */
+          SVN_ERR(walk_callback(child_abspath, kind, walk_baton, iterpool));
         }
 
       /* Recurse into this directory, if appropriate. */
@@ -733,28 +758,30 @@ svn_wc__internal_walk_children(svn_wc__d
                                void *cancel_baton,
                                apr_pool_t *scratch_pool)
 {
-  svn_wc__db_kind_t kind;
+  svn_wc__db_kind_t db_kind;
+  svn_node_kind_t kind;
   svn_wc__db_status_t status;
 
   SVN_ERR_ASSERT(walk_depth >= svn_depth_empty
                  && walk_depth <= svn_depth_infinity);
 
   /* Check if the node exists before the first callback */
-  SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL,
+  SVN_ERR(svn_wc__db_read_info(&status, &db_kind, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL,
                                db, local_abspath, scratch_pool, scratch_pool));
 
-  SVN_ERR(walk_callback(local_abspath, walk_baton, scratch_pool));
+  SVN_ERR(convert_db_kind_to_node_kind(&kind, db_kind, status, show_hidden));
+  SVN_ERR(walk_callback(local_abspath, kind, walk_baton, scratch_pool));
 
-  if (kind == svn_wc__db_kind_file
+  if (db_kind == svn_wc__db_kind_file
       || status == svn_wc__db_status_not_present
       || status == svn_wc__db_status_excluded
       || status == svn_wc__db_status_absent)
     return SVN_NO_ERROR;
 
-  if (kind == svn_wc__db_kind_dir)
+  if (db_kind == svn_wc__db_kind_dir)
     {
       return svn_error_return(
         walker_helper(db, local_abspath, show_hidden, walk_callback, walk_baton,

Modified: subversion/trunk/subversion/libsvn_wc/revision_status.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/revision_status.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/revision_status.c (original)
+++ subversion/trunk/subversion/libsvn_wc/revision_status.c Tue Dec 21 11:10:35 2010
@@ -52,6 +52,7 @@ struct walk_baton
  * Temporary allocations are made in SCRATCH_POOL. */
 static svn_error_t *
 analyze_status(const char *local_abspath,
+               svn_node_kind_t kind,
                void *baton,
                apr_pool_t *scratch_pool)
 {

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Dec 21 11:10:35 2010
@@ -1297,18 +1297,21 @@ typedef struct modcheck_baton_t {
                                           then this field has no meaning. */
 } modcheck_baton_t;
 
-/* */
+/* An implementation of svn_wc__node_found_func_t. */
 static svn_error_t *
 modcheck_found_node(const char *local_abspath,
+                    svn_node_kind_t kind,
                     void *walk_baton,
                     apr_pool_t *scratch_pool)
 {
   modcheck_baton_t *baton = walk_baton;
-  svn_wc__db_kind_t kind;
+  svn_wc__db_kind_t db_kind;
   svn_wc__db_status_t status;
   svn_boolean_t modified;
 
-  SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL, NULL,
+  /* ### The walker could in theory pass status and db kind as arguments.
+   * ### So this read_info call is probably redundant. */
+  SVN_ERR(svn_wc__db_read_info(&status, &db_kind, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL,
@@ -1321,7 +1324,7 @@ modcheck_found_node(const char *local_ab
      modification */
   else if (!baton->found_mod || baton->all_edits_are_deletes)
     SVN_ERR(entry_has_local_mods(&modified, baton->db, local_abspath,
-                                 kind, scratch_pool));
+                                 db_kind, scratch_pool));
 
   if (modified)
     {

Modified: subversion/trunk/subversion/tests/cmdline/entries-dump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/entries-dump.c?rev=1051452&r1=1051451&r2=1051452&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/entries-dump.c (original)
+++ subversion/trunk/subversion/tests/cmdline/entries-dump.c Tue Dec 21 11:10:35 2010
@@ -143,14 +143,11 @@ struct directory_walk_baton
 /* svn_wc__node_found_func_t implementation for directory_dump */
 static svn_error_t *
 print_dir(const char *local_abspath,
+          svn_node_kind_t kind,
           void *walk_baton,
           apr_pool_t *scratch_pool)
 {
   struct directory_walk_baton *bt = walk_baton;
-  svn_node_kind_t kind;
-
-  SVN_ERR(svn_wc_read_kind(&kind, bt->wc_ctx, local_abspath, FALSE,
-                           scratch_pool));
 
   if (kind != svn_node_dir)
     return SVN_NO_ERROR;