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

[PATCH] Resend: Issue #1296: --force option for svn export

From: plasma <plasmaball_at_pchome.com.tw>
Date: 2003-06-19 08:04:30 CEST

Hi all,

This is a resent patch. It works against 0.24.2.

plasma

LOG:

Fix issue #1296: --force option for svn export

  * clients/cmdline/main.c: Add svn_cl__force_opt for export in
    svn_cl__options.

  * clients/cmdline/export-cmd.c
    Interface of svn_client_export() is changed. A new argument named force.
    Give suggestions if target directory exists and --force is not given.

  * include/svn_client.h:
    Interface of svn_client_export() is changed. A new argument named force.

  * libsvn_clients/export.c
    (svn_client_export, svn_client__get_export_editor):
    Interface is changed. A new argument named force.
    (struct edit_baton): A new force field is added.
    (open_root, add_directory): If a --force option is specified, an
    existing directory is no longer an error.

PATCH:

--- subversion/clients/cmdline/main.c.orig Sun May 18 08:16:30 2003
+++ subversion/clients/cmdline/main.c Mon May 19 18:01:27 2003
@@ -226,7 +226,7 @@
     " 2. Exports a clean directory tree from the working copy specified by\n"
     " PATH1 into PATH2. all local changes will be preserved, but files\n"
     " not under revision control will not be copied.\n",
- {'r', 'q', SVN_CL__AUTH_OPTIONS} },
+ {'r', 'q', svn_cl__force_opt, SVN_CL__AUTH_OPTIONS} },
 
   { "help", svn_cl__help, {"?", "h"},
     "Display this usage message.\n"
--- subversion/clients/cmdline/export-cmd.c.orig Sun May 18 08:16:30 2003
+++ subversion/clients/cmdline/export-cmd.c Mon May 19 23:59:46 2003
@@ -42,6 +42,7 @@
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   const char *from, *to;
   apr_array_header_t *targets;
+ svn_error_t *err;
 
   SVN_ERR (svn_opt_args_to_target_array (&targets, os,
                                          opt_state->targets,
@@ -68,10 +69,18 @@
                           FALSE, pool);
 
   /* Do the export. */
- SVN_ERR (svn_client_export (from,
- to,
- &(opt_state->start_revision),
- ctx,
- pool));
+ err = svn_client_export (from,
+ to,
+ &(opt_state->start_revision),
+ opt_state->force,
+ ctx,
+ pool);
+ if (err && err->apr_err == SVN_ERR_WC_OBSTRUCTED_UPDATE && !opt_state->force)
+ SVN_ERR_W (err,
+ "Destination directory exists. Please remove "
+ "the directory, or try again with --force.");
+ else
+ SVN_ERR (err);
+
   return SVN_NO_ERROR;
 }
--- subversion/libsvn_client/export.c.orig Sun May 18 08:18:33 2003
+++ subversion/libsvn_client/export.c Tue May 20 00:02:31 2003
@@ -141,6 +141,7 @@
 svn_client_export (const char *from,
                    const char *to,
                    svn_opt_revision_t *revision,
+ svn_boolean_t force,
                    svn_client_ctx_t *ctx,
                    apr_pool_t *pool)
 {
@@ -156,7 +157,7 @@
       URL = svn_path_canonicalize (from, pool);
       
       SVN_ERR (svn_client__get_export_editor (&export_editor, &edit_baton,
- to, URL, ctx, pool));
+ to, URL, force, ctx, pool));
       
       if (revision->kind == svn_opt_revision_number)
         revnum = revision->value.number;
@@ -195,6 +196,7 @@
 {
   const char *root_path;
   const char *root_url;
+ svn_boolean_t force;
 
   svn_wc_notify_func_t notify_func;
   void *notify_baton;
@@ -250,11 +252,14 @@
   svn_node_kind_t kind;
   
   SVN_ERR (svn_io_check_path (eb->root_path, &kind, pool));
- if (kind != svn_node_none)
- return svn_error_create (SVN_ERR_WC_OBSTRUCTED_UPDATE,
- NULL, eb->root_path);
-
- SVN_ERR (svn_io_dir_make (eb->root_path, APR_OS_DEFAULT, pool));
+ if ( kind == svn_node_none )
+ SVN_ERR (svn_io_dir_make (eb->root_path, APR_OS_DEFAULT, pool));
+ else if (kind == svn_node_file)
+ return svn_error_create (SVN_ERR_WC_NOT_DIRECTORY,
+ NULL, eb->root_path);
+ else if ( (! (kind == svn_node_dir && eb->force)) || kind != svn_node_dir)
+ return svn_error_create (SVN_ERR_WC_OBSTRUCTED_UPDATE,
+ NULL, eb->root_path);
 
   if (eb->notify_func)
     (*eb->notify_func) (eb->notify_baton,
@@ -283,8 +288,17 @@
   struct edit_baton *eb = parent_baton;
   const char *full_path = svn_path_join (eb->root_path,
                                          path, pool);
+ svn_node_kind_t kind;
 
- SVN_ERR (svn_io_dir_make (full_path, APR_OS_DEFAULT, pool));
+ SVN_ERR (svn_io_check_path (full_path, &kind, pool));
+ if ( kind == svn_node_none )
+ SVN_ERR (svn_io_dir_make (full_path, APR_OS_DEFAULT, pool));
+ else if (kind == svn_node_file)
+ return svn_error_create (SVN_ERR_WC_NOT_DIRECTORY,
+ NULL, full_path);
+ else if (! (kind == svn_node_dir && eb->force))
+ return svn_error_create (SVN_ERR_WC_OBSTRUCTED_UPDATE,
+ NULL, full_path);
 
   if (eb->notify_func)
     (*eb->notify_func) (eb->notify_baton,
@@ -492,6 +506,7 @@
                                void **edit_baton,
                                const char *root_path,
                                const char *root_url,
+ svn_boolean_t force,
                                svn_client_ctx_t *ctx,
                                apr_pool_t *pool)
 {
@@ -500,6 +515,7 @@
 
   eb->root_path = apr_pstrdup (pool, root_path);
   eb->root_url = apr_pstrdup (pool, root_url);
+ eb->force = force;
   eb->notify_func = ctx->notify_func;
   eb->notify_baton = ctx->notify_baton;
 
--- subversion/libsvn_client/client.h.orig Mon May 19 23:23:22 2003
+++ subversion/libsvn_client/client.h Mon May 19 23:23:26 2003
@@ -224,6 +224,7 @@
                                              void **edit_baton,
                                              const char *root_path,
                                              const char *root_url,
+ svn_boolean_t force,
                                              svn_client_ctx_t *ctx,
                                              apr_pool_t *pool);
 
--- subversion/include/svn_client.h.orig Sun May 18 08:21:39 2003
+++ subversion/include/svn_client.h Mon May 19 18:01:27 2003
@@ -1181,6 +1181,7 @@
 svn_client_export (const char *from,
                    const char *to,
                    svn_opt_revision_t *revision,
+ svn_boolean_t force,
                    svn_client_ctx_t *ctx,
                    apr_pool_t *pool);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jun 19 08:05:44 2003

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.