2 * move-cmd.c -- Subversion move command
4 * ====================================================================
5 * Copyright (c) 2000-2006 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"
36 /* This implements the `svn_opt_subcommand_t' interface. */
38 svn_cl__move(apr_getopt_t
*os
,
42 svn_cl__opt_state_t
*opt_state
= ((svn_cl__cmd_baton_t
*) baton
)->opt_state
;
43 svn_client_ctx_t
*ctx
= ((svn_cl__cmd_baton_t
*) baton
)->ctx
;
44 apr_array_header_t
*targets
;
46 svn_commit_info_t
*commit_info
= NULL
;
49 SVN_ERR(svn_opt_args_to_target_array2(&targets
, os
,
50 opt_state
->targets
, pool
));
52 if (targets
->nelts
< 2)
53 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS
, 0, NULL
);
55 if (opt_state
->start_revision
.kind
!= svn_opt_revision_unspecified
56 && opt_state
->start_revision
.kind
!= svn_opt_revision_head
)
58 return svn_error_create
59 (SVN_ERR_UNSUPPORTED_FEATURE
, NULL
,
60 _("Cannot specify revisions (except HEAD) with move operations"));
63 if (! opt_state
->quiet
)
64 svn_cl__get_notifier(&ctx
->notify_func2
, &ctx
->notify_baton2
, FALSE
,
67 dst_path
= APR_ARRAY_IDX(targets
, targets
->nelts
- 1, const char *);
68 apr_array_pop(targets
);
70 if (! svn_path_is_url(dst_path
))
72 ctx
->log_msg_func3
= NULL
;
73 if (opt_state
->message
|| opt_state
->filedata
|| opt_state
->revprop_table
)
74 return svn_error_create
75 (SVN_ERR_CL_UNNECESSARY_LOG_MESSAGE
, NULL
,
76 _("Local, non-commit operations do not take a log message "
77 "or revision properties"));
80 if (ctx
->log_msg_func3
)
81 SVN_ERR(svn_cl__make_log_msg_baton(&(ctx
->log_msg_baton3
), opt_state
,
82 NULL
, ctx
->config
, pool
));
84 ctx
->revprop_table
= opt_state
->revprop_table
;
86 err
= svn_client_move5(&commit_info
, targets
, dst_path
, opt_state
->force
,
87 TRUE
, opt_state
->parents
, ctx
, pool
);
90 err
= svn_cl__may_need_force(err
);
92 if (ctx
->log_msg_func3
)
93 SVN_ERR(svn_cl__cleanup_log_msg(ctx
->log_msg_baton3
, err
));
97 if (commit_info
&& ! opt_state
->quiet
)
98 SVN_ERR(svn_cl__print_commit_info(commit_info
, pool
));