Re: svn commit: r1383480 - 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

2012-09-20 Thread Daniel Shahaf
s...@apache.org wrote on Tue, Sep 11, 2012 at 16:58:41 -:
 Author: stsp
 Date: Tue Sep 11 16:58:40 2012
 New Revision: 1383480
 
 URL: http://svn.apache.org/viewvc?rev=1383480view=rev
 Log:
 Allow mulitple --search options with 'svn log'. Log messages are shown
 if they match any of the provided search patterns (i.e. logical OR).

Right now it is fnmatch patterns --- can we have regexes too please?

I'm not sure about the UI, whether it's a --search-re flag or a
'--search re:foo' or something else.


svn commit: r1383480 - 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

2012-09-11 Thread stsp
Author: stsp
Date: Tue Sep 11 16:58:40 2012
New Revision: 1383480

URL: http://svn.apache.org/viewvc?rev=1383480view=rev
Log:
Allow mulitple --search options with 'svn log'. Log messages are shown
if they match any of the provided search patterns (i.e. logical OR).

This will be extended later with a new --search-and option to allow
for AND/OR combining of search terms (idea from philip).

* subversion/svn/cl.h
  (svn_cl__search_pattern_t): New data type.
  (svn_cl__opt_state_t): Replace search_pattern and case_insensitive_search
   with an array of svn_cl__search_pattern_t objects.

* subversion/svn/log-cmd.c
  (log_receiver_baton): As above, search_pattern and case_insensitive_search
   become an array of search patterns.
  (match_search_patterns): New helper to match multiple patterns.
  (log_entry_receiver, log_entry_receiver_xml): Call the new helper.
  (svn_cl__log): Track changes made to log_receiver_baton.

* subversion/svn/main.c
  (svn_cl__cmd_table): Document the effect of multiple --search options in
   the output of 'svn help log'.
  (add_search_pattern): New helper to create an array of search patterns
   from option arguments.
  (sub_main): Use new helper for processing --search and --isearch options.

* subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout: Adjust
   to new output of 'svn help log'.

* subversion/tests/cmdline/log_tests.py
  (log_search): Add a simple test case for multiple --search options.

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=1383480r1=1383479r2=1383480view=diff
==
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Tue Sep 11 16:58:40 2012
@@ -108,6 +108,12 @@ typedef enum svn_cl__accept_t
 svn_cl__accept_t
 svn_cl__accept_from_word(const char *word);
 
+/* --search and --isearch option values */
+typedef struct svn_cl__search_pattern_t {
+  const char *pattern; /* glob syntax */
+  svn_boolean_t case_insensitive;
+} svn_cl__search_pattern_t;
+
 
 /*** Mergeinfo flavors. ***/
 
@@ -236,8 +242,7 @@ typedef struct svn_cl__opt_state_t
   svn_boolean_t show_diff;/* produce diff output (maps to --diff) */
   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 */
+  apr_array_header_t* search_patterns; /* pattern arguments for --search */
 
   svn_wc_conflict_resolver_func2_t conflict_func;
   void *conflict_baton;

Modified: subversion/trunk/subversion/svn/log-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/log-cmd.c?rev=1383480r1=1383479r2=1383480view=diff
==
--- subversion/trunk/subversion/svn/log-cmd.c (original)
+++ subversion/trunk/subversion/svn/log-cmd.c Tue Sep 11 16:58:40 2012
@@ -71,10 +71,9 @@ struct log_receiver_baton
   /* Stack which keeps track of merge revision nesting, using svn_revnum_t's */
   apr_array_header_t *merge_stack;
 
-  /* 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;
+  /* Log message search patterns. Log entries will only be shown if the author,
+   * the log message, or a changed path matches one of these patterns. */
+  apr_array_header_t *search_patterns;
 
   /* Pool for persistent allocations. */
   apr_pool_t *pool;
@@ -203,6 +202,38 @@ match_search_pattern(const char *search_
   return FALSE;
 }
 
+/* Match all search patterns in SEARCH_PATTERNS against AUTHOR, DATE, MESSAGE,
+ * and CHANGED_PATHS. Return TRUE if any pattern matches, else FALSE.
+ * SCRACH_POOL is used for temporary allocations. */
+static svn_boolean_t
+match_search_patterns(apr_array_header_t *search_patterns,
+  const char *author,
+  const char *date,
+  const char *message,
+  apr_hash_t *changed_paths,
+  apr_pool_t *scratch_pool)
+{
+  int i;
+  svn_boolean_t match = FALSE;
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+
+  for (i = 0; i  search_patterns-nelts; i++)
+{
+  svn_cl__search_pattern_t p;
+
+  svn_pool_clear(iterpool);
+  
+  p = APR_ARRAY_IDX(search_patterns, i, svn_cl__search_pattern_t);
+  match =