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/08/03 16:52:31 UTC

svn commit: r981903 - in /subversion/trunk/subversion/libsvn_wc: ambient_depth_filter_editor.c diff.c update_editor.c wc.h

Author: rhuijben
Date: Tue Aug  3 14:52:30 2010
New Revision: 981903

URL: http://svn.apache.org/viewvc?rev=981903&view=rev
Log:
Make the ambient depth filter capable of handling just the BASE_NODE depth,
and reduce the number of database operations on the way.

* subversion/libsvn_wc/ambient_depth_filter_editor.c
  (edit_baton): Add read_base variable.
  (read_ambient_info): New function.
  (make_dir_baton, make_file_baton, open_root, delete_entry,
   open_directory): Use read_ambient_info instead of one or more
     other db operations.
  (svn_wc__ambient_depth_filter_editor): Reorder arguments to new
     standard ordering and accept read_base argument.

* subversion/libsvn_wc/diff.c
  (svn_wc_get_diff_editor6): Update caller. Keep working_tree filtering.

* subversion/libsvn_wc/update_editor.c
  (make_editor): Update caller. Request base_tree filtering.

* subversion/libsvn_wc/wc.h
  (svn_wc__ambient_depth_filter_editor): Update prototype and documentation.

Modified:
    subversion/trunk/subversion/libsvn_wc/ambient_depth_filter_editor.c
    subversion/trunk/subversion/libsvn_wc/diff.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/wc.h

Modified: subversion/trunk/subversion/libsvn_wc/ambient_depth_filter_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/ambient_depth_filter_editor.c?rev=981903&r1=981902&r2=981903&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/ambient_depth_filter_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/ambient_depth_filter_editor.c Tue Aug  3 14:52:30 2010
@@ -96,6 +96,7 @@ struct edit_baton
   svn_wc__db_t *db;
   const char *anchor_abspath;
   const char *target;
+  svn_boolean_t read_base;
 };
 
 struct file_baton
@@ -114,6 +115,72 @@ struct dir_baton
   void *wrapped_baton;
 };
 
+/* Helper to call either svn_wc__db_base_get_info or svn_wc__db_read_info for
+   obtaining information for the ambient depth editor */
+static svn_error_t *
+ambient_read_info(svn_boolean_t *hidden,
+                  svn_wc__db_status_t *status,
+                  svn_wc__db_kind_t *kind,
+                  svn_depth_t *depth,
+                  svn_wc__db_t *db,
+                  const char *local_abspath,
+                  svn_boolean_t read_base,
+                  apr_pool_t *scratch_pool)
+{
+  svn_error_t *err;
+  svn_wc__db_status_t status_p;
+
+  SVN_ERR_ASSERT(kind != NULL);
+
+  if (hidden)
+    {
+      *hidden = FALSE;
+
+      if (!status)
+        status = &status_p;
+    }
+
+  if (read_base)
+    err = svn_wc__db_base_get_info(status, kind, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, NULL, depth, NULL, NULL,
+                                   NULL, NULL,
+                                   db, local_abspath,
+                                   scratch_pool, scratch_pool);
+  else
+    err = svn_wc__db_read_info(status, kind, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, depth, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL,
+                               db, local_abspath, scratch_pool, scratch_pool);
+
+
+  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+    {
+      svn_error_clear(err);
+
+      *kind = svn_wc__db_kind_unknown;
+      if (status)
+        *status = svn_wc__db_status_normal;
+      if (depth)
+        *depth = svn_depth_unknown;
+
+      return SVN_NO_ERROR;
+    }
+  else
+    SVN_ERR(err);
+
+  if (hidden)
+    switch (*status)
+      {
+        case svn_wc__db_status_not_present:
+        case svn_wc__db_status_absent:
+        case svn_wc__db_status_excluded:
+          *hidden = TRUE;
+      }
+
+  return SVN_NO_ERROR;
+}
+
 /* */
 static svn_error_t *
 make_dir_baton(struct dir_baton **d_p,
@@ -148,8 +215,8 @@ make_dir_baton(struct dir_baton **d_p,
     {
       const char *abspath;
       svn_boolean_t exclude;
-      svn_error_t *err;
       svn_wc__db_status_t status;
+      svn_wc__db_kind_t kind;
       svn_boolean_t exists = TRUE;
 
       abspath = svn_dirent_join(eb->anchor_abspath,
@@ -157,19 +224,10 @@ make_dir_baton(struct dir_baton **d_p,
                                                          path),
                                 pool);
 
-      err = svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL,
-                                 eb->db, abspath, pool, pool);
+      SVN_ERR(ambient_read_info(NULL, &status, &kind, NULL,
+                                eb->db, abspath, eb->read_base, pool));
 
-      if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-        {
-          svn_error_clear(err);
-          exists = FALSE;
-        }
-      else
-        SVN_ERR(err);
+      exists = (kind != svn_wc__db_kind_unknown);
 
       if (pb->ambient_depth == svn_depth_empty
           || pb->ambient_depth == svn_depth_files)
@@ -230,7 +288,7 @@ make_file_baton(struct file_baton **f_p,
          already have an entry for the file, then the parent
          doesn't want to hear about the file at all. */
       svn_wc__db_kind_t kind;
-      svn_boolean_t unavailable = FALSE;
+      svn_boolean_t unavailable;
       const char *abspath;
 
       abspath = svn_dirent_join(eb->anchor_abspath,
@@ -238,14 +296,11 @@ make_file_baton(struct file_baton **f_p,
                                                          path),
                                 pool);
 
-      SVN_ERR(svn_wc__db_read_kind(&kind, pb->edit_baton->db, abspath, TRUE,
-                                   pool));
+      SVN_ERR(ambient_read_info(&unavailable, NULL, &kind, NULL,
+                                eb->db, abspath, eb->read_base, pool));
 
       if (kind == svn_wc__db_kind_unknown)
         unavailable = TRUE;
-      else
-        SVN_ERR(svn_wc__db_node_hidden(&unavailable, pb->edit_baton->db,
-                                       abspath, pool));
 
       if (unavailable)
         {
@@ -296,28 +351,17 @@ open_root(void *edit_baton,
   if (! *eb->target)
     {
       /* For an update with a NULL target, this is equivalent to open_dir(): */
+      svn_wc__db_kind_t kind;
       svn_boolean_t hidden;
-      svn_error_t *err;
+      svn_depth_t depth;
 
       /* Read the depth from the entry. */
-      err = svn_wc__db_node_hidden(&hidden, eb->db, eb->anchor_abspath, pool);
-
-      if (!err && !hidden)
-        {
-          svn_depth_t depth;
-          SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL, &depth, NULL,
-                                       NULL, NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL, NULL, NULL,
-                                       eb->db, eb->anchor_abspath,
-                                       pool, pool));
+      SVN_ERR(ambient_read_info(&hidden, NULL, &kind, &depth,
+                                eb->db, eb->anchor_abspath, eb->read_base,
+                                pool));
 
+      if (kind != svn_wc__db_kind_unknown && !hidden)
           b->ambient_depth = depth;
-        }
-      else if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-        svn_error_clear(err);
-      else
-        SVN_ERR(err);
     }
 
   return eb->wrapped_editor->open_root(eb->wrapped_edit_baton, base_revision,
@@ -351,13 +395,11 @@ delete_entry(const char *path,
                                                          path),
                                 pool);
 
-      SVN_ERR(svn_wc__db_read_kind(&kind, eb->db, abspath, TRUE, pool));
-
-      if (kind == svn_wc__db_kind_unknown)
-        return SVN_NO_ERROR;
+      SVN_ERR(ambient_read_info(&hidden, NULL, &kind, NULL,
+                                eb->db, abspath, eb->read_base, pool));
 
-      SVN_ERR(svn_wc__db_node_hidden(&hidden, eb->db, abspath, pool));
-      if (hidden)
+      if (kind == svn_wc__db_kind_unknown
+          || hidden)
         return SVN_NO_ERROR;
     }
 
@@ -423,8 +465,9 @@ open_directory(const char *path,
   struct edit_baton *eb = pb->edit_baton;
   struct dir_baton *b;
   const char *local_abspath;
+  svn_wc__db_kind_t kind;
   svn_boolean_t hidden;
-  svn_error_t *err;
+  svn_depth_t depth;
 
   SVN_ERR(make_dir_baton(&b, path, eb, pb, pool));
   *child_baton = b;
@@ -445,22 +488,14 @@ open_directory(const char *path,
                                   pool);
 
 
-  err = svn_wc__db_node_hidden(&hidden, eb->db, local_abspath, pool);
+  SVN_ERR(ambient_read_info(&hidden, NULL, &kind, &depth,
+                            eb->db, local_abspath, eb->read_base, pool));
 
-  if ((err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND) ||
-      hidden)
+  if (kind != svn_wc__db_kind_unknown
+      && !hidden)
     {
-      svn_error_clear(err);
-      return SVN_NO_ERROR;
+      b->ambient_depth = depth;
     }
-  else
-    SVN_ERR(err);
-
-  SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, &b->ambient_depth, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL,
-                               eb->db, local_abspath, pool, pool));
 
   return SVN_NO_ERROR;
 }
@@ -642,19 +677,20 @@ close_edit(void *edit_baton,
 svn_error_t *
 svn_wc__ambient_depth_filter_editor(const svn_delta_editor_t **editor,
                                     void **edit_baton,
-                                    const svn_delta_editor_t *wrapped_editor,
-                                    void *wrapped_edit_baton,
+                                    svn_wc__db_t *db,
                                     const char *anchor_abspath,
                                     const char *target,
-                                    svn_wc__db_t *db,
-                                    apr_pool_t *pool)
+                                    svn_boolean_t read_base,
+                                    const svn_delta_editor_t *wrapped_editor,
+                                    void *wrapped_edit_baton,
+                                    apr_pool_t *result_pool)
 {
   svn_delta_editor_t *depth_filter_editor;
   struct edit_baton *eb;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(anchor_abspath));
 
-  depth_filter_editor = svn_delta_default_editor(pool);
+  depth_filter_editor = svn_delta_default_editor(result_pool);
   depth_filter_editor->set_target_revision = set_target_revision;
   depth_filter_editor->open_root = open_root;
   depth_filter_editor->delete_entry = delete_entry;
@@ -671,12 +707,13 @@ svn_wc__ambient_depth_filter_editor(cons
   depth_filter_editor->absent_file = absent_file;
   depth_filter_editor->close_edit = close_edit;
 
-  eb = apr_palloc(pool, sizeof(*eb));
+  eb = apr_pcalloc(result_pool, sizeof(*eb));
   eb->wrapped_editor = wrapped_editor;
   eb->wrapped_edit_baton = wrapped_edit_baton;
   eb->db = db;
   eb->anchor_abspath = anchor_abspath;
   eb->target = target;
+  eb->read_base = read_base;
 
   *editor = depth_filter_editor;
   *edit_baton = eb;

Modified: subversion/trunk/subversion/libsvn_wc/diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/diff.c?rev=981903&r1=981902&r2=981903&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/diff.c (original)
+++ subversion/trunk/subversion/libsvn_wc/diff.c Tue Aug  3 14:52:30 2010
@@ -1864,11 +1864,12 @@ svn_wc_get_diff_editor6(const svn_delta_
   if (depth == svn_depth_unknown)
     SVN_ERR(svn_wc__ambient_depth_filter_editor(&inner_editor,
                                                 &inner_baton,
-                                                inner_editor,
-                                                inner_baton,
+                                                wc_ctx->db,
                                                 anchor_abspath,
                                                 target,
-                                                wc_ctx->db,
+                                                FALSE /* read_base */,
+                                                inner_editor,
+                                                inner_baton,
                                                 result_pool));
 
   return svn_delta_get_cancellation_editor(cancel_func,

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=981903&r1=981902&r2=981903&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Aug  3 14:52:30 2010
@@ -6084,11 +6084,12 @@ make_editor(svn_revnum_t *target_revisio
   if (!depth_is_sticky)
     SVN_ERR(svn_wc__ambient_depth_filter_editor(&inner_editor,
                                                 &inner_baton,
-                                                inner_editor,
-                                                inner_baton,
+                                                wc_ctx->db,
                                                 anchor_abspath,
                                                 target_basename,
-                                                wc_ctx->db,
+                                                TRUE /* read_base */,
+                                                inner_editor,
+                                                inner_baton,
                                                 result_pool));
 
   return svn_delta_get_cancellation_editor(cancel_func,

Modified: subversion/trunk/subversion/libsvn_wc/wc.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc.h?rev=981903&r1=981902&r2=981903&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc.h Tue Aug  3 14:52:30 2010
@@ -469,17 +469,21 @@ svn_wc__walker_default_error_handler(con
  * @c svn_depth_infinity, @c svn_depth_empty, @c svn_depth_files,
  * @c svn_depth_immediates, or @c svn_depth_unknown.
  *
+ * If @a read_base is TRUE, always read the depth data from BASE_NODE
+ * instead of from WORKING when that exists.
+ *
  * Allocations are done in POOL.
  */
 svn_error_t *
 svn_wc__ambient_depth_filter_editor(const svn_delta_editor_t **editor,
                                     void **edit_baton,
-                                    const svn_delta_editor_t *wrapped_editor,
-                                    void *wrapped_edit_baton,
+                                    svn_wc__db_t *db,
                                     const char *anchor_abspath,
                                     const char *target,
-                                    svn_wc__db_t *db,
-                                    apr_pool_t *pool);
+                                    svn_boolean_t read_base,
+                                    const svn_delta_editor_t *wrapped_editor,
+                                    void *wrapped_edit_baton,
+                                    apr_pool_t *result_pool);
 
 
 /* Similar to svn_wc_conflicted_p3(), but with a wc_db parameter in place of