subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1769485 - in /subversion/trunk/subversion: include/ libsvn_client/ libsvn_ra_svn/ libsvn_repos/ libsvn_subr/ svn/ svnbench/ svnserve/
Date Sun, 13 Nov 2016 10:42:25 GMT
Author: stefan2
Date: Sun Nov 13 10:42:24 2016
New Revision: 1769485

URL: http://svn.apache.org/viewvc?rev=1769485&view=rev
Log:
Change the svn_*_list APIs to use NULL as the "don't filter by pattern"
parameter instead of an empty pattern list.

Suggested by: Patrick Steinhardt (patrick.steinhardt at elegosoft.com)

* subversion/include/svn_repos.h
  (svn_repos_list):  Document the new PATTERN options behavior.

* subversion/libsvn_repos/list.c
  (matches_any):  Implement the new behavior.
  (svn_repos_list):  Empty lists will almost always be created by dumb
                     scripts.  It's probably a good idea to explicitly
                     not waste any resources in the degenerate case.

* subversion/include/svn_ra.h
  (svn_ra_list):  Document the new PATTERN options behavior.

* subversion/libsvn_ra_svn/protocol
  (3.1.1. Main Command Set):  The patterns list in the list command is
                              now optional.

* subversion/libsvn_subr/log.c
  (svn_log__list):  Make the logging cope with NULL pattern lists.

* subversion/svnserve/serve.c
  (list): Receive NULL for PATTERNS, if no list was received.

* subversion/libsvn_ra_svn/client.c
  (ra_svn_list):  Omit the pattern list entirely, if patterns is NULL. 

* subversion/include/svn_client.h
  (svn_client_list4):  Document the new PATTERN options behavior.
  (svn_client_list3):  Update docstring.

* subversion/libsvn_client/deprecated.c
  (svn_client_list3):  Update implementation.

* subversion/libsvn_client/list.c
  (match_patterns):  Implement the new behavior.
  (list_internal):  Update docstring.

* subversion/svn/list-cmd.c
  (svn_cl__list):  If no patterns were specified, pass NULL to the API.

* subversion/svnbench/null-list-cmd.c
  (svn_cl__null_list):  Same.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/include/svn_ra.h
    subversion/trunk/subversion/include/svn_repos.h
    subversion/trunk/subversion/libsvn_client/deprecated.c
    subversion/trunk/subversion/libsvn_client/list.c
    subversion/trunk/subversion/libsvn_ra_svn/client.c
    subversion/trunk/subversion/libsvn_ra_svn/protocol
    subversion/trunk/subversion/libsvn_repos/list.c
    subversion/trunk/subversion/libsvn_subr/log.c
    subversion/trunk/subversion/svn/list-cmd.c
    subversion/trunk/subversion/svnbench/null-list-cmd.c
    subversion/trunk/subversion/svnserve/serve.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Sun Nov 13 10:42:24 2016
@@ -6402,7 +6402,7 @@ typedef svn_error_t *(*svn_client_list_f
  * its children.  If @a path_or_url is non-existent, return
  * #SVN_ERR_FS_NOT_FOUND.
  *
- * If the @a pattern array of <tt>const char *</tt> is not empty, only
+ * If the @a pattern array of <tt>const char *</tt> is not @c NULL, only
  * report paths whose last segment matches one of the specified glob
  * patterns.  This does not affect the size of the tree nor the number of
  * externals being covered.
@@ -6445,7 +6445,7 @@ svn_client_list4(const char *path_or_url
                  svn_client_ctx_t *ctx,
                  apr_pool_t *scratch_pool);
 
-/** Similar to svn_client_list4(), but with @a patterm left empty.
+/** Similar to svn_client_list4(), but with @a patterm set to @c NULL.
  *
  * @since New in 1.8.
  *

Modified: subversion/trunk/subversion/include/svn_ra.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_ra.h?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_ra.h (original)
+++ subversion/trunk/subversion/include/svn_ra.h Sun Nov 13 10:42:24 2016
@@ -1159,10 +1159,11 @@ typedef svn_error_t *(* svn_ra_dirent_re
  * you may set @a path_info_only to receive only the path name and the node
  * kind.
  *
- * @a patterns is an array of <tt>const char *</tt>.  If it is not empty,
- * only those directory entries will be reported whose last path segment
- * matches at least one of these patterns.  This feature uses @c apr_fnmatch
- * for glob matching and requiring '.' to matched by dots in the path.
+ * @a patterns is an optional array of <tt>const char *</tt>.  If it is
+ * not @c NULL, only those directory entries will be reported whose last
+ * path segment matches at least one of these patterns.  This feature uses
+ * @c apr_fnmatch for glob matching and requiring '.' to matched by dots
+ * in the path.
  *
  * If @a authz_read_func is not @c NULL, this function will neither report
  * entries nor recurse into directories that the user has no access to.

Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Sun Nov 13 10:42:24 2016
@@ -1737,10 +1737,11 @@ typedef svn_error_t *(* svn_repos_dirent
  * you may set @a path_info_only to receive only the path name and the node
  * kind.  The entries will be reported ordered by their path.
  *
- * @a patterns is an array of <tt>const char *</tt>.  If it is not empty,
- * only those directory entries will be reported whose last path segment
- * matches at least one of these patterns.  This feature uses @c apr_fnmatch
- * for glob matching and requiring '.' to matched by dots in the path.
+ * @a patterns is an optional array of <tt>const char *</tt>.  If it is
+ * not @c NULL, only those directory entries will be reported whose last
+ * path segment matches at least one of these patterns.  This feature uses
+ * @c apr_fnmatch for glob matching and requiring '.' to matched by dots
+ * in the path.
  *
  * If @a authz_read_func is not @c NULL, this function will neither report
  * entries nor recurse into directories that the user has no access to.

Modified: subversion/trunk/subversion/libsvn_client/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/deprecated.c?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_client/deprecated.c Sun Nov 13 10:42:24 2016
@@ -1343,9 +1343,8 @@ svn_client_list3(const char *path_or_url
                  svn_client_ctx_t *ctx,
                  apr_pool_t *pool)
 {
-  apr_array_header_t *patterns = apr_array_make(pool, 0, sizeof(const char *));
   return svn_error_trace(svn_client_list4(path_or_url, peg_revision,
-                                          revision, patterns, depth,
+                                          revision, NULL, depth,
                                           dirent_fields, fetch_locks,
                                           include_externals,
                                           list_func, baton, ctx, pool));

Modified: subversion/trunk/subversion/libsvn_client/list.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/list.c?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/list.c (original)
+++ subversion/trunk/subversion/libsvn_client/list.c Sun Nov 13 10:42:24 2016
@@ -75,7 +75,7 @@ match_patterns(const char *s,
                apr_array_header_t *patterns)
 {
   int i;
-  if (patterns->nelts == 0)
+  if (!patterns)
     return TRUE;
 
   for (i = 0; i < patterns->nelts; ++i)
@@ -280,7 +280,7 @@ list_receiver(const char *rel_path,
    subdirectories (at svn_depth_empty).  Else if DEPTH is
    svn_depth_empty, just list PATH_OR_URL with none of its entries.
 
-   If PATTERNS is not empty, the last path segments must match at least
+   If PATTERNS is not NULL, the last path segments must match at least
    one of const char * patterns in it or the respective dirent will not
    be reported.
 

Modified: subversion/trunk/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/client.c?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/client.c Sun Nov 13 10:42:24 2016
@@ -2948,12 +2948,16 @@ ra_svn_list(svn_ra_session_t *session,
   SVN_ERR(svn_ra_svn__write_tuple(conn, scratch_pool, "w(c(?r)w(!", "list",
                                   path, revision, svn_depth_to_word(depth)));
   SVN_ERR(send_dirent_fields(conn, dirent_fields, scratch_pool));
-  SVN_ERR(svn_ra_svn__write_tuple(conn, scratch_pool, "!)(!"));
 
-  for (i = 0; i < patterns->nelts; ++i)
+  if (patterns)
     {
-      const char *pattern = APR_ARRAY_IDX(patterns, i, const char *);
-      SVN_ERR(svn_ra_svn__write_cstring(conn, scratch_pool, pattern));
+      SVN_ERR(svn_ra_svn__write_tuple(conn, scratch_pool, "!)(!"));
+
+      for (i = 0; i < patterns->nelts; ++i)
+        {
+          const char *pattern = APR_ARRAY_IDX(patterns, i, const char *);
+          SVN_ERR(svn_ra_svn__write_cstring(conn, scratch_pool, pattern));
+        }
     }
 
   SVN_ERR(svn_ra_svn__write_tuple(conn, scratch_pool, "!))"));

Modified: subversion/trunk/subversion/libsvn_ra_svn/protocol
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/protocol?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/protocol (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/protocol Sun Nov 13 10:42:24 2016
@@ -491,7 +491,7 @@ second place for auth-request point as n
 
   list
     params:   ( path:string [ rev:number ] depth:word
-                ( field:dirent-field ... ) ( pattern:string ... ) )
+                ( 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 ]

Modified: subversion/trunk/subversion/libsvn_repos/list.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/list.c?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/list.c (original)
+++ subversion/trunk/subversion/libsvn_repos/list.c Sun Nov 13 10:42:24 2016
@@ -97,7 +97,7 @@ matches_any(const char *dirname,
             apr_array_header_t *patterns)
 {
   int i;
-  if (!patterns->nelts)
+  if (!patterns)
     return TRUE;
 
   for (i = 0; i < patterns->nelts; ++i)
@@ -312,6 +312,11 @@ svn_repos_list(svn_fs_root_t *root,
                                _("Path '%s' not found"), path);
     }
 
+  /* Special case: Empty pattern list.
+   * We don't want the server to waste time here. */
+  if (patterns && patterns->nelts == 0)
+    return SVN_NO_ERROR;
+
   /* Actually report PATH, if it passes the filters. */
   if (matches_any(svn_dirent_dirname(path, scratch_pool), patterns))
     SVN_ERR(report_dirent(root, path, kind, path_info_only,

Modified: subversion/trunk/subversion/libsvn_subr/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/log.c?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/log.c (original)
+++ subversion/trunk/subversion/libsvn_subr/log.c Sun Nov 13 10:42:24 2016
@@ -410,11 +410,18 @@ svn_log__list(const char *path, svn_revn
   else
     log_path = "/";
 
-  for (i = 0; i < patterns->nelts; ++i)
+  if (patterns)
     {
-      const char *pattern = APR_ARRAY_IDX(patterns, i, const char *);
-      svn_stringbuf_appendbyte(pattern_text, ' ');
-      svn_stringbuf_appendcstr(pattern_text, pattern);
+      for (i = 0; i < patterns->nelts; ++i)
+        {
+          const char *pattern = APR_ARRAY_IDX(patterns, i, const char *);
+          svn_stringbuf_appendbyte(pattern_text, ' ');
+          svn_stringbuf_appendcstr(pattern_text, pattern);
+        }
+    }
+  else
+    {
+      svn_stringbuf_appendcstr(pattern_text, " <ANY>");
     }
 
   return apr_psprintf(pool, "list %s r%ld%s%s", log_path, revision,

Modified: subversion/trunk/subversion/svn/list-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/list-cmd.c?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/list-cmd.c (original)
+++ subversion/trunk/subversion/svn/list-cmd.c Sun Nov 13 10:42:24 2016
@@ -351,7 +351,7 @@ svn_cl__list(apr_getopt_t *os,
       const char *target = APR_ARRAY_IDX(targets, i, const char *);
       const char *truepath;
       svn_opt_revision_t peg_revision;
-      apr_array_header_t *patterns;
+      apr_array_header_t *patterns = NULL;
       int k;
 
       /* Initialize the following variables for
@@ -362,7 +362,6 @@ svn_cl__list(apr_getopt_t *os,
 
       svn_pool_clear(subpool);
 
-      patterns = apr_array_make(subpool, 4, sizeof(const char *));
       SVN_ERR(svn_cl__check_cancel(ctx->cancel_baton));
 
       /* Get peg revisions. */
@@ -379,20 +378,23 @@ svn_cl__list(apr_getopt_t *os,
         }
 
       if (opt_state->search_patterns)
-        for (k = 0; k < opt_state->search_patterns->nelts; ++k)
-          {
-            apr_array_header_t *pattern_group
-              = APR_ARRAY_IDX(opt_state->search_patterns, k,
-                              apr_array_header_t *);
-
-            /* Should never fail but ... */
-            if (pattern_group->nelts != 1)
-              return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'search-and' option is not supported"));
-
-            APR_ARRAY_PUSH(patterns, const char *)
-              = APR_ARRAY_IDX(pattern_group, 0, const char *);
-          }
+        {
+          patterns = apr_array_make(subpool, 4, sizeof(const char *));
+          for (k = 0; k < opt_state->search_patterns->nelts; ++k)
+            {
+              apr_array_header_t *pattern_group
+                = APR_ARRAY_IDX(opt_state->search_patterns, k,
+                                apr_array_header_t *);
+
+              /* Should never fail but ... */
+              if (pattern_group->nelts != 1)
+                return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                  _("'search-and' option is not supported"));
+
+              APR_ARRAY_PUSH(patterns, const char *)
+                = APR_ARRAY_IDX(pattern_group, 0, const char *);
+            }
+        }
 
       err = svn_client_list4(truepath, &peg_revision,
                              &(opt_state->start_revision), patterns,

Modified: subversion/trunk/subversion/svnbench/null-list-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnbench/null-list-cmd.c?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/svnbench/null-list-cmd.c (original)
+++ subversion/trunk/subversion/svnbench/null-list-cmd.c Sun Nov 13 10:42:24 2016
@@ -122,12 +122,11 @@ svn_cl__null_list(apr_getopt_t *os,
       const char *target = APR_ARRAY_IDX(targets, i, const char *);
       const char *truepath;
       svn_opt_revision_t peg_revision;
-      apr_array_header_t *patterns;
+      apr_array_header_t *patterns = NULL;
       int k;
 
       svn_pool_clear(subpool);
 
-      patterns = apr_array_make(subpool, 4, sizeof(const char *));
       SVN_ERR(svn_cl__check_cancel(ctx->cancel_baton));
 
       /* Get peg revisions. */
@@ -135,20 +134,23 @@ svn_cl__null_list(apr_getopt_t *os,
                                  subpool));
 
       if (opt_state->search_patterns)
-        for (k = 0; k < opt_state->search_patterns->nelts; ++k)
-          {
-            apr_array_header_t *pattern_group
-              = APR_ARRAY_IDX(opt_state->search_patterns, k,
-                              apr_array_header_t *);
-
-            /* Should never fail but ... */
-            if (pattern_group->nelts != 1)
-              return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'search-and' option is not supported"));
-
-            APR_ARRAY_PUSH(patterns, const char *)
-              = APR_ARRAY_IDX(pattern_group, 0, const char *);
-          }
+        {
+          patterns = apr_array_make(subpool, 4, sizeof(const char *));
+          for (k = 0; k < opt_state->search_patterns->nelts; ++k)
+            {
+              apr_array_header_t *pattern_group
+                = APR_ARRAY_IDX(opt_state->search_patterns, k,
+                                apr_array_header_t *);
+
+              /* Should never fail but ... */
+              if (pattern_group->nelts != 1)
+                return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                  _("'search-and' option is not supported"));
+
+              APR_ARRAY_PUSH(patterns, const char *)
+                = APR_ARRAY_IDX(pattern_group, 0, const char *);
+            }
+        }
 
       err = svn_client_list4(truepath, &peg_revision,
                              &(opt_state->start_revision), patterns,

Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1769485&r1=1769484&r2=1769485&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Sun Nov 13 10:42:24 2016
@@ -3571,7 +3571,7 @@ list(svn_ra_svn_conn_t *conn,
   const char *path, *full_path;
   svn_revnum_t rev;
   svn_depth_t depth;
-  apr_array_header_t *patterns;
+  apr_array_header_t *patterns = NULL;
   svn_fs_root_t *root;
   const char *depth_word;
   svn_boolean_t path_info_only;
@@ -3598,16 +3598,19 @@ list(svn_ra_svn_conn_t *conn,
                                svn_relpath_canonicalize(path, pool), pool);
 
   /* Read the patterns list.  */
-  patterns = apr_array_make(pool, 0, sizeof(const char *));
-  for (i = 0; i < patterns_list->nelts; ++i)
+  if (patterns_list)
     {
-      svn_ra_svn__item_t *elt = &SVN_RA_SVN__LIST_ITEM(patterns_list, i);
+      patterns = apr_array_make(pool, 0, sizeof(const char *));
+      for (i = 0; i < patterns_list->nelts; ++i)
+        {
+          svn_ra_svn__item_t *elt = &SVN_RA_SVN__LIST_ITEM(patterns_list, i);
+
+          if (elt->kind != SVN_RA_SVN_STRING)
+            return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
+                                    "Pattern field not a string");
 
-      if (elt->kind != SVN_RA_SVN_STRING)
-        return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
-                                "Pattern field not a string");
-
-      APR_ARRAY_PUSH(patterns, const char *) = elt->u.string.data;
+          APR_ARRAY_PUSH(patterns, const char *) = elt->u.string.data;
+        }
     }
 
   /* Check authorizations */



Mime
View raw message