Author: julianfoad
Date: Tue Jan  8 09:40:32 2019
New Revision: 1850720

URL: http://svn.apache.org/viewvc?rev=1850720&view=rev
Log:
Implement an experimental 'x-wc-copy-mods' command.

This can be used to comprehensively test the WC editor (issue #4786).

* subversion/include/private/svn_client_private.h,
  subversion/libsvn_client/wc_editor.c
  (svn_client__wc_copy_mods): New.

* subversion/svn/svn.c
  (svn_cl__cmd_table): Add 'x-wc-copy-mods' command.

* subversion/svn/cl.h
  (svn_opt_subcommand_t): Declare 'svn_cl__wc_copy_mods'.

* subversion/svn/shelf-cmd.c
  (svn_cl__wc_copy_mods): New.

Modified:
    subversion/trunk/subversion/include/private/svn_client_private.h
    subversion/trunk/subversion/libsvn_client/wc_editor.c
    subversion/trunk/subversion/svn/cl.h
    subversion/trunk/subversion/svn/shelf-cmd.c
    subversion/trunk/subversion/svn/svn.c

Modified: subversion/trunk/subversion/include/private/svn_client_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_client_private.h?rev=1850720&r1=1850719&r2=1850720&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_client_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_client_private.h Tue Jan  8 
09:40:32 2019
@@ -529,6 +529,12 @@ svn_client__wc_replay(const char *src_wc
                       svn_client_ctx_t *ctx,
                       apr_pool_t *scratch_pool);
 
+svn_error_t *
+svn_client__wc_copy_mods(const char *src_wc_abspath,
+                         const char *dst_wc_abspath,
+                         svn_client_ctx_t *ctx,
+                         apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/trunk/subversion/libsvn_client/wc_editor.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/wc_editor.c?rev=1850720&r1=1850719&r2=1850720&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/wc_editor.c (original)
+++ subversion/trunk/subversion/libsvn_client/wc_editor.c Tue Jan  8 09:40:32 
2019
@@ -632,3 +632,40 @@ svn_client__wc_editor(const svn_delta_ed
                                          ctx, result_pool));
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_client__wc_copy_mods(const char *src_wc_abspath,
+                         const char *dst_wc_abspath,
+                         svn_client_ctx_t *ctx,
+                         apr_pool_t *scratch_pool)
+{
+  svn_client__pathrev_t *base;
+  const char *dst_wc_url;
+  svn_ra_session_t *ra_session;
+  const svn_delta_editor_t *editor;
+  void *edit_baton;
+  apr_array_header_t *src_targets = apr_array_make(scratch_pool, 1,
+                                                   sizeof(char *));
+
+  /* We'll need an RA session to obtain the base of any copies */
+  SVN_ERR(svn_client__wc_node_get_base(&base,
+                                       src_wc_abspath, ctx->wc_ctx,
+                                       scratch_pool, scratch_pool));
+  dst_wc_url = base->url;
+  SVN_ERR(svn_client_open_ra_session2(&ra_session,
+                                      dst_wc_url, dst_wc_abspath,
+                                      ctx, scratch_pool, scratch_pool));
+  SVN_ERR(svn_client__wc_editor(&editor, &edit_baton,
+                                dst_wc_abspath,
+                                NULL, NULL,
+                                ra_session, ctx, scratch_pool));
+
+  APR_ARRAY_PUSH(src_targets, const char *) = src_wc_abspath;
+  SVN_WC__CALL_WITH_WRITE_LOCK(
+    svn_client__wc_replay(src_wc_abspath,
+                          src_targets, svn_depth_infinity, NULL,
+                          editor, edit_baton, ctx, scratch_pool),
+    ctx->wc_ctx, dst_wc_abspath, FALSE, scratch_pool);
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/trunk/subversion/svn/cl.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1850720&r1=1850719&r2=1850720&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Tue Jan  8 09:40:32 2019
@@ -330,6 +330,7 @@ svn_opt_subcommand_t
   svn_cl__shelf_save,
   svn_cl__shelf_shelve,
   svn_cl__shelf_unshelve,
+  svn_cl__wc_copy_mods,
   svn_cl__status,
   svn_cl__switch,
   svn_cl__unlock,

Modified: subversion/trunk/subversion/svn/shelf-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/shelf-cmd.c?rev=1850720&r1=1850719&r2=1850720&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/shelf-cmd.c (original)
+++ subversion/trunk/subversion/svn/shelf-cmd.c Tue Jan  8 09:40:32 2019
@@ -1207,3 +1207,26 @@ svn_cl__shelf_log(apr_getopt_t *os,
 
   return SVN_NO_ERROR;
 }
+
+/**************************************************************************/
+
+/* This implements the `svn_opt_subcommand_t' interface. */
+svn_error_t *
+svn_cl__wc_copy_mods(apr_getopt_t *os,
+                     void *baton,
+                     apr_pool_t *pool)
+{
+  svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
+  const char *src_wc_abspath, *dst_wc_abspath;
+
+  SVN_ERR(get_next_argument(&src_wc_abspath, os, pool, pool));
+  SVN_ERR(svn_dirent_get_absolute(&src_wc_abspath, src_wc_abspath, pool));
+
+  SVN_ERR(get_next_argument(&dst_wc_abspath, os, pool, pool));
+  SVN_ERR(svn_dirent_get_absolute(&dst_wc_abspath, dst_wc_abspath, pool));
+
+  SVN_ERR(svn_client__wc_copy_mods(src_wc_abspath, dst_wc_abspath,
+                                   ctx, pool));
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/trunk/subversion/svn/svn.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1850720&r1=1850719&r2=1850720&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Tue Jan  8 09:40:32 2019
@@ -2138,6 +2138,19 @@ const svn_opt_subcommand_desc3_t svn_cl_
     )},
     {opt_drop, 'q', opt_dry_run, opt_force} },
 
+  { "x-wc-copy-mods", svn_cl__wc_copy_mods, {0}, {N_(
+     "Copy local modifications from one WC to another.\n"
+     "usage: x-wc-copy-mods SRC_WC_PATH DST_WC_PATH\n"
+     "\n"), N_(
+     "  The source and destination WC paths may be in the same WC or in 
different"
+     "  WCs.\n"
+     "\n"), N_(
+     "  This feature is EXPERIMENTAL. This command is likely to change\n"
+     "  in the next release, and there is no promise of backward 
compatibility.\n"
+    )},
+    {}
+  },
+
   { NULL, NULL, {0}, {NULL}, {0} }
 };
 


Reply via email to