subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1622687 - in /subversion/branches/log-message-templates/subversion: include/svn_client.h libsvn_client/commit_util.c svn/util.c
Date Fri, 05 Sep 2014 12:03:35 GMT
Author: stsp
Date: Fri Sep  5 12:03:35 2014
New Revision: 1622687

URL: http://svn.apache.org/r1622687
Log:
On the log-message-templates branch, change the contents of the
log message template hash table passed to API consumers.

Before this change, the table was keyed by the template text and
contained lists of svn_client_commit_item3_t pointers as values.
Now, the table is keyed by repository-relative paths which contribute
a log message template and the values are the log message templates.

If necessary, API users can still determine which commit item is affected
by which template by correlating the repository-relative path of each commit
item with the repository-relative path of each log message template.

* subversion/include/svn_client.h
  (svn_client_get_commit_log4_t): Document the new hash table structure.

* subversion/libsvn_client/commit_util.c
  (get_log_message_templates): Rename 'log_templates' output parameter to
   'log_message_templates' for consistency. Populate the log template
   table with keys and values as per the above rules. Set the output parameter
   to NULL if no template is defined (this is a pre-existing API rule the
   code failed to implement).

* subversion/svn/util.c
  (svn_cl__get_log_message): Adjust for above API change and change the way
   multiple log templates are displayed to the user. We used to show:

     Multiple log message templates found:
     {{{
     template 1
     }}}
     {{{
     template 2
     }}}
     --This line, and those below, will be ignored--

  Now, we show something like this instead:

    --Log message template from 'trunk/epsilon'--
    template 1
    --Log message template from 'trunk'--
    template 2
    --This line, and those below, will be ignored--

Modified:
    subversion/branches/log-message-templates/subversion/include/svn_client.h
    subversion/branches/log-message-templates/subversion/libsvn_client/commit_util.c
    subversion/branches/log-message-templates/subversion/svn/util.c

Modified: subversion/branches/log-message-templates/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/include/svn_client.h?rev=1622687&r1=1622686&r2=1622687&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/include/svn_client.h (original)
+++ subversion/branches/log-message-templates/subversion/include/svn_client.h Fri Sep  5 12:03:35
2014
@@ -656,9 +656,9 @@ svn_client_commit_item2_dup(const svn_cl
  * @a log_message_templates is a hash table containing one or more log
  * message templates obtained from svn:log-message properties applicable
  * to @a commit_items. It is @c NULL if no log message template is defined.
- * The table is keyed by 'const char *' log templates. Its values are
- * apr_array_header_t * arrays which contain pointers to those commit
- * items (from @a commit_items) which the log template applies to.
+ * The hash table is keyed by paths relative to the repository root.
+ * Each path in this list of keys contributes a log message template.
+ * The value for each key in the table is a 'const char *' log template.
  *
  * @a baton is provided along with the callback for use by the handler.
  *

Modified: subversion/branches/log-message-templates/subversion/libsvn_client/commit_util.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/libsvn_client/commit_util.c?rev=1622687&r1=1622686&r2=1622687&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/libsvn_client/commit_util.c (original)
+++ subversion/branches/log-message-templates/subversion/libsvn_client/commit_util.c Fri Sep
 5 12:03:35 2014
@@ -453,7 +453,7 @@ harvest_committables(const char *local_a
 
 /* Obtain log message templates for svn_client_get_commit_log4_t. */
 static svn_error_t *
-get_log_message_templates(apr_hash_t **log_templates,
+get_log_message_templates(apr_hash_t **log_message_templates,
                           const apr_array_header_t *commit_items,
                           svn_wc_context_t *wc_ctx,
                           apr_pool_t *result_pool,
@@ -462,25 +462,33 @@ get_log_message_templates(apr_hash_t **l
   int i;
   apr_pool_t *iterpool;
 
-  *log_templates = apr_hash_make(result_pool);
+  *log_message_templates = apr_hash_make(result_pool);
   iterpool = svn_pool_create(scratch_pool);
   for (i = 0; i < commit_items->nelts; i++)
     {
       svn_client_commit_item3_t *item =
         APR_ARRAY_IDX(commit_items, i, svn_client_commit_item3_t *);
       const svn_string_t *propval = NULL;
-      apr_array_header_t *lmt_items;
       apr_hash_t *props;
+      const char *defining_repos_relpath = NULL;
 
       svn_pool_clear(iterpool);
 
-      SVN_ERR(svn_wc_prop_list2(&props, wc_ctx, item->path,
-                                iterpool, iterpool));
+      /* Check if the commit item itself has an svn:log-template property. */
+      SVN_ERR(svn_wc_prop_list2(&props, wc_ctx, item->path, iterpool,
+                                iterpool));
       propval = svn_hash_gets(props, SVN_PROP_INHERITABLE_LOG_TEMPLATE);
-      if (propval == NULL)
+      if (propval)
+        {
+          SVN_ERR(svn_wc__node_get_repos_info(NULL, &defining_repos_relpath,
+                                              NULL, NULL, wc_ctx, item->path,
+                                              result_pool, iterpool));
+        }
+      else
         {
           apr_array_header_t *inherited_props;
           
+          /* Check if the commit item inherits an svn:log-template property. */
           SVN_ERR(svn_wc__get_iprops(&inherited_props, wc_ctx, item->path,
                                      SVN_PROP_INHERITABLE_LOG_TEMPLATE,
                                      scratch_pool, iterpool));
@@ -492,28 +500,42 @@ get_log_message_templates(apr_hash_t **l
                               svn_prop_inherited_item_t *);
               propval = svn_hash_gets(iprop->prop_hash,
                                       SVN_PROP_INHERITABLE_LOG_TEMPLATE);
+
+              if (svn_path_is_url(iprop->path_or_url))
+                {
+                  const char *repos_root_url;
+
+                  SVN_ERR(svn_wc__node_get_repos_info(NULL, NULL,
+                                                      &repos_root_url, NULL,
+                                                      wc_ctx, item->path,
+                                                      iterpool, iterpool));
+                  defining_repos_relpath =
+                    svn_uri_skip_ancestor(repos_root_url, iprop->path_or_url,
+                                          result_pool);
+                }
+              else
+                SVN_ERR(svn_wc__node_get_repos_info(NULL, &defining_repos_relpath,
+                                                    NULL, NULL, wc_ctx,
+                                                    iprop->path_or_url,
+                                                    result_pool, iterpool));
             }
         }
-
-      if (propval == NULL)
+                                            
+      if (propval == NULL || defining_repos_relpath == NULL ||
+          svn_hash_gets(*log_message_templates, defining_repos_relpath))
         continue;
 
       /* Embedded NUL characters in the log message template string
        * terminate the template regardless of the actual value of
        * propval->len. */
-      lmt_items = svn_hash_gets(*log_templates, propval->data);
-      if (lmt_items == NULL)
-        {
-          lmt_items = apr_array_make(scratch_pool, 4,
-                                     sizeof(svn_client_commit_item3_t *));
-          svn_hash_sets(*log_templates,
-                        apr_pstrdup(result_pool, propval->data), lmt_items);
-        }
-      APR_ARRAY_PUSH(lmt_items, svn_client_commit_item3_t *) = item;
+      svn_hash_sets(*log_message_templates, defining_repos_relpath,
+                    apr_pstrdup(result_pool, propval->data));
     }
-
   svn_pool_destroy(iterpool);
 
+  if (apr_hash_count(*log_message_templates) == 0)
+    *log_message_templates = NULL;
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/log-message-templates/subversion/svn/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/util.c?rev=1622687&r1=1622686&r2=1622687&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/util.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/util.c Fri Sep  5 12:03:35 2014
@@ -340,24 +340,32 @@ svn_cl__get_log_message(const char **log
     {
       svn_stringbuf_t *template_text;
       apr_hash_index_t *hi;
+      apr_pool_t *iterpool;
 
       template_text = svn_stringbuf_create_empty(pool);
-      if (apr_hash_count(log_message_templates) > 1)
-          svn_stringbuf_appendcstr(template_text,
-             _("Multiple log message templates found:"));
+      iterpool = svn_pool_create(pool);
       for (hi = apr_hash_first(NULL, log_message_templates);
            hi;
            hi = apr_hash_next(hi))
         {
-          const char *this_template = apr_hash_this_key(hi);
+          const char *repos_relpath = apr_hash_this_key(hi);
+          const char *this_template = apr_hash_this_val(hi);
 
+          svn_pool_clear(iterpool);
+                                                    
           if (apr_hash_count(log_message_templates) > 1)
-              svn_stringbuf_appendcstr(template_text, "\n{{{\n");
+            {
+              const char *sep;
+
+              sep = apr_psprintf(iterpool,
+                                 _("\n--Log message template from '%s'--\n"),
+                                 repos_relpath);
+              svn_stringbuf_appendcstr(template_text, sep);
+            }
           svn_stringbuf_appendcstr(template_text, this_template);
           svn_stringbuf_strip_whitespace(template_text);
-          if (apr_hash_count(log_message_templates) > 1)
-            svn_stringbuf_appendcstr(template_text, "\n}}}\n");
         }
+      svn_pool_destroy(iterpool);
       default_msg = template_text;
     }
   else



Mime
View raw message