2 * move-cmd.c -- Subversion move command
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
24 /* ==================================================================== */
30 #include "svn_client.h"
31 #include "svn_error.h"
35 #include "svn_private_config.h"
41 /* This implements the `svn_opt_subcommand_t' interface. */
43 svn_cl__move(apr_getopt_t *os,
47 svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
48 svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
49 apr_array_header_t *targets;
53 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
57 if (targets->nelts < 2)
58 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
60 if (opt_state->start_revision.kind != svn_opt_revision_unspecified
61 && opt_state->start_revision.kind != svn_opt_revision_head)
63 return svn_error_create
64 (SVN_ERR_UNSUPPORTED_FEATURE, NULL,
65 _("Cannot specify revisions (except HEAD) with move operations"));
68 dst_path = APR_ARRAY_IDX(targets, targets->nelts - 1, const char *);
69 apr_array_pop(targets);
71 if (! svn_path_is_url(dst_path))
73 ctx->log_msg_func3 = NULL;
74 if (opt_state->message || opt_state->filedata || opt_state->revprop_table)
75 return svn_error_create
76 (SVN_ERR_CL_UNNECESSARY_LOG_MESSAGE, NULL,
77 _("Local, non-commit operations do not take a log message "
78 "or revision properties"));
81 if (ctx->log_msg_func3)
82 SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
83 NULL, ctx->config, pool));
85 SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
87 err = svn_client_move7(targets, dst_path,
88 TRUE /* move_as_child */,
89 opt_state->parents /* make_parents */,
90 opt_state->allow_mixed_rev /* allow_mixed_revisions*/,
91 FALSE /* metadata_only */,
92 opt_state->revprop_table,
93 (opt_state->quiet ? NULL : svn_cl__print_commit_info),
97 err = svn_cl__may_need_force(err);
99 if (ctx->log_msg_func3)
100 SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err, pool));
102 return svn_error_trace(err);