subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1768309 - in /subversion/trunk/subversion: include/private/svn_ra_svn_private.h libsvn_ra_svn/client.c libsvn_ra_svn/marshal.c libsvn_ra_svn/protocol svnserve/serve.c
Date Sun, 06 Nov 2016 11:46:26 GMT
Author: stefan2
Date: Sun Nov  6 11:46:26 2016
New Revision: 1768309

URL: http://svn.apache.org/viewvc?rev=1768309&view=rev
Log:
Change the ra_svn protocol for the list command response.
Make all dirent fields optional and have the dirent-fields flags control
which ones to transmit.

* subversion/libsvn_ra_svn/protocol
  (3.1.1. Main Command Set):  Replace the sub-struct with a list of
                              optional fields for the 'list' command.
                              Also document the optional nature of the
                              'kind' field and that the dirent-field is
                              extensible.

* subversion/include/private/svn_ra_svn_private.h
  (svn_ra_svn__write_dirent): Declare new serialization utility.

* subversion/libsvn_ra_svn/marshal.c
  (svn_ra_svn__write_dirent): Implement.

* subversion/svnserve/serve.c
  (list_receiver_baton_t): Pass on the dirent-fields instead of a simple
                           flag such that we can send exactly what the
                           client asked for.
  (list_receiver): Call the new serialization utility.
  (list): Update caller to baton change.

* subversion/libsvn_ra_svn/client.c
  (ra_svn_list): Update the format string to reflect the protocol change.

Suggested by: danielsh

Modified:
    subversion/trunk/subversion/include/private/svn_ra_svn_private.h
    subversion/trunk/subversion/libsvn_ra_svn/client.c
    subversion/trunk/subversion/libsvn_ra_svn/marshal.c
    subversion/trunk/subversion/libsvn_ra_svn/protocol
    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=1768309&r1=1768308&r2=1768309&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_ra_svn_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_ra_svn_private.h Sun Nov  6 11:46:26 2016
@@ -1008,6 +1008,19 @@ svn_ra_svn__write_data_log_entry(svn_ra_
                                  svn_boolean_t invalid_revnum,
                                  unsigned revprop_count);
 
+/** Send a directory entry @a dirent for @a path over connection @a conn.
+ * Use @a pool for allocations.
+ *
+ * Depending on the flags in @a dirent_fields, only selected elements will
+ * be transmitted.
+ */
+svn_error_t *
+svn_ra_svn__write_dirent(svn_ra_svn_conn_t *conn,
+                         apr_pool_t *pool,
+                         const char *path,
+                         svn_dirent_t *dirent,
+                         apr_uint64_t dirent_fields);
+
 /**
  * @}
  */

Modified: subversion/trunk/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/client.c?rev=1768309&r1=1768308&r2=1768309&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/client.c Sun Nov  6 11:46:26 2016
@@ -2979,7 +2979,7 @@ ra_svn_list(svn_ra_session_t *session,
         return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
                                 _("List entry not a list"));
       SVN_ERR(svn_ra_svn__parse_tuple(&item->u.list,
-                                      "cw?(nbr(?c)(?c))",
+                                      "cw?(?n)(?b)(?r)(?c)(?c)",
                                       &dirent_path, &kind_word, &dirent.size,
                                       &dirent.has_props, &dirent.created_rev,
                                       &date, &dirent.last_author));

Modified: subversion/trunk/subversion/libsvn_ra_svn/marshal.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/marshal.c?rev=1768309&r1=1768308&r2=1768309&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/marshal.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/marshal.c Sun Nov  6 11:46:26 2016
@@ -2916,6 +2916,57 @@ svn_ra_svn__write_data_log_entry(svn_ra_
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_ra_svn__write_dirent(svn_ra_svn_conn_t *conn,
+                         apr_pool_t *pool,
+                         const char *path,
+                         svn_dirent_t *dirent,
+                         apr_uint64_t dirent_fields)
+{
+  const char *kind = (dirent_fields & SVN_DIRENT_KIND)
+                   ? svn_node_kind_to_word(dirent->kind)
+                   : "unknown";
+
+  if (dirent_fields & ~SVN_DIRENT_KIND)
+    {
+      SVN_ERR(write_tuple_start_list(conn, pool));
+      SVN_ERR(write_tuple_cstring(conn, pool, path));
+      SVN_ERR(writebuf_write(conn, pool, kind, strlen(kind)));
+
+      SVN_ERR(writebuf_write_literal(conn, pool, " ( "));
+      if (dirent_fields & SVN_DIRENT_SIZE)
+        SVN_ERR(svn_ra_svn__write_number(conn, pool, dirent->size));
+
+      SVN_ERR(writebuf_write_literal(conn, pool, ") ( "));
+      if (dirent_fields & SVN_DIRENT_HAS_PROPS)
+        SVN_ERR(write_tuple_boolean(conn, pool, dirent->has_props));
+
+      SVN_ERR(writebuf_write_literal(conn, pool, ") ( "));
+      if (dirent_fields & SVN_DIRENT_CREATED_REV)
+        SVN_ERR(write_tuple_revision(conn, pool, dirent->created_rev));
+
+      SVN_ERR(writebuf_write_literal(conn, pool, ") ( "));
+      if (dirent_fields & SVN_DIRENT_TIME)
+        SVN_ERR(write_tuple_cstring_opt(conn, pool,
+                                  svn_time_to_cstring(dirent->time, pool)));
+
+      SVN_ERR(writebuf_write_literal(conn, pool, ") ( "));
+      if (dirent_fields & SVN_DIRENT_LAST_AUTHOR)
+        SVN_ERR(write_tuple_cstring_opt(conn, pool, dirent->last_author));
+
+      SVN_ERR(writebuf_write_literal(conn, pool, ") ) "));
+    }
+  else
+    {
+      SVN_ERR(write_tuple_start_list(conn, pool));
+      SVN_ERR(write_tuple_cstring(conn, pool, path));
+      SVN_ERR(writebuf_write(conn, pool, kind, strlen(kind)));
+      SVN_ERR(writebuf_write_literal(conn, pool, " ) "));
+    }
+
+  return SVN_NO_ERROR;
+}
+
 /* If condition COND is not met, return a "malformed network data" error.
  */
 #define CHECK_PROTOCOL_COND(cond)\

Modified: subversion/trunk/subversion/libsvn_ra_svn/protocol
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/protocol?rev=1768309&r1=1768308&r2=1768309&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/protocol (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/protocol Sun Nov  6 11:46:26 2016
@@ -493,13 +493,16 @@ second place for auth-request point as n
     params:   ( path:string [ rev:number ] depth:word
                 ( field:dirent-field ... ) ( pattern:string ... ) )
     Before sending response, server sends dirents, ending with "done".
-    dirent:   ( rel-path:string kind:node-kind ? ( size:number
-                has-props:bool created-rev:number
-                [ created-date:string ] [ last-author:string ] ) )
+    dirent:   ( rel-path:string kind:node-kind
+                ? [ size:number ] [ has-props:bool ] [ created-rev:number ]
+                  [ created-date:string ] [ last-author:string ] )
               | done
     dirent-field: kind | size | has-props | created-rev | time | last-author
+                  | word
     response: ( )
     New in svn 1.10.  If rev is not specified, the youngest revision is used.
+    If the dirent-fields don't contain "kind", "unknown" will be returned
+    in the kind field.
 
 3.1.2. Editor Command Set
 

Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1768309&r1=1768308&r2=1768309&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Sun Nov  6 11:46:26 2016
@@ -3544,8 +3544,8 @@ typedef struct list_receiver_baton_t
   /* Send the data through this connection. */
   svn_ra_svn_conn_t *conn;
 
-  /* If set, send path and kind only. */
-  svn_boolean_t path_info_only;
+  /* Send the field selected by these flags. */
+  apr_uint64_t dirent_fields;
 } list_receiver_baton_t;
 
 /* Implements svn_repos_dirent_receiver_t, sending DIRENT and PATH to the
@@ -3557,19 +3557,8 @@ list_receiver(const char *path,
               apr_pool_t *pool)
 {
   list_receiver_baton_t *b = baton;
-
-  if (b->path_info_only)
-    SVN_ERR(svn_ra_svn__write_tuple(b->conn, pool, "cw", path,
-                                    svn_node_kind_to_word(dirent->kind)));
-  else
-    SVN_ERR(svn_ra_svn__write_tuple(b->conn, pool, "cw(nbr(?c)(?c))", path,
-                                    svn_node_kind_to_word(dirent->kind),
-                                    (apr_uint64_t) dirent->size,
-                                    dirent->has_props, dirent->created_rev,
-                                    svn_time_to_cstring(dirent->time, pool),
-                                    dirent->last_author));
-
-  return SVN_NO_ERROR;
+  return svn_error_trace(svn_ra_svn__write_dirent(b->conn, pool, path, dirent,
+                                                  b->dirent_fields));
 }
 
 static svn_error_t *
@@ -3585,7 +3574,7 @@ list(svn_ra_svn_conn_t *conn,
   apr_array_header_t *patterns;
   svn_fs_root_t *root;
   const char *depth_word;
-  apr_uint64_t dirent_fields;
+  svn_boolean_t path_info_only;
   svn_ra_svn__list_t *dirent_fields_list = NULL;
   svn_ra_svn__list_t *patterns_list = NULL;
   int i;
@@ -3601,9 +3590,10 @@ list(svn_ra_svn_conn_t *conn,
                                   &depth_word, &dirent_fields_list,
                                   &patterns_list));
 
-  depth = svn_depth_from_word(depth_word);
-  SVN_ERR(parse_dirent_fields(&dirent_fields, dirent_fields_list));
+  rb.conn = conn;
+  SVN_ERR(parse_dirent_fields(&rb.dirent_fields, dirent_fields_list));
 
+  depth = svn_depth_from_word(depth_word);
   full_path = svn_fspath__join(b->repository->fs_path->data,
                                svn_relpath_canonicalize(path, pool), pool);
 
@@ -3629,16 +3619,14 @@ list(svn_ra_svn_conn_t *conn,
 
   SVN_ERR(log_command(b, conn, pool, "%s",
                       svn_log__list(full_path, rev, patterns, depth,
-                                    dirent_fields, pool)));
+                                    rb.dirent_fields, pool)));
 
   /* Fetch the root of the appropriate revision. */
   SVN_CMD_ERR(svn_fs_revision_root(&root, b->repository->fs, rev, pool));
 
   /* Fetch the directory entries if requested and send them immediately. */
-  rb.conn = conn;
-  rb.path_info_only = (dirent_fields & ~SVN_DIRENT_KIND) == 0;
-
-  err = svn_repos_list(root, full_path, patterns, depth, rb.path_info_only,
+  path_info_only = (rb.dirent_fields & ~SVN_DIRENT_KIND) == 0;
+  err = svn_repos_list(root, full_path, patterns, depth, path_info_only,
                        authz_check_access_cb_func(b), &ab, list_receiver,
                        &rb, NULL, NULL, pool);
 



Mime
View raw message