subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1354830 - in /subversion/trunk/subversion: svn/cl.h svn/log-cmd.c svn/main.c tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout tests/cmdline/log_tests.py
Date Thu, 28 Jun 2012 06:35:45 GMT
Author: stsp
Date: Thu Jun 28 06:35:44 2012
New Revision: 1354830

URL: http://svn.apache.org/viewvc?rev=1354830&view=rev
Log:
Add an --isearch option to svn log, so that I will hopefully earn some money
for doing covert advertising for a popular fruit company, as well as allowing
case-insensitive search of log messages.

* subversion/svn/cl.h
  (svn_cl__opt_state_t): Add case_insensitive_search.

* subversion/svn/log-cmd.c
  (match_search_pattern): Add case_insensitive_search parameter, and perform
   case-insensitive matching if it is set.
  (log_entry_receiver, log_entry_receiver_xml, svn_cl__log): Pass the
   case_insensitive_search flag through.

* subversion/svn/main.c
  (svn_cl__longopt_t): Add opt_isearch.
  (svn_cl__options): Add --isearch option.
  (svn_cl__cmd_table): Add --isearch option to 'svn log'.
  (main): Handle --isearch option.

* subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout: Adjust
   for changed 'svn help log' output.

* subversion/tests/cmdline/log_tests.py
  (log_search): Test the --isearch option, too.

Modified:
    subversion/trunk/subversion/svn/cl.h
    subversion/trunk/subversion/svn/log-cmd.c
    subversion/trunk/subversion/svn/main.c
    subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout
    subversion/trunk/subversion/tests/cmdline/log_tests.py

Modified: subversion/trunk/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1354830&r1=1354829&r2=1354830&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Thu Jun 28 06:35:44 2012
@@ -238,6 +238,7 @@ typedef struct svn_cl__opt_state_t
   svn_boolean_t allow_mixed_rev; /* Allow operation on mixed-revision WC */
   svn_boolean_t include_externals; /* Recurses (in)to file & dir externals */
   const char *search_pattern;     /* pattern argument for --search */
+  svn_boolean_t case_insensitive_search; /* perform case-insensitive search */
 } svn_cl__opt_state_t;
 
 

Modified: subversion/trunk/subversion/svn/log-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/log-cmd.c?rev=1354830&r1=1354829&r2=1354830&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/log-cmd.c (original)
+++ subversion/trunk/subversion/svn/log-cmd.c Thu Jun 28 06:35:44 2012
@@ -74,6 +74,7 @@ struct log_receiver_baton
   /* Log message search pattern. Log entries will only be shown if the author,
    * the log message, or a changed path matches this pattern. */
   const char *search_pattern;
+  svn_boolean_t case_insensitive_search;
 
   /* Pool for persistent allocations. */
   apr_pool_t *pool;
@@ -154,17 +155,19 @@ match_search_pattern(const char *search_
                      const char *author,
                      const char *log_message,
                      apr_hash_t *changed_paths,
+                     svn_boolean_t case_insensitive_search,
                      apr_pool_t *pool)
 {
   /* Match any substring containing the pattern, like UNIX 'grep' does. */
   const char *pattern = apr_psprintf(pool, "*%s*", search_pattern);
+  int flags = (case_insensitive_search ? APR_FNM_CASE_BLIND : 0);
 
   /* Does the author match the search pattern? */
-  if (apr_fnmatch(pattern, author, 0) == APR_SUCCESS)
+  if (apr_fnmatch(pattern, author, flags) == APR_SUCCESS)
     return TRUE;
 
   /* Does the log message the search pattern? */
-  if (log_message && apr_fnmatch(pattern, log_message, 0) == APR_SUCCESS)
+  if (log_message && apr_fnmatch(pattern, log_message, flags) == APR_SUCCESS)
     return TRUE;
 
   if (changed_paths)
@@ -178,7 +181,7 @@ match_search_pattern(const char *search_
         {
           const char *path = svn__apr_hash_index_key(hi);
 
-          if (apr_fnmatch(search_pattern, path, 0) == APR_SUCCESS)
+          if (apr_fnmatch(search_pattern, path, flags) == APR_SUCCESS)
             return TRUE;
         }
     }
@@ -305,7 +308,8 @@ log_entry_receiver(void *baton,
 
   if (lb->search_pattern &&
       ! match_search_pattern(lb->search_pattern, author, message,
-                             log_entry->changed_paths2, pool))
+                             log_entry->changed_paths2,
+                             lb->case_insensitive_search, pool))
     {
       if (log_entry->has_children)
         APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
@@ -489,7 +493,8 @@ log_entry_receiver_xml(void *baton,
   /* Match search pattern before XML-escaping. */
   if (lb->search_pattern &&
       ! match_search_pattern(lb->search_pattern, author, message,
-                             log_entry->changed_paths2, pool))
+                             log_entry->changed_paths2,
+                             lb->case_insensitive_search, pool))
     {
       if (log_entry->has_children)
         APR_ARRAY_PUSH(lb->merge_stack, svn_revnum_t) = log_entry->revision;
@@ -722,6 +727,7 @@ svn_cl__log(apr_getopt_t *os,
   lb.diff_extensions = opt_state->extensions;
   lb.merge_stack = apr_array_make(pool, 0, sizeof(svn_revnum_t));
   lb.search_pattern = opt_state->search_pattern;
+  lb.case_insensitive_search = opt_state->case_insensitive_search;
   lb.pool = pool;
 
   if (opt_state->xml)

Modified: subversion/trunk/subversion/svn/main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/main.c?rev=1354830&r1=1354829&r2=1354830&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/main.c (original)
+++ subversion/trunk/subversion/svn/main.c Thu Jun 28 06:35:44 2012
@@ -131,6 +131,7 @@ typedef enum svn_cl__longopt_t {
   opt_include_externals,
   opt_symmetric,
   opt_search,
+  opt_isearch,
 } svn_cl__longopt_t;
 
 
@@ -379,6 +380,9 @@ const apr_getopt_option_t svn_cl__option
   {"search", opt_search, 1,
                        N_("use ARG as search pattern (glob syntax)")},
 
+  {"isearch", opt_isearch, 1,
+                       N_("like --search, but case-insensitive")}, 
+
   /* Long-opt Aliases
    *
    * These have NULL desriptions, but an option code that matches some
@@ -720,7 +724,8 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "      svn log --stop-on-copy --limit 1 -r0:HEAD ^/branches/foo\n"),
     {'r', 'q', 'v', 'g', 'c', opt_targets, opt_stop_on_copy, opt_incremental,
      opt_xml, 'l', opt_with_all_revprops, opt_with_no_revprops, opt_with_revprop,
-     opt_depth, opt_diff, opt_diff_cmd, opt_internal_diff, 'x', opt_search},
+     opt_depth, opt_diff, opt_diff_cmd, opt_internal_diff, 'x', opt_search,
+     opt_isearch},
     {{opt_with_revprop, N_("retrieve revision property ARG")},
      {'c', N_("the change made in revision ARG")}} },
 
@@ -2169,6 +2174,10 @@ main(int argc, const char *argv[])
       case opt_search:
         opt_state.search_pattern = opt_arg;
         break;
+      case opt_isearch:
+        opt_state.search_pattern = opt_arg;
+        opt_state.case_insensitive_search = TRUE;
+        break;
       default:
         /* Hmmm. Perhaps this would be a good place to squirrel away
            opts that commands like svn diff might need. Hmmm indeed. */

Modified: subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout?rev=1354830&r1=1354829&r2=1354830&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout
(original)
+++ subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout
Thu Jun 28 06:35:44 2012
@@ -111,6 +111,7 @@ Valid options:
                                 -p (--show-c-function):
                                    Show C function name in diff output.
   --search ARG             : use ARG as search pattern (glob syntax)
+  --isearch ARG            : like --search, but case-insensitive
 
 Global options:
   --username ARG           : specify a username ARG

Modified: subversion/trunk/subversion/tests/cmdline/log_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/log_tests.py?rev=1354830&r1=1354829&r2=1354830&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/log_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/log_tests.py Thu Jun 28 06:35:44 2012
@@ -2296,6 +2296,14 @@ def log_search(sbox):
   log_chain = parse_log_output(output)
   check_log_chain(log_chain, [7, 6, 3])
 
+  # case-insensitive search
+  exit_code, output, err = svntest.actions.run_and_verify_svn(
+                             None, None, [], 'log', '--isearch',
+                             'FOR REVISION [367]')
+
+  log_chain = parse_log_output(output)
+  check_log_chain(log_chain, [7, 6, 3])
+
 @SkipUnless(server_has_mergeinfo)
 def merge_sensitive_log_with_search(sbox):
   "test 'svn log -g --search'"



Mime
View raw message