subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1767202 - in /subversion/trunk/subversion/svnbench: cl.h null-list-cmd.c svnbench.c
Date Sun, 30 Oct 2016 23:49:55 GMT
Author: stefan2
Date: Sun Oct 30 23:49:55 2016
New Revision: 1767202

URL: http://svn.apache.org/viewvc?rev=1767202&view=rev
Log:
Add '--search' option support to 'svnbench null-list'.

This replicates features already implemented for 'svn list'.

* subversion/svnbench/cl.h
  (svn_cl__opt_state_t): Copy SEARCH_PATTERNS from the standard CL client.

* subversion/svnbench/null-list-cmd.c
  (svn_cl__null_list): Process the search patterns just like in 'svn'.

* subversion/svnbench/svnbench.c
  (svn_cl__longopt_t,
   svn_cl__options,
   svn_cl__cmd_table,
   add_search_pattern_group,
   sub_main): Replicate svn's '--search' option.

Modified:
    subversion/trunk/subversion/svnbench/cl.h
    subversion/trunk/subversion/svnbench/null-list-cmd.c
    subversion/trunk/subversion/svnbench/svnbench.c

Modified: subversion/trunk/subversion/svnbench/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnbench/cl.h?rev=1767202&r1=1767201&r2=1767202&view=diff
==============================================================================
--- subversion/trunk/subversion/svnbench/cl.h (original)
+++ subversion/trunk/subversion/svnbench/cl.h Sun Oct 30 23:49:55 2016
@@ -95,6 +95,7 @@ typedef struct svn_cl__opt_state_t
   svn_boolean_t trust_server_cert_expired;
   svn_boolean_t trust_server_cert_not_yet_valid;
   svn_boolean_t trust_server_cert_other_failure;
+  apr_array_header_t* search_patterns; /* pattern arguments for --search */
 } svn_cl__opt_state_t;
 
 

Modified: subversion/trunk/subversion/svnbench/null-list-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnbench/null-list-cmd.c?rev=1767202&r1=1767201&r2=1767202&view=diff
==============================================================================
--- subversion/trunk/subversion/svnbench/null-list-cmd.c (original)
+++ subversion/trunk/subversion/svnbench/null-list-cmd.c Sun Oct 30 23:49:55 2016
@@ -122,17 +122,36 @@ 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;
+      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. */
       SVN_ERR(svn_opt_parse_path(&peg_revision, &truepath, target,
                                  subpool));
 
-      err = svn_client_list3(truepath, &peg_revision,
-                             &(opt_state->start_revision),
+      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 *);
+          }
+
+      err = svn_client_list4(truepath, &peg_revision,
+                             &(opt_state->start_revision), patterns,
                              opt_state->depth,
                              dirent_fields,
                              opt_state->verbose,

Modified: subversion/trunk/subversion/svnbench/svnbench.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnbench/svnbench.c?rev=1767202&r1=1767201&r2=1767202&view=diff
==============================================================================
--- subversion/trunk/subversion/svnbench/svnbench.c (original)
+++ subversion/trunk/subversion/svnbench/svnbench.c Sun Oct 30 23:49:55 2016
@@ -41,6 +41,7 @@
 #include "private/svn_opt_private.h"
 #include "private/svn_cmdline_private.h"
 #include "private/svn_string_private.h"
+#include "private/svn_utf_private.h"
 
 #include "svn_private_config.h"
 
@@ -67,7 +68,8 @@ typedef enum svn_cl__longopt_t {
   opt_with_no_revprops,
   opt_trust_server_cert,
   opt_trust_server_cert_failures,
-  opt_changelist
+  opt_changelist,
+  opt_search
 } svn_cl__longopt_t;
 
 
@@ -164,6 +166,8 @@ const apr_getopt_option_t svn_cl__option
                     N_("use/display additional information from merge\n"
                        "                             "
                        "history")},
+  {"search", opt_search, 1,
+                       N_("use ARG as search pattern (glob syntax)")},
 
   /* Long-opt Aliases
    *
@@ -256,7 +260,7 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "    If locked, the letter 'O'.  (Use 'svn info URL' to see details)\n"
      "    Size (in bytes)\n"
      "    Date and time of the last commit\n"),
-    {'r', 'v', 'q', 'R', opt_depth} },
+    {'r', 'v', 'q', 'R', opt_depth, opt_search} },
 
   { "null-log", svn_cl__null_log, {0}, N_
     ("Fetch the log messages for a set of revision(s) and/or path(s).\n"
@@ -345,6 +349,24 @@ ra_progress_func(apr_off_t progress,
 /* Our cancellation callback. */
 svn_cancel_func_t svn_cl__check_cancel = NULL;
 
+/* Add a --search argument to OPT_STATE.
+ * These options start a new search pattern group. */
+static void
+add_search_pattern_group(svn_cl__opt_state_t *opt_state,
+                         const char *pattern,
+                         apr_pool_t *result_pool)
+{
+  apr_array_header_t *group = NULL;
+
+  if (opt_state->search_patterns == NULL)
+    opt_state->search_patterns = apr_array_make(result_pool, 1,
+                                                sizeof(apr_array_header_t *));
+
+  group = apr_array_make(result_pool, 1, sizeof(const char *));
+  APR_ARRAY_PUSH(group, const char *) = pattern;
+  APR_ARRAY_PUSH(opt_state->search_patterns, apr_array_header_t *) = group;
+}
+
 
 /*** Main. ***/
 
@@ -371,9 +393,13 @@ sub_main(int *exit_code, int argc, const
   svn_boolean_t use_notifier = TRUE;
   apr_time_t start_time, time_taken;
   ra_progress_baton_t ra_progress_baton = {0};
+  svn_membuf_t buf;
 
   received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
 
+  /* Init the temporary buffer. */
+  svn_membuf__create(&buf, 0, pool);
+
   /* Check library versions */
   SVN_ERR(check_lib_versions());
 
@@ -656,6 +682,14 @@ sub_main(int *exit_code, int argc, const
       case 'g':
         opt_state.use_merge_history = TRUE;
         break;
+      case opt_search:
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf__xfrm(&utf8_opt_arg, utf8_opt_arg,
+                              strlen(utf8_opt_arg), TRUE, TRUE, &buf));
+        add_search_pattern_group(&opt_state,
+                                 apr_pstrdup(pool, utf8_opt_arg),
+                                 pool);
+        break;
       default:
         /* Hmmm. Perhaps this would be a good place to squirrel away
            opts that commands like svn diff might need. Hmmm indeed. */



Mime
View raw message