subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1622678 - in /subversion/branches/log-message-templates/subversion: include/ libsvn_client/ svn/
Date Fri, 05 Sep 2014 10:31:11 GMT
Author: stsp
Date: Fri Sep  5 10:31:11 2014
New Revision: 1622678

URL: http://svn.apache.org/r1622678
Log:
On the log-message-templates branch, rework the way log templates
are passed to client API consumers.

Before this change, the template texts were passed as part of the
svn_client_commit_item3_t structure, duplicating the template text
for each item. The API consumer was forced to loop over all commit
items to correlate templates which apply to multiple commit items.
Log message templates were collected during commit harvesting.

Now, the templates are passed as an additional argument to the client's
log message callback (svn_client_get_commit_log4_t). Each template has
associated with it a list of pointers to commit items which the template
applies to. The templates are collected during an extra post-processing
step after commit harvesting and only for consumers of the new API.

* subversion/include/svn_client.h
  (svn_client_commit_item3_t): Remove log_msg_template field.
  (svn_client_get_commit_log4_t): Revision of svn_client_get_commit_log3_t
   which takes a log_message_templates parameter.
  (svn_client_get_commit_log3_t): Deprecate.
  (svn_client_ctx_t): Add log_msg_func4 and log_msg_baton4 and
   deprecate log_msg_func3.

* subversion/libsvn_client/client.h
  (SVN_CLIENT__HAS_LOG_MSG_FUNC): Update for log_msg_func4.

* subversion/libsvn_client/commit_util.c
  (add_committable, harvest_not_present_for_copy, harvest_status_callback,
   handle_descendants): Remove now obsolete support for log message templates.
  (get_log_msg_template): Rename to ...
  (get_log_message_templates): ... this. Return a collection of templates
   which are associated with the commit items they apply to.
  (svn_client__get_log_msg): Collect log message templates if the client API
   user is providing a svn_client_get_commit_log4_t log message function.

* subversion/svn/cl.h
   (svn_cl__get_log_message): This is now an implementation of
    svn_client_get_commit_log4_t.

* subversion/svn/commit-cmd.c
  (svn_cl__commit): Use ctx->log_msg_baton4 instead of ctx->log_msg_baton3.

* subversion/svn/copy-cmd.c
  (svn_cl__copy): Use ctx->log_msg_baton4 instead of ctx->log_msg_baton3.

* subversion/svn/delete-cmd.c
  (svn_cl__delete): Use ctx->log_msg_baton4 instead of ctx->log_msg_baton3. 

* subversion/svn/import-cmd.c
  (svn_cl__import): Use ctx->log_msg_baton4 instead of ctx->log_msg_baton3.

* subversion/svn/mkdir-cmd.c
  (svn_cl__mkdir): Use ctx->log_msg_baton4 instead of ctx->log_msg_baton3. 

* subversion/svn/move-cmd.c
  (svn_cl__move): Use ctx->log_msg_baton4 instead of ctx->log_msg_baton3.

* subversion/svn/propedit-cmd.c
  (svn_cl__propedit): Use ctx->log_msg_baton4 instead of ctx->log_msg_baton3.

* subversion/svn/svn.c
  (sub_main): Use ctx->log_msg_func4 instead of ctx->log_msg_func3.

* subversion/svn/util.c
  (svn_cl__get_log_message): Implement the svn_client_get_commit_log4_t
   interface. Provide the same behaviour as get_log_message_template().
  (get_log_message_template): Remove.

Modified:
    subversion/branches/log-message-templates/subversion/include/svn_client.h
    subversion/branches/log-message-templates/subversion/libsvn_client/client.h
    subversion/branches/log-message-templates/subversion/libsvn_client/commit_util.c
    subversion/branches/log-message-templates/subversion/svn/cl.h
    subversion/branches/log-message-templates/subversion/svn/commit-cmd.c
    subversion/branches/log-message-templates/subversion/svn/copy-cmd.c
    subversion/branches/log-message-templates/subversion/svn/delete-cmd.c
    subversion/branches/log-message-templates/subversion/svn/import-cmd.c
    subversion/branches/log-message-templates/subversion/svn/mkdir-cmd.c
    subversion/branches/log-message-templates/subversion/svn/move-cmd.c
    subversion/branches/log-message-templates/subversion/svn/propedit-cmd.c
    subversion/branches/log-message-templates/subversion/svn/svn.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=1622678&r1=1622677&r2=1622678&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 10:31:11
2014
@@ -528,13 +528,6 @@ typedef struct svn_client_commit_item3_t
    */
   const char *moved_from_abspath;
 
-  /** Log message template associated with this item (if any; NULL
-   * otherwise).
-   *
-   * @since New in 1.9.
-   */
-  const svn_string_t *log_msg_template;
-
 } svn_client_commit_item3_t;
 
 /** The commit candidate structure.
@@ -660,11 +653,31 @@ svn_client_commit_item2_dup(const svn_cl
  * structures, which may be fully or only partially filled-in,
  * depending on the type of commit operation.
  *
+ * @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.
+ *
  * @a baton is provided along with the callback for use by the handler.
  *
  * All allocations should be performed in @a pool.
  *
+ * @since New in 1.9.
+ */
+typedef svn_error_t *(*svn_client_get_commit_log4_t)(
+  const char **log_msg,
+  const char **tmp_file,
+  const apr_array_header_t *commit_items,
+  const apr_hash_t *log_message_templates,
+  void *baton,
+  apr_pool_t *pool);
+
+/* Like svn_client_get_commit_log3_t but without log message template support.
+ *
  * @since New in 1.5.
+ * @deprecated Provided for backward compatibility with the 1.8 API.
  */
 typedef svn_error_t *(*svn_client_get_commit_log3_t)(
   const char **log_msg,
@@ -988,6 +1001,8 @@ typedef struct svn_client_ctx_t
 
   /** Log message callback function. NULL means that Subversion
    *   should try @c log_msg_func2, then @c log_msg_func.
+    * @deprecated Provided for backward compatibility with the 1.8 API.
+    * Use @c log_msg_func4 instead.
    * @since New in 1.5. */
   svn_client_get_commit_log3_t log_msg_func3;
 
@@ -1051,6 +1066,15 @@ typedef struct svn_client_ctx_t
    * @since New in 1.9.
    */
   void *tunnel_baton;
+
+  /** Log message callback function. NULL means that Subversion should
+   * try @c log_msgs_func3, @c log_msg_func2, then @c log_msg_func.
+   * @since New in 1.9. */
+  svn_client_get_commit_log4_t log_msg_func4;
+
+  /** The callback baton for @c log_msg_func4.
+   * @since New in 1.9. */
+  void *log_msg_baton4;
 } svn_client_ctx_t;
 
 /** Initialize a client context.

Modified: subversion/branches/log-message-templates/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/libsvn_client/client.h?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/libsvn_client/client.h (original)
+++ subversion/branches/log-message-templates/subversion/libsvn_client/client.h Fri Sep  5
10:31:11 2014
@@ -290,7 +290,8 @@ svn_client__ensure_ra_session_url(const 
 
 /* CTX is of type "svn_client_ctx_t *". */
 #define SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx) \
-        ((ctx)->log_msg_func3 || (ctx)->log_msg_func2 || (ctx)->log_msg_func)
+        ((ctx)->log_msg_func4 || (ctx)->log_msg_func3 || (ctx)->log_msg_func2 \
+         || (ctx)->log_msg_func)
 
 /* Open an RA session, returning it in *RA_SESSION or a corrected URL
    in *CORRECTED_URL.  (This function mirrors svn_ra_open4(), which

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=1622678&r1=1622677&r2=1622678&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 10:31:11 2014
@@ -200,7 +200,6 @@ add_committable(svn_client__committables
                 const char *copyfrom_relpath,
                 svn_revnum_t copyfrom_rev,
                 const char *moved_from_abspath,
-                const svn_string_t *log_msg_template,
                 apr_byte_t state_flags,
                 apr_hash_t *lock_tokens,
                 const svn_lock_t *lock,
@@ -250,10 +249,6 @@ add_committable(svn_client__committables
   if (moved_from_abspath)
     new_item->moved_from_abspath = apr_pstrdup(result_pool,
                                                moved_from_abspath);
-  if (log_msg_template)
-    new_item->log_msg_template = svn_string_dup(log_msg_template,
-                                                result_pool);
-
   /* Now, add the commit item to the array. */
   APR_ARRAY_PUSH(array, svn_client_commit_item3_t *) = new_item;
 
@@ -456,36 +451,69 @@ harvest_committables(const char *local_a
   return SVN_NO_ERROR;
 }
 
-/* Set *LOG_MSG_TEMPLATE to the log message template associated with
-   LOCAL_ABSPATH (or NULL if there is none). */
+/* Obtain log message templates for svn_client_get_commit_log4_t. */
 static svn_error_t *
-get_log_msg_template(const svn_string_t **log_msg_template,
-                     svn_wc_context_t *wc_ctx,
-                     const char *local_abspath,
-                     apr_pool_t *result_pool)
+get_log_message_templates(apr_hash_t **log_templates,
+                          const apr_array_header_t *commit_items,
+                          svn_wc_context_t *wc_ctx,
+                          apr_pool_t *result_pool,
+                          apr_pool_t *scratch_pool)
 {
-  apr_hash_t *props;
+  int i;
+  apr_pool_t *iterpool;
+
+  *log_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;
+
+      svn_pool_clear(iterpool);
+
+      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)
+        {
+          apr_array_header_t *inherited_props;
+          
+          SVN_ERR(svn_wc__get_iprops(&inherited_props, wc_ctx, item->path,
+                                     SVN_PROP_INHERITABLE_LOG_TEMPLATE,
+                                     scratch_pool, iterpool));
+          if (inherited_props && inherited_props->nelts)
+            {
+              svn_prop_inherited_item_t *iprop =
+                APR_ARRAY_IDX(inherited_props,
+                              inherited_props->nelts - 1,
+                              svn_prop_inherited_item_t *);
+              propval = svn_hash_gets(iprop->prop_hash,
+                                      SVN_PROP_INHERITABLE_LOG_TEMPLATE);
+            }
+        }
+
+      if (propval == NULL)
+        continue;
 
-  SVN_ERR(svn_wc_prop_list2(&props, wc_ctx, local_abspath,
-                            result_pool, result_pool));
-  *log_msg_template = svn_hash_gets(props, SVN_PROP_INHERITABLE_LOG_TEMPLATE);
-  if (! *log_msg_template)
-    {
-      apr_array_header_t *inherited_lmt;
-      
-      SVN_ERR(svn_wc__get_iprops(&inherited_lmt, wc_ctx, local_abspath,
-                                 SVN_PROP_INHERITABLE_LOG_TEMPLATE,
-                                 result_pool, result_pool));
-      if (inherited_lmt && inherited_lmt->nelts)
-        {
-          svn_prop_inherited_item_t *iprop =
-            APR_ARRAY_IDX(inherited_lmt,
-                          inherited_lmt->nelts - 1,
-                          svn_prop_inherited_item_t *);
-          *log_msg_template = svn_hash_gets(iprop->prop_hash,
-                                            SVN_PROP_INHERITABLE_LOG_TEMPLATE);
+      /* 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_pool_destroy(iterpool);
+
   return SVN_NO_ERROR;
 }
 
@@ -516,7 +544,6 @@ harvest_not_present_for_copy(svn_wc_cont
       const char *this_commit_relpath;
       svn_boolean_t not_present;
       svn_node_kind_t kind;
-      const svn_string_t *log_msg_template;
 
       svn_pool_clear(iterpool);
 
@@ -566,8 +593,6 @@ harvest_not_present_for_copy(svn_wc_cont
         SVN_ERR(svn_wc_read_kind2(&kind, wc_ctx, this_abspath,
                                   TRUE, TRUE, scratch_pool));
 
-      SVN_ERR(get_log_msg_template(&log_msg_template, wc_ctx,
-                                   this_abspath, scratch_pool));
       SVN_ERR(add_committable(committables, this_abspath, kind,
                               repos_root_url,
                               this_commit_relpath,
@@ -575,7 +600,6 @@ harvest_not_present_for_copy(svn_wc_cont
                               NULL /* copyfrom_relpath */,
                               SVN_INVALID_REVNUM /* copyfrom_rev */,
                               NULL /* moved_from_abspath */,
-                              log_msg_template,
                               SVN_CLIENT_COMMIT_ITEM_DELETE,
                               NULL, NULL,
                               result_pool, scratch_pool));
@@ -902,11 +926,6 @@ harvest_status_callback(void *status_bat
   if (matches_changelists
       && state_flags)
     {
-      const svn_string_t *log_msg_template;
-
-      SVN_ERR(get_log_msg_template(&log_msg_template, wc_ctx,
-                                   local_abspath, scratch_pool));
-
       /* Finally, add the committable item. */
       SVN_ERR(add_committable(committables, local_abspath,
                               status->kind,
@@ -920,7 +939,6 @@ harvest_status_callback(void *status_bat
                               cf_relpath,
                               cf_rev,
                               moved_from_abspath,
-                              log_msg_template,
                               state_flags,
                               baton->lock_tokens, status->lock,
                               result_pool, scratch_pool));
@@ -1081,7 +1099,6 @@ handle_descendants(void *baton,
                                               const char *);
           const char *local_abspath = svn_dirent_join(item->path, relpath,
                                                       iterpool);
-          const svn_string_t *log_msg_template;
 
           /* ### Need a sub-iterpool? */
 
@@ -1160,10 +1177,6 @@ handle_descendants(void *baton,
 
           /* Add a new commit item that describes the delete */
 
-          SVN_ERR(get_log_msg_template(&log_msg_template, hdb->wc_ctx,
-                                       svn_dirent_join(item->path, relpath,
-                                                       iterpool),
-                                       iterpool));
           SVN_ERR(add_committable(hdb->committables,
                                   svn_dirent_join(item->path, relpath,
                                                   iterpool),
@@ -1179,7 +1192,6 @@ handle_descendants(void *baton,
                                   NULL /* copyfrom_relpath */,
                                   SVN_INVALID_REVNUM,
                                   NULL /* moved_from_abspath */,
-                                  log_msg_template,
                                   SVN_CLIENT_COMMIT_ITEM_DELETE,
                                   NULL /* lock tokens */,
                                   NULL /* lock */,
@@ -2014,9 +2026,22 @@ svn_client__get_log_msg(const char **log
                         svn_client_ctx_t *ctx,
                         apr_pool_t *pool)
 {
-  if (ctx->log_msg_func3)
+  if (ctx->log_msg_func4)
+    {
+      apr_hash_t *log_message_templates;
+
+      SVN_ERR(get_log_message_templates(&log_message_templates,
+                                        commit_items, ctx->wc_ctx,
+                                        pool, pool));
+      return svn_error_trace((*ctx->log_msg_func4)(log_msg, tmp_file,
+                                                   commit_items,
+                                                   log_message_templates,
+                                                   ctx->log_msg_baton4,
+                                                   pool));
+    }
+  else if (ctx->log_msg_func3)
     {
-      /* The client provided a callback function for the current API.
+      /* The client provided a callback function for the 1.8 API.
          Forward the call to it directly. */
       return (*ctx->log_msg_func3)(log_msg, tmp_file, commit_items,
                                    ctx->log_msg_baton3, pool);

Modified: subversion/branches/log-message-templates/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/cl.h?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/cl.h (original)
+++ subversion/branches/log-message-templates/subversion/svn/cl.h Fri Sep  5 10:31:11 2014
@@ -628,11 +628,12 @@ svn_cl__make_log_msg_baton(void **baton,
                            apr_hash_t *config,
                            apr_pool_t *pool);
 
-/* A function of type svn_client_get_commit_log3_t. */
+/* A function of type svn_client_get_commit_log4_t. */
 svn_error_t *
 svn_cl__get_log_message(const char **log_msg,
                         const char **tmp_file,
                         const apr_array_header_t *commit_items,
+                        apr_hash_t *log_message_templates,
                         void *baton,
                         apr_pool_t *pool);
 

Modified: subversion/branches/log-message-templates/subversion/svn/commit-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/commit-cmd.c?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/commit-cmd.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/commit-cmd.c Fri Sep  5 10:31:11
2014
@@ -147,7 +147,7 @@ svn_cl__commit(apr_getopt_t *os,
      to store the temp file, instead of the current working directory.  The
      client might not have write access to their working directory, but they
      better have write access to the directory they're committing.  */
-  SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3),
+  SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton4),
                                      opt_state, base_dir,
                                      ctx->config, pool));
 
@@ -180,7 +180,7 @@ svn_cl__commit(apr_getopt_t *os,
                            NULL,
                            ctx,
                            pool);
-  SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err, pool));
+  SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton4, err, pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/log-message-templates/subversion/svn/copy-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/copy-cmd.c?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/copy-cmd.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/copy-cmd.c Fri Sep  5 10:31:11
2014
@@ -164,7 +164,7 @@ svn_cl__copy(apr_getopt_t *os,
     }
 
   if (ctx->log_msg_func3)
-    SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
+    SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton4), opt_state,
                                        NULL, ctx->config, pool));
 
   err = svn_client_copy6(sources, dst_path, TRUE,
@@ -175,7 +175,7 @@ svn_cl__copy(apr_getopt_t *os,
                          ctx, pool);
 
   if (ctx->log_msg_func3)
-    SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err, pool));
+    SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton4, err, pool));
   else if (err)
     return svn_error_trace(err);
 

Modified: subversion/branches/log-message-templates/subversion/svn/delete-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/delete-cmd.c?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/delete-cmd.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/delete-cmd.c Fri Sep  5 10:31:11
2014
@@ -72,7 +72,7 @@ svn_cl__delete(apr_getopt_t *os,
     }
   else
     {
-      SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
+      SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton4), opt_state,
                                          NULL, ctx->config, pool));
     }
 
@@ -87,7 +87,7 @@ svn_cl__delete(apr_getopt_t *os,
     err = svn_cl__may_need_force(err);
 
   if (ctx->log_msg_func3)
-    SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err, pool));
+    SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton4, err, pool));
   else if (err)
     return svn_error_trace(err);
 

Modified: subversion/branches/log-message-templates/subversion/svn/import-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/import-cmd.c?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/import-cmd.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/import-cmd.c Fri Sep  5 10:31:11
2014
@@ -109,11 +109,11 @@ svn_cl__import(apr_getopt_t *os,
   if (opt_state->depth == svn_depth_unknown)
     opt_state->depth = svn_depth_infinity;
 
-  SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
+  SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton4), opt_state,
                                      NULL, ctx->config, pool));
 
   SVN_ERR(svn_cl__cleanup_log_msg
-          (ctx->log_msg_baton3,
+          (ctx->log_msg_baton4,
            svn_client_import5(path,
                               url,
                               opt_state->depth,

Modified: subversion/branches/log-message-templates/subversion/svn/mkdir-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/mkdir-cmd.c?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/mkdir-cmd.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/mkdir-cmd.c Fri Sep  5 10:31:11
2014
@@ -71,7 +71,7 @@ svn_cl__mkdir(apr_getopt_t *os,
     }
   else
     {
-      SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
+      SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton4), opt_state,
                                          NULL, ctx->config, pool));
     }
 
@@ -83,7 +83,7 @@ svn_cl__mkdir(apr_getopt_t *os,
                           NULL, ctx, pool);
 
   if (ctx->log_msg_func3)
-    err = svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err, pool);
+    err = svn_cl__cleanup_log_msg(ctx->log_msg_baton4, err, pool);
 
   if (err)
     {

Modified: subversion/branches/log-message-templates/subversion/svn/move-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/move-cmd.c?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/move-cmd.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/move-cmd.c Fri Sep  5 10:31:11
2014
@@ -79,7 +79,7 @@ svn_cl__move(apr_getopt_t *os,
     }
 
   if (ctx->log_msg_func3)
-    SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
+    SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton4), opt_state,
                                        NULL, ctx->config, pool));
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
@@ -97,7 +97,7 @@ svn_cl__move(apr_getopt_t *os,
     err = svn_cl__may_need_force(err);
 
   if (ctx->log_msg_func3)
-    SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err, pool));
+    SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton4, err, pool));
   else if (err)
     return svn_error_trace(err);
 

Modified: subversion/branches/log-message-templates/subversion/svn/propedit-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/propedit-cmd.c?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/propedit-cmd.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/propedit-cmd.c Fri Sep  5 10:31:11
2014
@@ -299,7 +299,7 @@ svn_cl__propedit(apr_getopt_t *os,
                                              subpool);
 
               if (ctx->log_msg_func3)
-                SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3),
+                SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton4),
                                                    opt_state, NULL, ctx->config,
                                                    subpool));
               if (svn_path_is_url(target))
@@ -328,7 +328,7 @@ svn_cl__propedit(apr_getopt_t *os,
                 }
 
               if (ctx->log_msg_func3)
-                SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3,
+                SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton4,
                                                 err, pool));
               else if (err)
                 return svn_error_trace(err);

Modified: subversion/branches/log-message-templates/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-message-templates/subversion/svn/svn.c?rev=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/svn.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/svn.c Fri Sep  5 10:31:11 2014
@@ -2826,8 +2826,8 @@ sub_main(int *exit_code, int argc, const
                         SVN_CONFIG_OPTION_NO_UNLOCK, TRUE);
 
   /* Set the log message callback function.  Note that individual
-     subcommands will populate the ctx->log_msg_baton3. */
-  ctx->log_msg_func3 = svn_cl__get_log_message;
+     subcommands will populate the ctx->log_msg_baton4. */
+  ctx->log_msg_func4 = svn_cl__get_log_message;
 
   /* Set up the notifier.
 

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=1622678&r1=1622677&r2=1622678&view=diff
==============================================================================
--- subversion/branches/log-message-templates/subversion/svn/util.c (original)
+++ subversion/branches/log-message-templates/subversion/svn/util.c Fri Sep  5 10:31:11 2014
@@ -174,7 +174,7 @@ svn_cl__merge_file_externally(const char
 }
 
 
-/* A svn_client_ctx_t's log_msg_baton3, for use with
+/* A svn_client_ctx_t's log_msg_baton4, for use with
    svn_cl__make_log_msg_baton(). */
 struct log_msg_baton
 {
@@ -321,82 +321,13 @@ truncate_buffer_at_prefix(apr_size_t *ne
   /* NOTREACHED */
 }
 
-static svn_error_t *
-get_log_message_template(svn_stringbuf_t **log_msg_template,
-                         const apr_array_header_t *commit_items,
-                         apr_pool_t *result_pool,
-                         apr_pool_t *scratch_pool)
-{
-  int i;
-  apr_hash_t *log_templates = apr_hash_make(scratch_pool);
-  svn_stringbuf_t *template_text;
-  const svn_string_t *last_log_template = NULL;
-
-  if (commit_items)
-    {
-      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 *lmt = item->log_msg_template;
-          apr_array_header_t *lmt_paths;
-
-          if (! lmt)
-            continue;
-
-          fprintf(stderr, "path(%s), lmt(%s)\n", item->path, lmt->data);
-          lmt_paths = apr_hash_get(log_templates, lmt->data, lmt->len);
-          if (! lmt_paths)
-            {
-              lmt_paths = apr_array_make(scratch_pool, 4, sizeof(const char *));
-              apr_hash_set(log_templates, lmt->data, lmt->len, lmt_paths);
-              last_log_template = lmt;
-            }
-          
-          APR_ARRAY_PUSH(lmt_paths, const char *) = item->path;
-        }
-    }
-
-  /* No log message template?  No sweat. */
-  if (apr_hash_count(log_templates) == 0)
-    {
-      template_text = svn_stringbuf_create_empty(result_pool);
-    }
-  else if (apr_hash_count(log_templates) == 1)
-    {
-      template_text = svn_stringbuf_create_from_string(last_log_template,
-                                                        result_pool);
-    }
-  else
-    {
-      apr_hash_index_t *hi;
-
-      template_text = svn_stringbuf_create(_("Multiple log message templates "
-                                             "found:\n"), result_pool);
-      for (hi = apr_hash_first(NULL, log_templates); hi; hi = apr_hash_next(hi))
-        {
-          const void *key;
-          apr_ssize_t klen;
-          void * val;
-
-          apr_hash_this(hi, &key, &klen, &val);
-          svn_stringbuf_appendcstr(template_text, "\n{{{\n");
-          svn_stringbuf_appendbytes(template_text, key, klen);
-          svn_stringbuf_appendcstr(template_text, "\n}}}\n");
-        }
-    }
-
-  *log_msg_template = template_text;
-  return SVN_NO_ERROR;
-}
-
-
 #define EDITOR_EOF_PREFIX  _("--This line, and those below, will be ignored--")
 
 svn_error_t *
 svn_cl__get_log_message(const char **log_msg,
                         const char **tmp_file,
                         const apr_array_header_t *commit_items,
+                        apr_hash_t *log_message_templates,
                         void *baton,
                         apr_pool_t *pool)
 {
@@ -405,7 +336,33 @@ svn_cl__get_log_message(const char **log
   svn_stringbuf_t *message = NULL;
 
   /* Set default message.  */
-  SVN_ERR(get_log_message_template(&default_msg, commit_items, pool, pool));
+  if (log_message_templates)
+    {
+      svn_stringbuf_t *template_text;
+      apr_hash_index_t *hi;
+
+      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:"));
+      for (hi = apr_hash_first(NULL, log_message_templates);
+           hi;
+           hi = apr_hash_next(hi))
+        {
+          const char *this_template = apr_hash_this_key(hi);
+
+          if (apr_hash_count(log_message_templates) > 1)
+              svn_stringbuf_appendcstr(template_text, "\n{{{\n");
+          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");
+        }
+      default_msg = template_text;
+    }
+  else
+    default_msg = svn_stringbuf_create_empty(pool);
+
   svn_stringbuf_appendcstr(default_msg, APR_EOL_STR);
   svn_stringbuf_appendcstr(default_msg, EDITOR_EOF_PREFIX);
   svn_stringbuf_appendcstr(default_msg, APR_EOL_STR APR_EOL_STR);



Mime
View raw message