subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1700861 - in /subversion/trunk/subversion: include/private/svn_ra_svn_private.h libsvn_ra_svn/deprecated.c libsvn_ra_svn/marshal.c svnserve/serve.c
Date Wed, 02 Sep 2015 18:09:53 GMT
Author: stefan2
Date: Wed Sep  2 18:09:52 2015
New Revision: 1700861

URL: http://svn.apache.org/r1700861
Log:
Resolve the last API dependency that prevents us from chaning the ra_svn
list item type: the (deprecated) command handler API.

This switches the private API to a new svn_ra_svn__command_handler type
which expects an svn_ra_svn__list_t parameter instead of an APR array.
Then there is the usual translation code between public & private API.
However, since we can't easily translate the callbacks in the API-provided
table, we must allow for both callback types in our new command instance.
Upon invocation we decide which one to call (only one of them will be set).

* subversion/include/private/svn_ra_svn_private.h
  (svn_ra_svn__command_handler): New callback type, similar to
                                 svn_ra_svn_command_handler.
  (svn_ra_svn__cmd_entry_t): New command structure, similar to
                             svn_ra_svn_cmd_entry_t.
  (svn_ra_svn__handle_commands2): Expect commands of the new type.

* subversion/libsvn_ra_svn/deprecated.c
  (svn_ra_svn_handle_commands2): Translate command table.
  (svn_ra_svn_handle_commands): To reuse code, implement this in terms of
                                svn_ra_svn_handle_commands2 now.

* subversion/libsvn_ra_svn/marshal.c
  (svn_ra_svn__handle_command): Expect the new command type now.
                                Translate parameters if we have to call
                                legacy handlers.
  (svn_ra_svn__handle_commands2): Switch to the new command type.

* subversion/svnserve/serve.c
  (report_commands,
   main_commands): Update command table definition.
  (serve_interruptable): Switch to the new command type.

Modified:
    subversion/trunk/subversion/include/private/svn_ra_svn_private.h
    subversion/trunk/subversion/libsvn_ra_svn/deprecated.c
    subversion/trunk/subversion/libsvn_ra_svn/marshal.c
    subversion/trunk/subversion/svnserve/serve.c

Modified: subversion/trunk/subversion/include/private/svn_ra_svn_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_ra_svn_private.h?rev=1700861&r1=1700860&r2=1700861&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_ra_svn_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_ra_svn_private.h Wed Sep  2 18:09:52 2015
@@ -57,6 +57,32 @@ typedef struct svn_ra_svn__item_t
   } u;
 } svn_ra_svn__item_t;
 
+/** Command handler, used by svn_ra_svn__handle_commands(). */
+typedef svn_error_t *(*svn_ra_svn__command_handler)(svn_ra_svn_conn_t *conn,
+                                                    apr_pool_t *pool,
+                                                    svn_ra_svn__list_t *params,
+                                                    void *baton);
+
+/** Command table, used by svn_ra_svn_handle_commands().
+ */
+typedef struct svn_ra_svn__cmd_entry_t
+{
+  /** Name of the command */
+  const char *cmdname;
+
+  /** Handler for the command */
+  svn_ra_svn__command_handler handler;
+
+  /** Only set when used through a deprecated API.
+   * HANDLER is NULL in that case. */
+  svn_ra_svn_command_handler deprecated_handler;
+
+  /** Termination flag.  If set, command-handling will cease after
+   * command is processed. */
+  svn_boolean_t terminate;
+} svn_ra_svn__cmd_entry_t;
+
+
 /* Return a deep copy of the SOURCE array containing private API
  * svn_ra_svn__item_t SOURCE to public API *TARGET, allocating
  * sub-structures in RESULT_POOL. */
@@ -359,7 +385,7 @@ svn_ra_svn__handle_command(svn_boolean_t
 svn_error_t *
 svn_ra_svn__handle_commands2(svn_ra_svn_conn_t *conn,
                              apr_pool_t *pool,
-                             const svn_ra_svn_cmd_entry_t *commands,
+                             const svn_ra_svn__cmd_entry_t *commands,
                              void *baton,
                              svn_boolean_t error_on_disconnect);
 

Modified: subversion/trunk/subversion/libsvn_ra_svn/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/deprecated.c?rev=1700861&r1=1700860&r2=1700861&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/deprecated.c Wed Sep  2 18:09:52 2015
@@ -188,8 +188,23 @@ svn_ra_svn_handle_commands2(svn_ra_svn_c
                             void *baton,
                             svn_boolean_t error_on_disconnect)
 {
+  apr_size_t i, count = 0;
+  svn_ra_svn__cmd_entry_t *internal;
+
+  while (commands[count].cmdname)
+    count++;
+
+  internal = apr_pcalloc(pool, count * sizeof(*internal));
+  for (i = 0; i < count; ++i)
+    {
+      internal[i].cmdname = commands[i].cmdname;
+      internal[i].handler = NULL;
+      internal[i].deprecated_handler = commands[i].handler;
+      internal[i].terminate = commands[i].terminate;
+    }
+
   return svn_error_trace(svn_ra_svn__handle_commands2(conn, pool,
-                                                      commands, baton,
+                                                      internal, baton,
                                                       error_on_disconnect));
 }
 
@@ -199,9 +214,9 @@ svn_ra_svn_handle_commands(svn_ra_svn_co
                            const svn_ra_svn_cmd_entry_t *commands,
                            void *baton)
 {
-  return svn_error_trace(svn_ra_svn__handle_commands2(conn, pool,
-                                                      commands, baton,
-                                                      FALSE));
+  return svn_error_trace(svn_ra_svn_handle_commands2(conn, pool,
+                                                     commands, baton,
+                                                     FALSE));
 }
 
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_ra_svn/marshal.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/marshal.c?rev=1700861&r1=1700860&r2=1700861&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/marshal.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/marshal.c Wed Sep  2 18:09:52 2015
@@ -1763,7 +1763,7 @@ svn_ra_svn__handle_command(svn_boolean_t
   const char *cmdname;
   svn_error_t *err, *write_err;
   svn_ra_svn__list_t *params;
-  const svn_ra_svn_cmd_entry_t *command;
+  const svn_ra_svn__cmd_entry_t *command;
 
   *terminate = FALSE;
   err = svn_ra_svn__read_tuple(conn, pool, "wl", &cmdname, &params);
@@ -1782,7 +1782,21 @@ svn_ra_svn__handle_command(svn_boolean_t
   command = svn_hash_gets(cmd_hash, cmdname);
   if (command)
     {
-      err = (*command->handler)(conn, pool, params, baton);
+      /* Call the standard command handler.
+       * If that is not set, then this is a lecagy API call and we invoke
+       * the legacy command handler. */
+      if (command->handler)
+        {
+          err = (*command->handler)(conn, pool, params, baton);
+        }
+      else
+        {
+          apr_array_header_t *deprecated_params
+            = svn_ra_svn__to_public_array(params, pool);
+          err = (*command->deprecated_handler)(conn, pool, deprecated_params,
+                                               baton);
+        }
+
       *terminate = command->terminate;
     }
   else
@@ -1807,13 +1821,13 @@ svn_ra_svn__handle_command(svn_boolean_t
 svn_error_t *
 svn_ra_svn__handle_commands2(svn_ra_svn_conn_t *conn,
                              apr_pool_t *pool,
-                             const svn_ra_svn_cmd_entry_t *commands,
+                             const svn_ra_svn__cmd_entry_t *commands,
                              void *baton,
                              svn_boolean_t error_on_disconnect)
 {
   apr_pool_t *subpool = svn_pool_create(pool);
   apr_pool_t *iterpool = svn_pool_create(subpool);
-  const svn_ra_svn_cmd_entry_t *command;
+  const svn_ra_svn__cmd_entry_t *command;
   apr_hash_t *cmd_hash = apr_hash_make(subpool);
 
   for (command = commands; command->cmdname; command++)

Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1700861&r1=1700860&r2=1700861&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Wed Sep  2 18:09:52 2015
@@ -925,12 +925,12 @@ abort_report(svn_ra_svn_conn_t *conn,
   return SVN_NO_ERROR;
 }
 
-static const svn_ra_svn_cmd_entry_t report_commands[] = {
+static const svn_ra_svn__cmd_entry_t report_commands[] = {
   { "set-path",      set_path },
   { "delete-path",   delete_path },
   { "link-path",     link_path },
-  { "finish-report", finish_report, TRUE },
-  { "abort-report",  abort_report,  TRUE },
+  { "finish-report", finish_report, NULL, TRUE },
+  { "abort-report",  abort_report,  NULL, TRUE },
   { NULL }
 };
 
@@ -3458,7 +3458,7 @@ get_inherited_props(svn_ra_svn_conn_t *c
   return SVN_NO_ERROR;
 }
 
-static const svn_ra_svn_cmd_entry_t main_commands[] = {
+static const svn_ra_svn__cmd_entry_t main_commands[] = {
   { "reparent",        reparent },
   { "get-latest-rev",  get_latest_rev },
   { "get-dated-rev",   get_dated_rev },
@@ -4072,7 +4072,7 @@ serve_interruptable(svn_boolean_t *termi
 {
   svn_boolean_t terminate = FALSE;
   svn_error_t *err = NULL;
-  const svn_ra_svn_cmd_entry_t *command;
+  const svn_ra_svn__cmd_entry_t *command;
   apr_pool_t *iterpool = svn_pool_create(pool);
 
   /* Prepare command parser. */



Mime
View raw message