You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/07/22 16:09:19 UTC

svn commit: r966669 - in /subversion/trunk/subversion: include/svn_client.h libsvn_client/copy.c libsvn_client/deprecated.c svn/copy-cmd.c svn/move-cmd.c

Author: hwright
Date: Thu Jul 22 14:09:18 2010
New Revision: 966669

URL: http://svn.apache.org/viewvc?rev=966669&view=rev
Log:
Update the move and copy APIs to use the commit callback supplied in the client
context, rather than returning it directly.

* subversion/svn/move-cmd.c
  (svn_cl__move): Update call to client API.

* subversion/svn/copy-cmd.c
  (svn_cl__copy): Same.

* subversion/include/svn_client.h
  (svn_client_copy6): New.
  (svn_client_copy5): Deprecate.
  (svn_client_move6): New.
  (svn_client_move5): Deprecate.

* subversion/libsvn_client/deprecated.c
  (svn_client_copy5, svn_client_move5): New deprecated wrappers.

* subversion/libsvn_client/copy.c
  (repos_to_repos_copy, wc_to_repos_copy): Remove commit_info param, and use
    the context callback and baton to retrieving the commit info.
  (try_copy): Remove the commit_info param.
  (svn_client_copy5, svn_client_move5): Remove.
  (svn_client_copy6, svn_client_move6): New.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/copy.c
    subversion/trunk/subversion/libsvn_client/deprecated.c
    subversion/trunk/subversion/svn/copy-cmd.c
    subversion/trunk/subversion/svn/move-cmd.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=966669&r1=966668&r2=966669&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Thu Jul 22 14:09:18 2010
@@ -3615,10 +3615,7 @@ typedef struct svn_client_copy_source_t
  *
  * If @a dst_path is a URL, use the authentication baton
  * in @a ctx and @a ctx->log_msg_func3/@a ctx->log_msg_baton3 to immediately
- * attempt to commit the copy action in the repository.  If the commit
- * succeeds, allocate (in @a pool) and populate @a *commit_info_p.  If
- * @a dst_path is not a URL, and the copy succeeds, set @a
- * *commit_info_p to @c NULL.
+ * attempt to commit the copy action in the repository.
  *
  * If @a dst_path is not a URL, then this is just a variant of
  * svn_client_add(), where the @a sources are scheduled for addition
@@ -3645,8 +3642,30 @@ typedef struct svn_client_copy_source_t
  * for each item added at the new location, passing the new, relative path of
  * the added item.
  *
+ * If @a ctx->commit_callback2 is non-NULL, then for each successful commit,
+ * call @a ctx->commit_callback2 with @a ctx->commit_baton and a
+ * #svn_commit_info_t for the commit.
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_client_copy6(const apr_array_header_t *sources,
+                 const char *dst_path,
+                 svn_boolean_t copy_as_child,
+                 svn_boolean_t make_parents,
+                 svn_boolean_t ignore_externals,
+                 const apr_hash_t *revprop_table,
+                 svn_client_ctx_t *ctx,
+                 apr_pool_t *pool);
+
+/**
+ * Similar to svn_client_copy6(), but returns the @a commit_info_p directly,
+ * rather than through @a ctx->commit_callback2.
+ *
  * @since New in 1.6.
+ * @deprecated Provided for backward compatibility with the 1.6 API.
  */
+SVN_DEPRECATED
 svn_error_t *
 svn_client_copy5(svn_commit_info_t **commit_info_p,
                  const apr_array_header_t *sources,
@@ -3754,8 +3773,7 @@ svn_client_copy(svn_client_commit_info_t
  *   - The authentication baton in @a ctx and @a ctx->log_msg_func/@a
  *     ctx->log_msg_baton are used to commit the move.
  *
- *   - The move operation will be immediately committed.  If the
- *     commit succeeds, allocate (in @a pool) and populate @a *commit_info_p.
+ *   - The move operation will be immediately committed.
  *
  * If @a src_paths are working copy paths:
  *
@@ -3774,8 +3792,6 @@ svn_client_copy(svn_client_commit_info_t
  *     items and @a force is not set, the move will fail. If @a force is set
  *     such items will be removed.
  *
- *   - If the move succeeds, set @a *commit_info_p to @c NULL.
- *
  * The parent of @a dst_path must already exist.
  *
  * If @a src_paths has only one item, attempt to move it to @a dst_path.  If
@@ -3813,8 +3829,30 @@ svn_client_copy(svn_client_commit_info_t
  *
  * ### Is this really true?  What about svn_wc_notify_commit_replaced()? ###
  *
+ * If @a ctx->commit_callback2 is non-NULL, then for each successful commit,
+ * call @a ctx->commit_callback2 with @a ctx->commit_baton and a
+ * #svn_commit_info_t for the commit.
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_client_move6(const apr_array_header_t *src_paths,
+                 const char *dst_path,
+                 svn_boolean_t force,
+                 svn_boolean_t move_as_child,
+                 svn_boolean_t make_parents,
+                 const apr_hash_t *revprop_table,
+                 svn_client_ctx_t *ctx,
+                 apr_pool_t *pool);
+
+/**
+ * Similar to svn_client_move6(), but returns the @a commit_info_p directly,
+ * rather than through @a ctx->commit_callback2.
+ *
  * @since New in 1.5.
+ * @deprecated Provided for backward compatibility with the 1.6 API.
  */
+SVN_DEPRECATED
 svn_error_t *
 svn_client_move5(svn_commit_info_t **commit_info_p,
                  const apr_array_header_t *src_paths,

Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=966669&r1=966668&r2=966669&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Thu Jul 22 14:09:18 2010
@@ -720,8 +720,7 @@ find_absent_parents2(svn_ra_session_t *r
 }
 
 static svn_error_t *
-repos_to_repos_copy(svn_commit_info_t **commit_info_p,
-                    const apr_array_header_t *copy_pairs,
+repos_to_repos_copy(const apr_array_header_t *copy_pairs,
                     svn_boolean_t make_parents,
                     const apr_hash_t *revprop_table,
                     svn_client_ctx_t *ctx,
@@ -739,7 +738,6 @@ repos_to_repos_copy(svn_commit_info_t **
   svn_ra_session_t *ra_session = NULL;
   const svn_delta_editor_t *editor;
   void *edit_baton;
-  void *commit_baton;
   struct path_driver_cb_baton cb_baton;
   apr_array_header_t *new_dirs = NULL;
   apr_hash_t *commit_revprops;
@@ -1115,11 +1113,10 @@ repos_to_repos_copy(svn_commit_info_t **
                                            message, ctx, pool));
 
   /* Fetch RA commit editor. */
-  SVN_ERR(svn_client__commit_get_baton(&commit_baton, commit_info_p, pool));
   SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton,
                                     commit_revprops,
-                                    svn_client__commit_callback,
-                                    commit_baton,
+                                    ctx->commit_callback2,
+                                    ctx->commit_baton,
                                     NULL, TRUE, /* No lock tokens */
                                     pool));
 
@@ -1151,8 +1148,7 @@ repos_to_repos_copy(svn_commit_info_t **
  * REVPROP_TABLE is ...
  * CTX is ... */
 static svn_error_t *
-wc_to_repos_copy(svn_commit_info_t **commit_info_p,
-                 const apr_array_header_t *copy_pairs,
+wc_to_repos_copy(const apr_array_header_t *copy_pairs,
                  svn_boolean_t make_parents,
                  const apr_hash_t *revprop_table,
                  svn_client_ctx_t *ctx,
@@ -1164,7 +1160,6 @@ wc_to_repos_copy(svn_commit_info_t **com
   svn_ra_session_t *ra_session;
   const svn_delta_editor_t *editor;
   void *edit_baton;
-  void *commit_baton;
   apr_hash_t *committables;
   apr_array_header_t *commit_items;
   apr_pool_t *iterpool;
@@ -1392,11 +1387,10 @@ wc_to_repos_copy(svn_commit_info_t **com
                                                FALSE, FALSE, ctx, pool));
 
   /* Fetch RA commit editor. */
-  SVN_ERR(svn_client__commit_get_baton(&commit_baton, commit_info_p, pool));
   SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton,
                                     commit_revprops,
-                                    svn_client__commit_callback,
-                                    commit_baton, NULL,
+                                    ctx->commit_callback2,
+                                    ctx->commit_baton, NULL,
                                     TRUE, /* No lock tokens */
                                     pool));
 
@@ -1869,8 +1863,7 @@ repos_to_wc_copy(const apr_array_header_
 
 /* Perform all allocations in POOL. */
 static svn_error_t *
-try_copy(svn_commit_info_t **commit_info_p,
-         const apr_array_header_t *sources,
+try_copy(const apr_array_header_t *sources,
          const char *dst_path_in,
          svn_boolean_t is_move,
          svn_boolean_t force,
@@ -2154,7 +2147,6 @@ try_copy(svn_commit_info_t **commit_info
   /* Now, call the right handler for the operation. */
   if ((! srcs_are_urls) && (! dst_is_url))
     {
-      *commit_info_p = NULL;
       return svn_error_return(
         wc_to_wc_copy(copy_pairs, dst_path_in, is_move, make_parents, ctx,
                       pool));
@@ -2162,12 +2154,10 @@ try_copy(svn_commit_info_t **commit_info
   else if ((! srcs_are_urls) && (dst_is_url))
     {
       return svn_error_return(
-        wc_to_repos_copy(commit_info_p, copy_pairs, make_parents,
-                         revprop_table, ctx, pool));
+        wc_to_repos_copy(copy_pairs, make_parents, revprop_table, ctx, pool));
     }
   else if ((srcs_are_urls) && (! dst_is_url))
     {
-      *commit_info_p = NULL;
       return svn_error_return(
         repos_to_wc_copy(copy_pairs, make_parents, ignore_externals,
                          ctx, pool));
@@ -2175,7 +2165,7 @@ try_copy(svn_commit_info_t **commit_info
   else
     {
       return svn_error_return(
-        repos_to_repos_copy(commit_info_p, copy_pairs, make_parents,
+        repos_to_repos_copy(copy_pairs, make_parents,
                             revprop_table, ctx, is_move, pool));
     }
 }
@@ -2184,8 +2174,7 @@ try_copy(svn_commit_info_t **commit_info
 
 /* Public Interfaces */
 svn_error_t *
-svn_client_copy5(svn_commit_info_t **commit_info_p,
-                 const apr_array_header_t *sources,
+svn_client_copy6(const apr_array_header_t *sources,
                  const char *dst_path,
                  svn_boolean_t copy_as_child,
                  svn_boolean_t make_parents,
@@ -2195,15 +2184,13 @@ svn_client_copy5(svn_commit_info_t **com
                  apr_pool_t *pool)
 {
   svn_error_t *err;
-  svn_commit_info_t *commit_info = NULL;
   apr_pool_t *subpool = svn_pool_create(pool);
 
   if (sources->nelts > 1 && !copy_as_child)
     return svn_error_create(SVN_ERR_CLIENT_MULTIPLE_SOURCES_DISALLOWED,
                             NULL, NULL);
 
-  err = try_copy(&commit_info,
-                 sources, dst_path,
+  err = try_copy(sources, dst_path,
                  FALSE /* is_move */,
                  TRUE /* force, set to avoid deletion check */,
                  make_parents,
@@ -2232,8 +2219,7 @@ svn_client_copy5(svn_commit_info_t **com
       if (svn_path_is_url(src_path) && ! svn_path_is_url(dst_path))
         src_basename = svn_path_uri_decode(src_basename, subpool);
 
-      err = try_copy(&commit_info,
-                     sources,
+      err = try_copy(sources,
                      dst_is_uri
                          ? svn_uri_join(dst_path, src_basename, subpool)
                          : svn_dirent_join(dst_path, src_basename, subpool),
@@ -2246,22 +2232,13 @@ svn_client_copy5(svn_commit_info_t **com
                      subpool);
     }
 
-  if (commit_info_p != NULL)
-    {
-      if (commit_info)
-        *commit_info_p = svn_commit_info_dup(commit_info, pool);
-      else
-        *commit_info_p = NULL;
-    }
-
   svn_pool_destroy(subpool);
   return svn_error_return(err);
 }
 
 
 svn_error_t *
-svn_client_move5(svn_commit_info_t **commit_info_p,
-                 const apr_array_header_t *src_paths,
+svn_client_move6(const apr_array_header_t *src_paths,
                  const char *dst_path,
                  svn_boolean_t force,
                  svn_boolean_t move_as_child,
@@ -2270,7 +2247,6 @@ svn_client_move5(svn_commit_info_t **com
                  svn_client_ctx_t *ctx,
                  apr_pool_t *pool)
 {
-  svn_commit_info_t *commit_info = NULL;
   const svn_opt_revision_t head_revision
     = { svn_opt_revision_head, { 0 } };
   svn_error_t *err;
@@ -2296,7 +2272,7 @@ svn_client_move5(svn_commit_info_t **com
       APR_ARRAY_PUSH(sources, svn_client_copy_source_t *) = copy_source;
     }
 
-  err = try_copy(&commit_info, sources, dst_path,
+  err = try_copy(sources, dst_path,
                  TRUE /* is_move */,
                  force,
                  make_parents,
@@ -2322,7 +2298,7 @@ svn_client_move5(svn_commit_info_t **com
       src_basename = src_is_uri ? svn_uri_basename(src_path, pool)
                                 : svn_dirent_basename(src_path, pool);
 
-      err = try_copy(&commit_info, sources,
+      err = try_copy(sources,
                      dst_is_uri
                          ? svn_uri_join(dst_path, src_basename, pool)
                          : svn_dirent_join(dst_path, src_basename, pool),
@@ -2335,14 +2311,6 @@ svn_client_move5(svn_commit_info_t **com
                      subpool);
     }
 
-  if (commit_info_p != NULL)
-    {
-      if (commit_info)
-        *commit_info_p = svn_commit_info_dup(commit_info, pool);
-      else
-        *commit_info_p = commit_info;
-    }
-
   svn_pool_destroy(subpool);
   return svn_error_return(err);
 }

Modified: subversion/trunk/subversion/libsvn_client/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/deprecated.c?rev=966669&r1=966668&r2=966669&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_client/deprecated.c Thu Jul 22 14:09:18 2010
@@ -528,6 +528,32 @@ svn_client_commit(svn_client_commit_info
 }
 
 /*** From copy.c ***/
+svn_error_t *
+svn_client_copy5(svn_commit_info_t **commit_info_p,
+                 const apr_array_header_t *sources,
+                 const char *dst_path,
+                 svn_boolean_t copy_as_child,
+                 svn_boolean_t make_parents,
+                 svn_boolean_t ignore_externals,
+                 const apr_hash_t *revprop_table,
+                 svn_client_ctx_t *ctx,
+                 apr_pool_t *pool)
+{
+  svn_client_ctx_t shadow_ctx;
+  struct capture_baton_t cb;
+
+  cb.info = commit_info_p;
+  cb.pool = pool;
+  cb.original_callback = ctx->commit_callback2;
+  cb.original_baton = ctx->commit_baton;
+
+  shadow_ctx = *ctx;
+  shadow_ctx.commit_callback2 = capture_commit_info;
+  shadow_ctx.commit_baton = &cb;
+
+  return svn_client_copy6(sources, dst_path, copy_as_child, make_parents,
+                          ignore_externals, revprop_table, ctx, pool);
+}
 
 svn_error_t *
 svn_client_copy4(svn_commit_info_t **commit_info_p,
@@ -615,6 +641,33 @@ svn_client_copy(svn_client_commit_info_t
 }
 
 svn_error_t *
+svn_client_move5(svn_commit_info_t **commit_info_p,
+                 const apr_array_header_t *src_paths,
+                 const char *dst_path,
+                 svn_boolean_t force,
+                 svn_boolean_t move_as_child,
+                 svn_boolean_t make_parents,
+                 const apr_hash_t *revprop_table,
+                 svn_client_ctx_t *ctx,
+                 apr_pool_t *pool)
+{
+  svn_client_ctx_t shadow_ctx;
+  struct capture_baton_t cb;
+
+  cb.info = commit_info_p;
+  cb.pool = pool;
+  cb.original_callback = ctx->commit_callback2;
+  cb.original_baton = ctx->commit_baton;
+
+  shadow_ctx = *ctx;
+  shadow_ctx.commit_callback2 = capture_commit_info;
+  shadow_ctx.commit_baton = &cb;
+
+  return svn_client_move6(src_paths, dst_path, force, move_as_child,
+                          make_parents, revprop_table, &shadow_ctx, pool);
+}
+
+svn_error_t *
 svn_client_move4(svn_commit_info_t **commit_info_p,
                  const char *src_path,
                  const char *dst_path,

Modified: subversion/trunk/subversion/svn/copy-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/copy-cmd.c?rev=966669&r1=966668&r2=966669&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/copy-cmd.c (original)
+++ subversion/trunk/subversion/svn/copy-cmd.c Thu Jul 22 14:09:18 2010
@@ -48,7 +48,6 @@ svn_cl__copy(apr_getopt_t *os,
   apr_array_header_t *targets, *sources;
   const char *src_path, *dst_path;
   svn_boolean_t srcs_are_urls, dst_is_url;
-  svn_commit_info_t *commit_info = NULL;
   svn_error_t *err;
   int i;
 
@@ -138,7 +137,7 @@ svn_cl__copy(apr_getopt_t *os,
     SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
                                        NULL, ctx->config, pool));
 
-  err = svn_client_copy5(&commit_info, sources, dst_path, TRUE,
+  err = svn_client_copy6(sources, dst_path, TRUE,
                          opt_state->parents, opt_state->ignore_externals,
                          opt_state->revprop_table, ctx, pool);
 
@@ -147,8 +146,5 @@ svn_cl__copy(apr_getopt_t *os,
   else if (err)
     return svn_error_return(err);
 
-  if (commit_info && ! opt_state->quiet)
-    SVN_ERR(svn_cl__print_commit_info(commit_info, NULL, pool));
-
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/svn/move-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/move-cmd.c?rev=966669&r1=966668&r2=966669&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/move-cmd.c (original)
+++ subversion/trunk/subversion/svn/move-cmd.c Thu Jul 22 14:09:18 2010
@@ -48,7 +48,6 @@ svn_cl__move(apr_getopt_t *os,
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_array_header_t *targets;
   const char *dst_path;
-  svn_commit_info_t *commit_info = NULL;
   svn_error_t *err;
 
   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
@@ -85,7 +84,7 @@ svn_cl__move(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
 
-  err = svn_client_move5(&commit_info, targets, dst_path, opt_state->force,
+  err = svn_client_move6(targets, dst_path, opt_state->force,
                          TRUE, opt_state->parents, opt_state->revprop_table,
                          ctx, pool);
 
@@ -97,8 +96,5 @@ svn_cl__move(apr_getopt_t *os,
   else if (err)
     return svn_error_return(err);
 
-  if (commit_info && ! opt_state->quiet)
-    SVN_ERR(svn_cl__print_commit_info(commit_info, NULL, pool));
-
   return SVN_NO_ERROR;
 }