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_opt_args_to_target_array2(&targets, os,
50
opt_state->targets, pool));
52
/* We want exactly 1 or 2 targets for this subcommand. */
53
if (targets->nelts < 1)
54
return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
55
if (targets->nelts > 2)
56
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, 0, NULL);
58
/* The first target is the `from' path. */
59
from = ((const char **) (targets->elts))[0];
61
/* Get the peg revision if present. */
62
SVN_ERR(svn_opt_parse_path(&peg_revision, &truefrom, from, pool));
64
/* If only one target was given, split off the basename to use as
65
the `to' path. Else, a `to' path was supplied. */
66
if (targets->nelts == 1)
67
to = svn_path_uri_decode(svn_path_basename(truefrom, pool), pool);
69
to = ((const char **) (targets->elts))[1];
71
if (! opt_state->quiet)
72
svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2, FALSE, TRUE,
76
err = svn_client_export3(NULL, truefrom, to, &peg_revision,
77
&(opt_state->start_revision),
78
opt_state->force, opt_state->ignore_externals,
79
opt_state->nonrecursive ? FALSE : TRUE,
80
opt_state->native_eol, ctx,
82
if (err && err->apr_err == SVN_ERR_WC_OBSTRUCTED_UPDATE && !opt_state->force)
84
_("Destination directory exists; please remove "
85
"the directory or use --force to overwrite"));