]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/subversion/subversion/svn/move-cmd.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / subversion / subversion / svn / move-cmd.c
1 /*
2  * move-cmd.c -- Subversion move command
3  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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
20  *    under the License.
21  * ====================================================================
22  */
23
24 /* ==================================================================== */
25
26
27 \f
28 /*** Includes. ***/
29
30 #include "svn_client.h"
31 #include "svn_error.h"
32 #include "svn_path.h"
33 #include "cl.h"
34
35 #include "svn_private_config.h"
36
37
38 \f
39 /*** Code. ***/
40
41 /* This implements the `svn_opt_subcommand_t' interface. */
42 svn_error_t *
43 svn_cl__move(apr_getopt_t *os,
44              void *baton,
45              apr_pool_t *pool)
46 {
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;
50   const char *dst_path;
51   svn_error_t *err;
52
53   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
54                                                       opt_state->targets,
55                                                       ctx, TRUE, pool));
56
57   if (targets->nelts < 2)
58     return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
59
60   if (opt_state->start_revision.kind != svn_opt_revision_unspecified
61       && opt_state->start_revision.kind != svn_opt_revision_head)
62     {
63       return svn_error_create
64         (SVN_ERR_UNSUPPORTED_FEATURE, NULL,
65          _("Cannot specify revisions (except HEAD) with move operations"));
66     }
67
68   dst_path = APR_ARRAY_IDX(targets, targets->nelts - 1, const char *);
69   apr_array_pop(targets);
70
71   if (! svn_path_is_url(dst_path))
72     {
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"));
79     }
80
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));
84
85   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
86
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),
94                          NULL, ctx, pool);
95
96   if (err)
97     err = svn_cl__may_need_force(err);
98
99   if (ctx->log_msg_func3)
100     SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err, pool));
101   else if (err)
102     return svn_error_trace(err);
103
104   return SVN_NO_ERROR;
105 }