[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Revv svn_client_commit_item_t structure

From: Erik Huelsmann <ehuels_at_gmail.com>
Date: 2005-08-24 00:27:02 CEST

On 8/22/05, Ivan Zhakov <chemodax@gmail.com> wrote:
> Hello!
> For work on branches/wc-replacements was required to revv
> svn_client_commit_item_t structure. Because revv was complex and
> usefull, I propose did this in trunk.
> Idea in general aproved here by C. Michael Pilato:
> http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=104319
 
> [[
> Isolate svn_client_commit_item_t.revision and add
> svn_client_commit_item_t.copyfrom_rev. It's required for "replace from
> copy operations".

All in all the patch looks very nice. I'm running make check now, but
do have some comments below. There were some extra ^M characters in
your patch btw, nothing problematic, but the patch program will
complain...

Some lines you changed either already had, or have now a trailing
space. Please don't add those, or better, if you change a line, take
care to remove them.

I prefixed my nits below with '=>'

>
> * subversion/clients/cmdline/cl.h
> (svn_cl__get_log_message): Fix documentation.
> * subversion/clients/cmdline/copy-cmd.c
> * subversion/clients/cmdline/commit-cmd.c
> * subversion/clients/cmdline/delete-cmd.c
> * subversion/clients/cmdline/import-cmd.c
> * subversion/clients/cmdline/mkdir-cmd.c
> * subversion/clients/cmdline/move-cmd.c
> * subversion/clients/cmdline/main.c
> (svn_cl__copy), (svn_cl__commit), (svn_cl__delete),
> (svn_cl__import), (main), (svn_cl__mkdir), (svn_cl_move): use new
> commit message API
> (use ctx->log_msg_func2/ctx->log_msg_baton2 instead of
> ctx->log_msg_func/ctx->log_msg_baton).
> * subversion/clients/cmdline/util.c
> (svn_cl__get_log_message): turn function into
> svn_client_get_commit_log2_t type.
> * subversion/include/svn_client.h:
> (svn_client_commit_item2_t): New structure, copied from
> svn_client_commit_item2_t with addition field copyfrom_rev.
> (svn_client_commit_item_t): Deprecate.
> (svn_client_get_commit_log2_t): Revv API, new callback accepts array
> of svn_client_get_commit_log2_t.
> (svn_client_get_commit_log_t): Deprecate.
> (svn_client_ctx_t): Add new log_msg_func2/log_msg_batton2 members for
> new API.
> Deprecate log_msg_func/log_msg_batton.
> * subversion/libsvn_client/add.c
> (mkdir_urls): Use function svn_client__get_log_msg instead of direct
> call to ctx->log_msg_func.
> * subversion/libsvn_client/client.h
> (svn_client__callback_baton_t): Fix documentation.
> * subversion/libsvn_client/commit.c
> (svn_client_import2): Use function svn_client__get_log_msg instead of direct
> call to ctx->log_msg_func.
> (have_processed_parent): Use svn_client_commit_item2_t in place of
> svn_client_commit_item2_t.
> (adjust_rel_targets): Use function svn_client__get_log_msg instead of direct
> call to ctx->log_msg_func. Use svn_client_commit_item2_t in place of
> svn_client_commit_item_t.
> * subversion/libsvn_client/commit_util.c
> (svn_client__get_log_msg): Utility function for backward compability
> with 1.2 API.
> * subversion/libsvn_client/copy.c
> (wc_to_repos_copy), (repos_to_repos_copy): Use
> svn_client_commit_item2_t in place of
> svn_client_commit_item_t.
> * subversion/libsvn_client/delete.c
> (delete_urls): Use svn_client_commit_item2_t in place of
> svn_client_commit_item_t.
> * subversion/libsvn_client/ra.c
> (get_wc_prop), (push_wc_prop): Use svn_client_commit_item2_t in place of
> svn_client_commit_item_t.
> ]]

In the log message, please use full sentences and start each sentence
with a capital. ["(svn_cl_move): Use new" instead of "(svn_cl_move):
use new"]

Index: subversion/include/svn_client.h

===================================================================

--- subversion/include/svn_client.h (revision 15883)

+++ subversion/include/svn_client.h (working copy)

@@ -308,7 +308,7 @@

 
 /**
  * @name Commit state flags
- * @brief State flags for use with the @c svn_client_commit_item_t structure
+ * @brief State flags for use with the @c svn_client_commit_item2_t structure
  * (see the note about the namespace for that structure, which also
  * applies to these flags).
  * @{
@@ -322,7 +322,49 @@

 #define SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN 0x20
 /** @} */
 
-/** The commit candidate structure. */
+/** The commit candidate structure.
+ *
+ * @since New in 1.3.
+ */
+typedef struct svn_client_commit_item2_t
+{
+ /** absolute working-copy path of item */
+ const char *path;
+
+ /** node kind (dir, file) */
+ svn_node_kind_t kind;
+
+ /** commit URL for this item */
+ const char *url;
+
+ /** revision */
+ svn_revnum_t revision;
+
+ /** copyfrom-url */
+ const char *copyfrom_url;
+
+ /** copyfrom-rev, valid when copyfrom_url != NULL */
+ svn_revnum_t copyfrom_rev;
+
+ /** state flags */
+ apr_byte_t state_flags;
+
+ /** An array of `svn_prop_t *' changes to wc properties. If adding
+ * to this array, allocate the svn_prop_t and its contents in
+ * wcprop_changes->pool, so that it has the same lifetime as this
+ * svn_client_commit_item_t.
+ *
+ * See http://subversion.tigris.org/issues/show_bug.cgi?id=806 for
+ * what would happen if the post-commit process didn't group these
+ * changes together with all other changes to the item :-).
+ */
+ apr_array_header_t *wcprop_changes;
+} svn_client_commit_item2_t;
+
+/** The commit candidate structure.
+ *
+ * @deprecated Provided for backward compatibility with the 1.2 API.
+ */
 typedef struct svn_client_commit_item_t
 {
   /** absolute working-copy path of item */
@@ -367,6 +409,33 @@

  * @c NULL, this value is undefined). The log message MUST be a UTF8
  * string with LF line separators.
  *
+ * @a commit_items is a read-only array of @c svn_client_commit_item2_t
+ * structures, which may be fully or only partially filled-in,
+ * depending on the type of commit operation.
+ *
+ * @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.3.
+ */
+typedef svn_error_t *
+(*svn_client_get_commit_log2_t) (const char **log_msg,
+ const char **tmp_file,
+ apr_array_header_t *commit_items,
+ void *baton,
+ apr_pool_t *pool);
+
+/** Callback type used by commit-y operations to get a commit log message
+ * from the caller.
+ *
+ * Set @a *log_msg to the log message for the commit, allocated in @a
+ * pool, or @c NULL if wish to abort the commit process. Set @a *tmp_file
+ * to the path of any temporary file which might be holding that log
+ * message, or @c NULL if no such file exists (though, if @a *log_msg is
+ * @c NULL, this value is undefined). The log message MUST be a UTF8
+ * string with LF line separators.
+ *
  * @a commit_items is a read-only array of @c svn_client_commit_item_t
  * structures, which may be fully or only partially filled-in,
  * depending on the type of commit operation.

=>
=> nice!
=>

@@ -374,6 +443,8 @@

  * @a baton is provided along with the callback for use by the handler.
  *
  * All allocations should be performed in @a pool.
+ *
+ * @deprecated Provided for backward compatibility with the 1.2 API.
  */
 typedef svn_error_t *
 (*svn_client_get_commit_log_t) (const char **log_msg,
@@ -423,10 +494,12 @@

   void *notify_baton;
 
   /** Log message callback function. NULL means that Subversion
- should not attempt to fetch a log message. */
+ * should try not attempt to fetch a log message.
+ * @deprecated Provided for backward compatibility with the 1.2 API. */
   svn_client_get_commit_log_t log_msg_func;
 
- /** log message callback baton */
+ /** log message callback baton
+ * @deprecated Provided for backward compatibility with the 1.2 API. */
   void *log_msg_baton;
 
   /** a hash mapping of <tt>const char *</tt> configuration file names to
@@ -451,6 +524,15 @@

   /** notification baton for notify_func2().
    * @since New in 1.2. */
   void *notify_baton2;
+
+ /** Log message callback function. NULL means that Subversion
+ * should try log_msg_func.
+ * @since New in 1.3. */
+ svn_client_get_commit_log2_t log_msg_func2;
+
+ /** callback baton for log_msg_func2
+ * @since New in 1.3. */
+ void *log_msg_baton2;
 } svn_client_ctx_t;
 
 
Index: subversion/libsvn_client/delete.c

===================================================================

--- subversion/libsvn_client/delete.c (revision 15883)

+++ subversion/libsvn_client/delete.c (working copy)

@@ -136,9 +136,9 @@

     }
 
   /* Create new commit items and add them to the array. */
- if (ctx->log_msg_func)
+ if (ctx->log_msg_func || ctx->log_msg_func2)
     {
- svn_client_commit_item_t *item;
+ svn_client_commit_item2_t *item;
       const char *tmp_file;
       apr_array_header_t *commit_items
         = apr_array_make (pool, targets->nelts, sizeof (item));
@@ -149,10 +149,10 @@

           item = apr_pcalloc (pool, sizeof (*item));
           item->url = svn_path_join (common, path, pool);
           item->state_flags = SVN_CLIENT_COMMIT_ITEM_DELETE;
- APR_ARRAY_PUSH (commit_items, svn_client_commit_item_t *) = item;
+ APR_ARRAY_PUSH (commit_items, svn_client_commit_item2_t *) = item;
         }
- SVN_ERR ((*ctx->log_msg_func) (&log_msg, &tmp_file, commit_items,
- ctx->log_msg_baton, pool));
+ SVN_ERR (svn_client__get_log_msg (&log_msg, &tmp_file, commit_items,
+ ctx, pool));
       if (! log_msg)
         return SVN_NO_ERROR;
     }
Index: subversion/libsvn_client/client.h

===================================================================

--- subversion/libsvn_client/client.h (revision 15883)

+++ subversion/libsvn_client/client.h (working copy)

@@ -191,7 +191,7 @@

   const char *base_dir;
   svn_wc_adm_access_t *base_access;
 
- /* An array of svn_client_commit_item_t * structures, present only
+ /* An array of svn_client_commit_item2_t * structures, present only
      during working copy commits. */
   apr_array_header_t *commit_items;
 
@@ -637,6 +637,17 @@

                                 apr_pool_t *pool);
 
 
+
+/*
+ * Retrieves log message using *CTX->log_msg_func or
+ * *CTX->log_msg_func2 callbacks.
+ * Other argements same as svn_client_get_commit_log2_t
+ */
+svn_error_t * svn_client__get_log_msg(const char **log_msg,
+ const char **tmp_file,
+ apr_array_header_t *commit_items,
+ svn_client_ctx_t *ctx, apr_pool_t *pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/libsvn_client/ra.c

===================================================================

--- subversion/libsvn_client/ra.c (revision 15883)

+++ subversion/libsvn_client/ra.c (working copy)

@@ -92,8 +92,8 @@

       int i;
       for (i = 0; i < cb->commit_items->nelts; i++)
         {
- svn_client_commit_item_t *item
- = ((svn_client_commit_item_t **) cb->commit_items->elts)[i];
+ svn_client_commit_item2_t *item
+ = ((svn_client_commit_item2_t **) cb->commit_items->elts)[i];

=>
=> it would be nicer to use APR_ARRAY_IDX in the above line: it's
better readabel
=> and you're changing the code anyway. The same goes for a number of similar
=> instances below
=>
           if (! strcmp (relpath,
                         svn_path_uri_decode (item->url, pool)))
             return svn_wc_prop_get (value, name, item->path, cb->base_access,
@@ -133,8 +133,8 @@

 
   for (i = 0; i < cb->commit_items->nelts; i++)
     {
- svn_client_commit_item_t *item
- = ((svn_client_commit_item_t **) cb->commit_items->elts)[i];
+ svn_client_commit_item2_t *item
+ = ((svn_client_commit_item2_t **) cb->commit_items->elts)[i];
       
       if (strcmp (relpath, svn_path_uri_decode (item->url, pool)) == 0)
         {
Index: subversion/libsvn_client/copy.c

===================================================================

--- subversion/libsvn_client/copy.c (revision 15883)

+++ subversion/libsvn_client/copy.c (working copy)

@@ -420,9 +420,9 @@

     }
 
   /* Create a new commit item and add it to the array. */
- if (ctx->log_msg_func)
+ if (ctx->log_msg_func || ctx->log_msg_func2)
     {
- svn_client_commit_item_t *item;
+ svn_client_commit_item2_t *item;
       const char *tmp_file;
       apr_array_header_t *commit_items
         = apr_array_make (pool, 2, sizeof (item));
@@ -430,17 +430,18 @@

       item = apr_pcalloc (pool, sizeof (*item));
       item->url = svn_path_join (top_url, dst_rel, pool);
       item->state_flags = SVN_CLIENT_COMMIT_ITEM_ADD;
- (*((svn_client_commit_item_t **) apr_array_push (commit_items))) = item;
+ (*((svn_client_commit_item2_t **) apr_array_push (commit_items))) = item;

=>
=> Better use APR_ARRAY_PUSH for readability
=>

       if (is_move && (! resurrection))
         {
           item = apr_pcalloc (pool, sizeof (*item));
           item->url = svn_path_join (top_url, src_rel, pool);
           item->state_flags = SVN_CLIENT_COMMIT_ITEM_DELETE;
- (*((svn_client_commit_item_t **) apr_array_push (commit_items))) =
+ (*((svn_client_commit_item2_t **) apr_array_push (commit_items))) =
             item;
         }
- SVN_ERR ((*ctx->log_msg_func) (&message, &tmp_file, commit_items,
- ctx->log_msg_baton, pool));
+
+ SVN_ERR (svn_client__get_log_msg(&message, &tmp_file, commit_items,
+ ctx, pool));
       if (! message)
         return SVN_NO_ERROR;
     }
@@ -647,19 +648,19 @@

     }
 
   /* Create a new commit item and add it to the array. */
- if (ctx->log_msg_func)
+ if (ctx->log_msg_func || ctx->log_msg_func2)
     {
- svn_client_commit_item_t *item;
+ svn_client_commit_item2_t *item;
       const char *tmp_file;
 
       commit_items = apr_array_make (pool, 1, sizeof (item));
       item = apr_pcalloc (pool, sizeof (*item));
       item->url = base_url;
       item->state_flags = SVN_CLIENT_COMMIT_ITEM_ADD;
- (*((svn_client_commit_item_t **) apr_array_push (commit_items))) = item;
+ (*((svn_client_commit_item2_t **) apr_array_push (commit_items))) = item;
       
=>
=> APR_ARRAY_PUSH
=>

- SVN_ERR ((*ctx->log_msg_func) (&message, &tmp_file, commit_items,
- ctx->log_msg_baton, pool));
+ SVN_ERR (svn_client__get_log_msg (&message, &tmp_file, commit_items,
+ ctx, pool));
       if (! message)
         return SVN_NO_ERROR;
     }
Index: subversion/libsvn_client/commit_util.c

===================================================================

--- subversion/libsvn_client/commit_util.c (revision 15883)

+++ subversion/libsvn_client/commit_util.c (working copy)

@@ -55,12 +55,13 @@

                  const char *url,
                  svn_revnum_t revision,
                  const char *copyfrom_url,
+ svn_revnum_t copyfrom_rev,
                  apr_byte_t state_flags)
 {
   apr_pool_t *pool = apr_hash_pool_get (committables);
   const char *repos_name = SVN_CLIENT__SINGLE_REPOS_NAME;
   apr_array_header_t *array;
- svn_client_commit_item_t *new_item;
+ svn_client_commit_item2_t *new_item;
 
   /* Sanity checks. */
   assert (path && url);
@@ -87,11 +88,12 @@

   new_item->revision = revision;
   new_item->copyfrom_url = copyfrom_url
                              ? apr_pstrdup (pool, copyfrom_url) : NULL;
+ new_item->copyfrom_rev = copyfrom_rev;
   new_item->state_flags = state_flags;
   new_item->wcprop_changes = apr_array_make (pool, 1, sizeof (svn_prop_t *));
    
   /* Now, add the commit item to the array. */
- (*((svn_client_commit_item_t **) apr_array_push (array))) = new_item;
+ (*((svn_client_commit_item2_t **) apr_array_push (array))) = new_item;
 }
 
 
@@ -122,7 +124,7 @@

 
 /* If there is a commit item for PATH in COMMITTABLES, return it, else
    return NULL. Use POOL for temporary allocation only. */
-static svn_client_commit_item_t *
+static svn_client_commit_item2_t *
 look_up_committable (apr_hash_t *committables,
                      const char *path,
                      apr_pool_t *pool)
@@ -141,9 +143,9 @@

       
       for (i = 0; i < these_committables->nelts; i++)
         {
- svn_client_commit_item_t *this_committable
+ svn_client_commit_item2_t *this_committable
             = APR_ARRAY_IDX (these_committables, i,
- svn_client_commit_item_t *);
+ svn_client_commit_item2_t *);
           
           if (strcmp (this_committable->path, path) == 0)
             return this_committable;
@@ -476,8 +478,10 @@

     {
       /* Finally, add the committable item. */
       add_committable (committables, path, entry->kind, url,
- cf_url ? cf_rev : entry->revision,
- cf_url, state_flags);
+ entry->revision,
+ cf_url,
+ cf_rev,
+ state_flags);
       if (lock_tokens && entry->lock_token)
         apr_hash_set (lock_tokens, apr_pstrdup (token_pool, url),
                       APR_HASH_KEY_STRING,
@@ -562,6 +566,7 @@

                                            this_entry->kind, used_url,
                                            SVN_INVALID_REVNUM,
                                            NULL,
+ SVN_INVALID_REVNUM,
                                            SVN_CLIENT_COMMIT_ITEM_DELETE);
                           svn_error_clear (lockerr);
                           continue; /* don't recurse! */
@@ -819,10 +824,10 @@

 
 int svn_client__sort_commit_item_urls (const void *a, const void *b)
 {
- const svn_client_commit_item_t *item1
- = *((const svn_client_commit_item_t * const *) a);
- const svn_client_commit_item_t *item2
- = *((const svn_client_commit_item_t * const *) b);
+ const svn_client_commit_item2_t *item1
+ = *((const svn_client_commit_item2_t * const *) a);
+ const svn_client_commit_item2_t *item2
+ = *((const svn_client_commit_item2_t * const *) b);
   return svn_path_compare_paths (item1->url, item2->url);
 }
 
@@ -835,7 +840,7 @@

 {
   apr_array_header_t *ci = commit_items; /* convenience */
   const char *url;
- svn_client_commit_item_t *item, *last_item = NULL;
+ svn_client_commit_item2_t *item, *last_item = NULL;
   int i;
   
   assert (ci && ci->nelts);
@@ -848,7 +853,7 @@

      to all of them, and making sure there are no duplicate URLs. */
   for (i = 0; i < ci->nelts; i++)
     {
- item = (((svn_client_commit_item_t **) ci->elts)[i]);
+ item = (((svn_client_commit_item2_t **) ci->elts)[i]);
       url = item->url;
 
       if ((last_item) && (strcmp (last_item->url, url) == 0))
@@ -888,8 +893,8 @@

      of all of our URLs. */
   for (i = 0; i < ci->nelts; i++)
     {
- svn_client_commit_item_t *this_item
- = ((svn_client_commit_item_t **) ci->elts)[i];
+ svn_client_commit_item2_t *this_item
+ = ((svn_client_commit_item2_t **) ci->elts)[i];
       int url_len = strlen (this_item->url);
       int base_url_len = strlen (*base_url);
 
@@ -905,8 +910,8 @@

   fprintf (stderr, " FLAGS REV REL-URL (COPY-URL)\n");
   for (i = 0; i < ci->nelts; i++)
     {
- svn_client_commit_item_t *this_item
- = ((svn_client_commit_item_t **) ci->elts)[i];
+ svn_client_commit_item2_t *this_item
+ = ((svn_client_commit_item2_t **) ci->elts)[i];
       char flags[6];
       flags[0] = (this_item->state_flags & SVN_CLIENT_COMMIT_ITEM_ADD)
                    ? 'a' : '-';
@@ -933,7 +938,7 @@

 
 struct file_mod_t
 {
- svn_client_commit_item_t *item;
+ svn_client_commit_item2_t *item;
   void *file_baton;
 };
 
@@ -961,7 +966,7 @@

                 apr_pool_t *pool)
 {
   struct path_driver_cb_baton *cb_baton = callback_baton;
- svn_client_commit_item_t *item = apr_hash_get (cb_baton->commit_items,
+ svn_client_commit_item2_t *item = apr_hash_get (cb_baton->commit_items,
                                                  path, APR_HASH_KEY_STRING);
   svn_node_kind_t kind = item->kind;
   void *file_baton = NULL;
@@ -1001,7 +1006,7 @@

           (SVN_ERR_BAD_URL, NULL,
            _("Commit item '%s' has copy flag but no copyfrom URL"),
            svn_path_local_style (path, pool));
- if (! SVN_IS_VALID_REVNUM (item->revision))
+ if (! SVN_IS_VALID_REVNUM (item->copyfrom_rev))
         return svn_error_createf
           (SVN_ERR_CLIENT_BAD_REVISION, NULL,
            _("Commit item '%s' has copy flag but an invalid revision"),
@@ -1094,7 +1099,7 @@

           assert (parent_baton);
           SVN_ERR (editor->add_file
                    (path, parent_baton, copyfrom_url,
- copyfrom_url ? item->revision : SVN_INVALID_REVNUM,
+ copyfrom_url ? item->copyfrom_rev : SVN_INVALID_REVNUM,
                     file_pool, &file_baton));
         }
       else
@@ -1102,7 +1107,7 @@

           assert (parent_baton);
           SVN_ERR (editor->add_directory
                    (path, parent_baton, copyfrom_url,
- copyfrom_url ? item->revision : SVN_INVALID_REVNUM,
+ copyfrom_url ? item->copyfrom_rev : SVN_INVALID_REVNUM,
                     pool, dir_baton));
         }
     }
@@ -1234,8 +1239,8 @@

      keep an array of those decoded paths, too. */
   for (i = 0; i < commit_items->nelts; i++)
     {
- svn_client_commit_item_t *item =
- APR_ARRAY_IDX (commit_items, i, svn_client_commit_item_t *);
+ svn_client_commit_item2_t *item =
+ APR_ARRAY_IDX (commit_items, i, svn_client_commit_item2_t *);
       const char *path = svn_path_uri_decode (item->url, pool);
       apr_hash_set (items_hash, path, APR_HASH_KEY_STRING, item);
       APR_ARRAY_PUSH (paths, const char *) = path;
@@ -1261,7 +1266,7 @@

       const void *key;
       apr_ssize_t klen;
       struct file_mod_t *mod;
- svn_client_commit_item_t *item;
+ svn_client_commit_item2_t *item;
       void *val;
       void *file_baton;
       const char *tempfile, *dir_path;
@@ -1611,3 +1616,53 @@

   return SVN_NO_ERROR;
 }
 #endif /* SVN_CLIENT_COMMIT_DEBUG */
+
+svn_error_t * svn_client__get_log_msg(const char **log_msg,
+ const char **tmp_file,
+ apr_array_header_t *commit_items,
+ svn_client_ctx_t *ctx, apr_pool_t *pool)
+{
+ /* client provided new callback function. simply forward call to him */
+ if (ctx->log_msg_func2)
+ return (*ctx->log_msg_func2) (log_msg, tmp_file, commit_items,
+ ctx->log_msg_baton2, pool);
+
+ /* client want use old (pre 1.3) API, therefore build
+ * svn_client_commit_item_t array */
+
+ if (ctx->log_msg_func)
+ {
+ int i;
+ svn_client_commit_item_t *old_item;
+ apr_array_header_t *old_commit_items
+ = apr_array_make (pool, commit_items->nelts, sizeof (old_item));
+
+ for (i = 0; i < commit_items->nelts; i++)
+ {
+ svn_client_commit_item2_t *item =
+ APR_ARRAY_IDX (commit_items, i, svn_client_commit_item2_t *);
+
+ old_item = apr_pcalloc (pool, sizeof (*old_item));
+ old_item->path = item->path;
+ old_item->kind = item->kind;
+ old_item->url = item->url;
+ /* pre 1.3 API use revision field for copyfrom_rev and revision
+ * depeding of copyfrom_url */
+ old_item->revision = item->copyfrom_url ?
+ item->copyfrom_rev : item->revision;
+ old_item->copyfrom_url = item->copyfrom_url;
+ old_item->state_flags = item->state_flags;
+ old_item->wcprop_changes = item->wcprop_changes;
+
+ APR_ARRAY_PUSH (old_commit_items,
svn_client_commit_item_t *) = old_item;
+ }
+
+ return (*ctx->log_msg_func) (log_msg, tmp_file, old_commit_items,
+ ctx->log_msg_baton, pool);
+ }
+
+ *log_msg = "";
+ *tmp_file = NULL;
+
+ return SVN_NO_ERROR;
+}

=>
=> I had some discussion about this on IRC with other devs
=> but I think this is indeed the cleanest way of supporting the old api
=>

Index: subversion/libsvn_client/commit.c

===================================================================

--- subversion/libsvn_client/commit.c (revision 15883)

+++ subversion/libsvn_client/commit.c (working copy)

@@ -656,12 +656,12 @@

   apr_pool_t *subpool;
 
   /* Create a new commit item and add it to the array. */
- if (ctx->log_msg_func)
+ if (ctx->log_msg_func || ctx->log_msg_func2)
     {
       /* If there's a log message gatherer, create a temporary commit
          item array solely to help generate the log message. The
          array is not used for the import itself. */
- svn_client_commit_item_t *item;
+ svn_client_commit_item2_t *item;
       const char *tmp_file;
       apr_array_header_t *commit_items
         = apr_array_make (pool, 1, sizeof (item));
@@ -669,10 +669,10 @@

       item = apr_pcalloc (pool, sizeof (*item));
       item->path = apr_pstrdup (pool, path);
       item->state_flags = SVN_CLIENT_COMMIT_ITEM_ADD;
- (*((svn_client_commit_item_t **) apr_array_push (commit_items))) = item;
+ (*((svn_client_commit_item2_t **) apr_array_push (commit_items))) = item;
       
- SVN_ERR ((*ctx->log_msg_func) (&log_msg, &tmp_file, commit_items,
- ctx->log_msg_baton, pool));
+ SVN_ERR (svn_client__get_log_msg(&log_msg, &tmp_file, commit_items,
+ ctx, pool));
       if (! log_msg)
         return SVN_NO_ERROR;
       if (tmp_file)
@@ -923,8 +923,8 @@

   int i;
   for (i = 0; i < processed && i < commit_items->nelts; ++i)
     {
- svn_client_commit_item_t *item
- = ((svn_client_commit_item_t **) commit_items->elts)[i];
+ svn_client_commit_item2_t *item
+ = ((svn_client_commit_item2_t **) commit_items->elts)[i];
 
       if (svn_path_is_child (item->path, path, pool))
         return TRUE;
@@ -1460,8 +1460,8 @@

 
     for (i = 0; i < commit_items->nelts; ++i)
       {
- svn_client_commit_item_t *item;
- item = APR_ARRAY_IDX (commit_items, i, svn_client_commit_item_t *);
+ svn_client_commit_item2_t *item;
+ item = APR_ARRAY_IDX (commit_items, i, svn_client_commit_item2_t *);
         
         if (item->state_flags != SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN)
           {
@@ -1476,11 +1476,12 @@

 
   /* Go get a log message. If an error occurs, or no log message is
      specified, abort the operation. */
- if (ctx->log_msg_func)
+ if (ctx->log_msg_func || ctx->log_msg_func2)
     {
       const char *tmp_file;
- cmt_err = (*ctx->log_msg_func)(&log_msg, &tmp_file, commit_items,
- ctx->log_msg_baton, pool);
+ cmt_err = svn_client__get_log_msg(&log_msg, &tmp_file, commit_items,
+ ctx, pool);
+
       if (cmt_err || (! log_msg))
         goto cleanup;
     }
@@ -1531,8 +1532,8 @@

 
       for (i = 0; i < commit_items->nelts; i++)
         {
- svn_client_commit_item_t *item
- = ((svn_client_commit_item_t **) commit_items->elts)[i];
+ svn_client_commit_item2_t *item
+ = ((svn_client_commit_item2_t **) commit_items->elts)[i];
           svn_boolean_t loop_recurse = FALSE;
           const char *adm_access_path;
           svn_wc_adm_access_t *adm_access;
Index: subversion/libsvn_client/add.c

===================================================================

--- subversion/libsvn_client/add.c (revision 15883)

+++ subversion/libsvn_client/add.c (working copy)

@@ -548,9 +548,9 @@

     }
 
   /* Create new commit items and add them to the array. */
- if (ctx->log_msg_func)
+ if (ctx->log_msg_func || ctx->log_msg_func2)
     {
- svn_client_commit_item_t *item;
+ svn_client_commit_item2_t *item;
       const char *tmp_file;
       apr_array_header_t *commit_items
         = apr_array_make (pool, targets->nelts, sizeof (item));
@@ -561,10 +561,12 @@

           item = apr_pcalloc (pool, sizeof (*item));
           item->url = svn_path_join (common, path, pool);
           item->state_flags = SVN_CLIENT_COMMIT_ITEM_ADD;
- APR_ARRAY_PUSH (commit_items, svn_client_commit_item_t *) = item;
+ APR_ARRAY_PUSH (commit_items, svn_client_commit_item2_t *) = item;
         }
- SVN_ERR ((*ctx->log_msg_func) (&log_msg, &tmp_file, commit_items,
- ctx->log_msg_baton, pool));
+
+ SVN_ERR (svn_client__get_log_msg(&log_msg, &tmp_file, commit_items,
+ ctx, pool));
+
       if (! log_msg)
         return SVN_NO_ERROR;
     }
Index: subversion/clients/cmdline/cl.h

===================================================================

--- subversion/clients/cmdline/cl.h (revision 15883)

+++ subversion/clients/cmdline/cl.h (working copy)

@@ -432,7 +432,7 @@

                                          apr_hash_t *config,
                                          apr_pool_t *pool);
 
-/* A function of type svn_client_get_commit_log_t. */
+/* A function of type svn_client_get_commit_log2_t. */
 svn_error_t *svn_cl__get_log_message (const char **log_msg,
                                       const char **tmp_file,
                                       apr_array_header_t *commit_items,
Index: subversion/clients/cmdline/mkdir-cmd.c

===================================================================

--- subversion/clients/cmdline/mkdir-cmd.c (revision 15883)

+++ subversion/clients/cmdline/mkdir-cmd.c (working copy)

@@ -58,7 +58,7 @@

 
   if (! svn_path_is_url (APR_ARRAY_IDX (targets, 0, const char *)))
     {
- ctx->log_msg_func = NULL;
+ ctx->log_msg_func2 = NULL;
       if (opt_state->message || opt_state->filedata)
         {
           return svn_error_create
@@ -68,14 +68,14 @@

     }
   else
     {
- SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton), opt_state,
+ SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton2), opt_state,
                                            NULL, ctx->config, subpool));
     }
 
   err = svn_client_mkdir2 (&commit_info, targets, ctx, subpool);
 
- if (ctx->log_msg_func)
- err = svn_cl__cleanup_log_msg (ctx->log_msg_baton, err);
+ if (ctx->log_msg_func2)
+ err = svn_cl__cleanup_log_msg (ctx->log_msg_baton2, err);
 
   if (err)
     {
Index: subversion/clients/cmdline/move-cmd.c

===================================================================

--- subversion/clients/cmdline/move-cmd.c (revision 15883)

+++ subversion/clients/cmdline/move-cmd.c (working copy)

@@ -58,7 +58,7 @@

     svn_cl__get_notifier (&ctx->notify_func2, &ctx->notify_baton2, FALSE,
                           FALSE, FALSE, pool);
 
- SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton), opt_state,
+ SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton2), opt_state,
                                        NULL, ctx->config, pool));
 
   if (opt_state->start_revision.kind != svn_opt_revision_unspecified
@@ -74,7 +74,7 @@

 
   if (err)
     err = svn_cl__may_need_force (err);
- SVN_ERR (svn_cl__cleanup_log_msg (ctx->log_msg_baton, err));
+ SVN_ERR (svn_cl__cleanup_log_msg (ctx->log_msg_baton2, err));
 
   if (commit_info && ! opt_state->quiet)
     SVN_ERR (svn_cl__print_commit_info (commit_info, pool));
Index: subversion/clients/cmdline/copy-cmd.c

===================================================================

--- subversion/clients/cmdline/copy-cmd.c (revision 15883)

+++ subversion/clients/cmdline/copy-cmd.c (working copy)

@@ -99,23 +99,23 @@

 
   if (! dst_is_url)
     {
- ctx->log_msg_func = NULL;
+ ctx->log_msg_func2 = NULL;
       if (opt_state->message || opt_state->filedata)
         return svn_error_create
           (SVN_ERR_CL_UNNECESSARY_LOG_MESSAGE, NULL,
            _("Local, non-commit operations do not take a log message"));
     }
 
- if (ctx->log_msg_func)
- SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton), opt_state,
+ if (ctx->log_msg_func2)
+ SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton2), opt_state,
                                          NULL, ctx->config, pool));
 
   err = svn_client_copy2 (&commit_info, src_path,
                           &(opt_state->start_revision),
                           dst_path, ctx, pool);
 
- if (ctx->log_msg_func)
- SVN_ERR (svn_cl__cleanup_log_msg (ctx->log_msg_baton, err));
+ if (ctx->log_msg_func2)
+ SVN_ERR (svn_cl__cleanup_log_msg (ctx->log_msg_baton2, err));
   else if (err)
     return err;
 
Index: subversion/clients/cmdline/util.c

===================================================================

--- subversion/clients/cmdline/util.c (revision 15883)

+++ subversion/clients/cmdline/util.c (working copy)

@@ -436,7 +436,7 @@

 
 #define EDITOR_EOF_PREFIX _("--This line, and those below, will be ignored--")
 
-/* This function is of type svn_client_get_commit_log_t. */
+/* This function is of type svn_client_get_commit_log2_t. */
 svn_error_t *
 svn_cl__get_log_message (const char **log_msg,
                          const char **tmp_file,
@@ -488,8 +488,8 @@

 
       for (i = 0; i < commit_items->nelts; i++)
         {
- svn_client_commit_item_t *item
- = ((svn_client_commit_item_t **) commit_items->elts)[i];
+ svn_client_commit_item2_t *item
+ = ((svn_client_commit_item2_t **) commit_items->elts)[i];
           const char *path = item->path;
           char text_mod = '_', prop_mod = ' ', unlock = ' ';
 
Index: subversion/clients/cmdline/commit-cmd.c

===================================================================

--- subversion/clients/cmdline/commit-cmd.c (revision 15883)

+++ subversion/clients/cmdline/commit-cmd.c (working copy)

@@ -86,13 +86,13 @@

      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_baton),
+ SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton2),
                                        opt_state, base_dir,
                                        ctx->config, pool));
 
   /* Commit. */
   SVN_ERR (svn_cl__cleanup_log_msg
- (ctx->log_msg_baton, svn_client_commit3 (&commit_info,
+ (ctx->log_msg_baton2, svn_client_commit3 (&commit_info,
                                                     targets,
                                                     opt_state->nonrecursive
                                                     ? FALSE : TRUE,
Index: subversion/clients/cmdline/delete-cmd.c

===================================================================

--- subversion/clients/cmdline/delete-cmd.c (revision 15883)

+++ subversion/clients/cmdline/delete-cmd.c (working copy)

@@ -56,7 +56,7 @@

 
   if (! svn_path_is_url (APR_ARRAY_IDX (targets, 0, const char *)))
     {
- ctx->log_msg_func = NULL;
+ ctx->log_msg_func2 = NULL;
       if (opt_state->message || opt_state->filedata)
         {
           return svn_error_create
@@ -66,7 +66,7 @@

     }
   else
     {
- SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton), opt_state,
+ SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton2), opt_state,
                                            NULL, ctx->config, pool));
     }
 
@@ -74,8 +74,8 @@

   if (err)
     err = svn_cl__may_need_force (err);
 
- if (ctx->log_msg_func)
- SVN_ERR (svn_cl__cleanup_log_msg (ctx->log_msg_baton, err));
+ if (ctx->log_msg_func2)
+ SVN_ERR (svn_cl__cleanup_log_msg (ctx->log_msg_baton2, err));
   else if (err)
     return err;
 
Index: subversion/clients/cmdline/import-cmd.c

===================================================================

--- subversion/clients/cmdline/import-cmd.c (revision 15883)

+++ subversion/clients/cmdline/import-cmd.c (working copy)

@@ -104,10 +104,10 @@

     svn_cl__get_notifier (&ctx->notify_func2, &ctx->notify_baton2,
                           FALSE, FALSE, FALSE, pool);
 
- SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton), opt_state,
+ SVN_ERR (svn_cl__make_log_msg_baton (&(ctx->log_msg_baton2), opt_state,
                                        NULL, ctx->config, pool));
   SVN_ERR (svn_cl__cleanup_log_msg
- (ctx->log_msg_baton, svn_client_import2 (&commit_info,
+ (ctx->log_msg_baton2, svn_client_import2 (&commit_info,
                                                     path,
                                                     url,
                                                     opt_state->nonrecursive,
Index: subversion/clients/cmdline/main.c

===================================================================

--- subversion/clients/cmdline/main.c (revision 15883)

+++ subversion/clients/cmdline/main.c (working copy)

@@ -1332,8 +1332,8 @@

                          SVN_CONFIG_OPTION_NO_UNLOCK, TRUE);
 
   /* Set the log message callback function. Note that individual
- subcommands will populate the ctx->log_msg_baton */
- ctx->log_msg_func = svn_cl__get_log_message;
+ subcommands will populate the ctx->log_msg_baton2 */
+ ctx->log_msg_func2 = svn_cl__get_log_message;
 
   /* Authentication set-up. */
   {

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Aug 24 00:27:55 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.