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

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

From: plasma <plasmaball_at_pchome.com.tw>
Date: 2003-05-19 18:17:54 CEST

On Sun, May 18, 2003 at 11:14:05PM -0500, cmpilato@collab.net wrote:
> Just a suggestion (doesn't count as a patch review): if an existing
> directory is the only condition that causes SVN_ERR_WC_OBSTRUCTED_UPDATE
> to be returned as part of an export, you might consider having the
> client code (in export-cmd.c) check for that error, and wrap it with a
> suggestion that the user either remove the directory, or use the
> --force option.

Sounds good. Below is another try, and it is aginst 0.23. In
addition, I throw SVN_ERR_WC_OBSTRUCTED_UPDATE if target is a file
instead of a directory in open_root() and add_directory().

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);
 
==========================================================
 @dwҦt
 http://edm-prg.epaper.com.tw/click.php?ad_code=7762
==========================================================
 PChomeʪGxWĤ@ʪI
 http://shopping.pchome.com.tw/
==========================================================

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon May 19 18:19:01 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.