You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2019/01/30 14:38:52 UTC

svn commit: r1852526 - in /subversion/trunk/subversion: include/svn_delta.h libsvn_client/shelf.c libsvn_delta/deprecated.c libsvn_delta/path_driver.c

Author: julianfoad
Date: Wed Jan 30 14:38:52 2019
New Revision: 1852526

URL: http://svn.apache.org/viewvc?rev=1852526&view=rev
Log:
Make the editor path driver callback a little easier to use.

Add 'editor' and 'edit_baton' parameters to the path driver callback. All
but trivial callback implementations need these, and they otherwise had to
be passed through the callback baton, which was straightforward but more
trouble than it need be.

* subversion/include/svn_delta.h
  (svn_delta_path_driver_cb_func2_t,
   svn_delta_path_driver3): New.

* subversion/libsvn_delta/path_driver.c
  (svn_delta_path_driver3): Rename from 'svn_delta_path_driver2'.
  (svn_delta_path_driver_state_t,
   svn_delta_path_driver_start): Change the callback function type.
  (svn_delta_path_driver_step): Pass the extra parameters.

* subversion/libsvn_delta/deprecated.c
  (path_driver_2_to_3_baton_t,
   path_driver_2_to_3_func,
   svn_delta_path_driver2): New.

* subversion/libsvn_client/shelf.c
  (path_driver_cb_func): Take 'editor' and 'edit_baton' as direct parameters.
  (path_driver_cb_baton_t,
   svn_client__shelf_replay): Remove them from the path driver baton.

Modified:
    subversion/trunk/subversion/include/svn_delta.h
    subversion/trunk/subversion/libsvn_client/shelf.c
    subversion/trunk/subversion/libsvn_delta/deprecated.c
    subversion/trunk/subversion/libsvn_delta/path_driver.c

Modified: subversion/trunk/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_delta.h?rev=1852526&r1=1852525&r2=1852526&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_delta.h (original)
+++ subversion/trunk/subversion/include/svn_delta.h Wed Jan 30 14:38:52 2019
@@ -1289,10 +1289,10 @@ svn_delta_depth_filter_editor(const svn_
 /** Callback function type for svn_delta_path_driver().
  *
  * The handler of this callback is given the callback baton @a
- * callback_baton, @a path which is a relpath relative to the
+ * callback_baton, @a editor and @a edit_baton which represent the
+ * editor being driven, @a path which is a relpath relative to the
  * root of the edit, and the @a parent_baton which represents
- * path's parent directory as created by the editor passed to
- * svn_delta_path_driver().
+ * path's parent directory as created by the editor.
  *
  * If the handler deletes the node at @a path (and does not replace it
  * with an added directory) it must set @a *dir_baton to null or leave
@@ -1311,6 +1311,23 @@ svn_delta_depth_filter_editor(const svn_
  * is also one of the paths passed to svn_delta_path_driver().  The
  * handler of this callback must call the editor's open_root()
  * function and return the top-level root dir baton in @a *dir_baton.
+ *
+ * @since New in 1.12.
+ */
+typedef svn_error_t *(*svn_delta_path_driver_cb_func2_t)(
+  void **dir_baton,
+  const svn_delta_editor_t *editor,
+  void *edit_baton,
+  void *parent_baton,
+  void *callback_baton,
+  const char *path,
+  apr_pool_t *pool);
+
+/* Like #svn_delta_path_driver_cb_func2_t but without the @a editor and
+ * @a edit_baton parameters. The user must arrange for the editor to be
+ * passed through @a callback_baton (if required, which it usually is).
+ *
+ * @deprecated Provided for backward compatibility with the 1.11 API.
  */
 typedef svn_error_t *(*svn_delta_path_driver_cb_func_t)(
   void **dir_baton,
@@ -1341,6 +1358,21 @@ typedef svn_error_t *(*svn_delta_path_dr
  *
  * Use @a scratch_pool for all necessary allocations.
  *
+ * @since New in 1.12.
+ */
+svn_error_t *
+svn_delta_path_driver3(const svn_delta_editor_t *editor,
+                       void *edit_baton,
+                       const apr_array_header_t *paths,
+                       svn_boolean_t sort_paths,
+                       svn_delta_path_driver_cb_func2_t callback_func,
+                       void *callback_baton,
+                       apr_pool_t *pool);
+
+/* Like svn_delta_path_driver3() but with a different callback function
+ * signature.
+ *
+ * @deprecated Provided for backward compatibility with the 1.11 API.
  * @since New in 1.8.
  */
 svn_error_t *
@@ -1397,7 +1429,7 @@ svn_error_t *
 svn_delta_path_driver_start(svn_delta_path_driver_state_t **state_p,
                             const svn_delta_editor_t *editor,
                             void *edit_baton,
-                            svn_delta_path_driver_cb_func_t callback_func,
+                            svn_delta_path_driver_cb_func2_t callback_func,
                             void *callback_baton,
                             apr_pool_t *result_pool);
 

Modified: subversion/trunk/subversion/libsvn_client/shelf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/shelf.c?rev=1852526&r1=1852525&r2=1852526&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/shelf.c (original)
+++ subversion/trunk/subversion/libsvn_client/shelf.c Wed Jan 30 14:38:52 2019
@@ -1454,9 +1454,6 @@ struct path_driver_cb_baton_t
 {
   svn_client__shelf_version_t *shelf_version;
   svn_client_ctx_t *ctx;
-
-  const svn_delta_editor_t *editor;
-  void *edit_baton;
 };
 
 /* Apply the changes for RELPATH from shelf storage to the WC.
@@ -1464,6 +1461,8 @@ struct path_driver_cb_baton_t
  * Implements svn_delta_path_driver_cb_func_t. */
 static svn_error_t *
 path_driver_cb_func(void **dir_baton_p,
+                    const svn_delta_editor_t *editor,
+                    void *edit_baton,
                     void *parent_baton,
                     void *callback_baton,
                     const char *relpath,
@@ -1496,8 +1495,8 @@ path_driver_cb_func(void **dir_baton_p,
   if (s->node_status == svn_wc_status_deleted
       || s->node_status == svn_wc_status_replaced)
     {
-      SVN_ERR(b->editor->delete_entry(relpath, SVN_INVALID_REVNUM,
-                                      parent_baton, scratch_pool));
+      SVN_ERR(editor->delete_entry(relpath, SVN_INVALID_REVNUM,
+                                   parent_baton, scratch_pool));
       if (s->node_status != svn_wc_status_replaced)
         {
           SVN_ERR(send_notification(to_wc_abspath, svn_wc_notify_update_delete,
@@ -1514,11 +1513,11 @@ path_driver_cb_func(void **dir_baton_p,
     {
       if (s->kind == svn_node_dir)
         {
-          SVN_ERR(b->editor->open_directory(relpath, parent_baton,
-                                            SVN_INVALID_REVNUM,
-                                            scratch_pool, dir_baton_p));
+          SVN_ERR(editor->open_directory(relpath, parent_baton,
+                                         SVN_INVALID_REVNUM,
+                                         scratch_pool, dir_baton_p));
           SVN_ERR(apply_prop_mods(base_props, work_props,
-                                  b->editor, NULL, *dir_baton_p,
+                                  editor, NULL, *dir_baton_p,
                                   scratch_pool));
         }
       else if (s->kind == svn_node_file)
@@ -1526,16 +1525,16 @@ path_driver_cb_func(void **dir_baton_p,
           void *file_baton;
 
           /* open */
-          SVN_ERR(b->editor->open_file(relpath, parent_baton,
-                                       SVN_INVALID_REVNUM,
-                                       scratch_pool, &file_baton));
+          SVN_ERR(editor->open_file(relpath, parent_baton,
+                                    SVN_INVALID_REVNUM,
+                                    scratch_pool, &file_baton));
           /* modifications */
           SVN_ERR(apply_file_mods(base_props, work_props,
                                   stored_base_abspath, stored_work_abspath,
-                                  b->editor, file_baton,
+                                  editor, file_baton,
                                   scratch_pool));
           /* close */
-          SVN_ERR(b->editor->close_file(file_baton, NULL, scratch_pool));
+          SVN_ERR(editor->close_file(file_baton, NULL, scratch_pool));
         }
       SVN_ERR(send_notification(to_wc_abspath, svn_wc_notify_update_update,
                                 s->kind,
@@ -1555,11 +1554,11 @@ path_driver_cb_func(void **dir_baton_p,
     {
       if (s->kind == svn_node_dir)
         {
-          SVN_ERR(b->editor->add_directory(relpath, parent_baton,
-                                           NULL, SVN_INVALID_REVNUM,
-                                           scratch_pool, dir_baton_p));
+          SVN_ERR(editor->add_directory(relpath, parent_baton,
+                                        NULL, SVN_INVALID_REVNUM,
+                                        scratch_pool, dir_baton_p));
           SVN_ERR(apply_prop_mods(NULL /*base*/, work_props,
-                                  b->editor, NULL, *dir_baton_p,
+                                  editor, NULL, *dir_baton_p,
                                   scratch_pool));
         }
       else if (s->kind == svn_node_file)
@@ -1567,16 +1566,16 @@ path_driver_cb_func(void **dir_baton_p,
           void *file_baton = NULL;
 
           /* add */
-          SVN_ERR(b->editor->add_file(relpath, parent_baton,
-                                      NULL, SVN_INVALID_REVNUM,
-                                      scratch_pool, &file_baton));
+          SVN_ERR(editor->add_file(relpath, parent_baton,
+                                   NULL, SVN_INVALID_REVNUM,
+                                   scratch_pool, &file_baton));
           /* modifications */
           SVN_ERR(apply_file_mods(NULL /*base*/, work_props,
                                   NULL /*base*/, stored_work_abspath,
-                                  b->editor, file_baton,
+                                  editor, file_baton,
                                   scratch_pool));
           /* close */
-          SVN_ERR(b->editor->close_file(file_baton, NULL, scratch_pool));
+          SVN_ERR(editor->close_file(file_baton, NULL, scratch_pool));
         }
       SVN_ERR(send_notification(to_wc_abspath,
                                 (s->node_status == svn_wc_status_replaced)
@@ -1642,8 +1641,6 @@ svn_client__shelf_replay(svn_client__she
 
   pdb.shelf_version = shelf_version;
   pdb.ctx = shelf_version->shelf->ctx;
-  pdb.editor = editor;
-  pdb.edit_baton = edit_baton;
 
   SVN_ERR(svn_delta_path_driver_start(&baton.path_driver_state,
                                       editor, edit_baton,

Modified: subversion/trunk/subversion/libsvn_delta/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/deprecated.c?rev=1852526&r1=1852525&r2=1852526&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_delta/deprecated.c Wed Jan 30 14:38:52 2019
@@ -30,6 +30,52 @@
 #include "svn_sorts.h"
 
 
+struct path_driver_2_to_3_baton_t
+{
+  svn_delta_path_driver_cb_func_t callback_func;
+  void *callback_baton;
+};
+
+/* Convert from a newer to older callback
+ */
+static svn_error_t *
+path_driver_2_to_3_func(void **dir_baton,
+                        const svn_delta_editor_t *editor,
+                        void *edit_baton,
+                        void *parent_baton,
+                        void *callback_baton,
+                        const char *path,
+                        apr_pool_t *pool)
+{
+  struct path_driver_2_to_3_baton_t *b = callback_baton;
+
+  /* Just drop the 'editor' parameters */
+  SVN_ERR(b->callback_func(dir_baton, parent_baton,
+                           b->callback_baton,
+                           path, pool));
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_delta_path_driver2(const svn_delta_editor_t *editor,
+                       void *edit_baton,
+                       const apr_array_header_t *paths,
+                       svn_boolean_t sort_paths,
+                       svn_delta_path_driver_cb_func_t callback_func,
+                       void *callback_baton,
+                       apr_pool_t *pool)
+{
+  struct path_driver_2_to_3_baton_t b;
+
+  b.callback_func = callback_func;
+  b.callback_baton = callback_baton;
+  SVN_ERR(svn_delta_path_driver3(editor, edit_baton,
+                                 paths, sort_paths,
+                                 path_driver_2_to_3_func, &b,
+                                 pool));
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_delta_path_driver(const svn_delta_editor_t *editor,
                       void *edit_baton,

Modified: subversion/trunk/subversion/libsvn_delta/path_driver.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/path_driver.c?rev=1852526&r1=1852525&r2=1852526&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/path_driver.c (original)
+++ subversion/trunk/subversion/libsvn_delta/path_driver.c Wed Jan 30 14:38:52 2019
@@ -131,11 +131,11 @@ count_components(const char *path)
 
 /*** Public interfaces ***/
 svn_error_t *
-svn_delta_path_driver2(const svn_delta_editor_t *editor,
+svn_delta_path_driver3(const svn_delta_editor_t *editor,
                        void *edit_baton,
                        const apr_array_header_t *paths,
                        svn_boolean_t sort_paths,
-                       svn_delta_path_driver_cb_func_t callback_func,
+                       svn_delta_path_driver_cb_func2_t callback_func,
                        void *callback_baton,
                        apr_pool_t *pool)
 {
@@ -189,7 +189,7 @@ struct svn_delta_path_driver_state_t
 {
   const svn_delta_editor_t *editor;
   void *edit_baton;
-  svn_delta_path_driver_cb_func_t callback_func;
+  svn_delta_path_driver_cb_func2_t callback_func;
   void *callback_baton;
   apr_array_header_t *db_stack;
   const char *last_path;
@@ -200,7 +200,7 @@ svn_error_t *
 svn_delta_path_driver_start(svn_delta_path_driver_state_t **state_p,
                             const svn_delta_editor_t *editor,
                             void *edit_baton,
-                            svn_delta_path_driver_cb_func_t callback_func,
+                            svn_delta_path_driver_cb_func2_t callback_func,
                             void *callback_baton,
                             apr_pool_t *pool)
 {
@@ -314,7 +314,9 @@ svn_delta_path_driver_step(svn_delta_pat
     parent_db = NULL;
   db = NULL;  /* predictable behaviour for callbacks that don't set it */
   subpool = svn_pool_create(state->pool);
-  SVN_ERR(state->callback_func(&db, parent_db, state->callback_baton,
+  SVN_ERR(state->callback_func(&db,
+                               state->editor, state->edit_baton, parent_db,
+                               state->callback_baton,
                                path, subpool));
   if (db)
     {