2 * export-cmd.c -- Subversion export command
4 * ====================================================================
5 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 /* ==================================================================== */
25 #include "svn_client.h"
26 #include "svn_error.h"
30 #include "svn_private_config.h"
35 /* This implements the `svn_opt_subcommand_t' interface. */
37 svn_cl__export(apr_getopt_t
*os
,
41 svn_cl__opt_state_t
*opt_state
= ((svn_cl__cmd_baton_t
*) baton
)->opt_state
;
42 svn_client_ctx_t
*ctx
= ((svn_cl__cmd_baton_t
*) baton
)->ctx
;
43 const char *from
, *to
;
44 apr_array_header_t
*targets
;
46 svn_opt_revision_t peg_revision
;
49 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets
, os
,
53 /* We want exactly 1 or 2 targets for this subcommand. */
54 if (targets
->nelts
< 1)
55 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS
, 0, NULL
);
56 if (targets
->nelts
> 2)
57 return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR
, 0, NULL
);
59 /* The first target is the `from' path. */
60 from
= APR_ARRAY_IDX(targets
, 0, const char *);
62 /* Get the peg revision if present. */
63 SVN_ERR(svn_opt_parse_path(&peg_revision
, &truefrom
, from
, pool
));
65 /* If only one target was given, split off the basename to use as
66 the `to' path. Else, a `to' path was supplied. */
67 if (targets
->nelts
== 1)
68 to
= svn_path_uri_decode(svn_path_basename(truefrom
, pool
), pool
);
70 to
= APR_ARRAY_IDX(targets
, 1, const char *);
72 if (! opt_state
->quiet
)
73 svn_cl__get_notifier(&ctx
->notify_func2
, &ctx
->notify_baton2
, FALSE
, TRUE
,
76 if (opt_state
->depth
== svn_depth_unknown
)
77 opt_state
->depth
= svn_depth_infinity
;
80 err
= svn_client_export4(NULL
, truefrom
, to
, &peg_revision
,
81 &(opt_state
->start_revision
),
82 opt_state
->force
, opt_state
->ignore_externals
,
84 opt_state
->native_eol
, ctx
,
86 if (err
&& err
->apr_err
== SVN_ERR_WC_OBSTRUCTED_UPDATE
&& !opt_state
->force
)
88 _("Destination directory exists; please remove "
89 "the directory or use --force to overwrite"));