In the command-line client, forbid
[svn.git] / subversion / svn / revert-cmd.c
blobf56aaf4a52a95c286abfbf219e69ba8b77af881a
1 /*
2 * revert-cmd.c -- Subversion revert command
4 * ====================================================================
5 * Copyright (c) 2000-2007 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 /* ==================================================================== */
23 /*** Includes. ***/
25 #include "svn_client.h"
26 #include "svn_error_codes.h"
27 #include "svn_error.h"
28 #include "cl.h"
30 #include "svn_private_config.h"
33 /*** Code. ***/
35 /* This implements the `svn_opt_subcommand_t' interface. */
36 svn_error_t *
37 svn_cl__revert(apr_getopt_t *os,
38 void *baton,
39 apr_pool_t *pool)
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 apr_array_header_t *targets = NULL;
44 apr_array_header_t *changelist_targets = NULL, *combined_targets = NULL;
45 svn_error_t *err;
47 /* Before allowing svn_opt_args_to_target_array2() to canonicalize
48 all the targets, we need to build a list of targets made of both
49 ones the user typed, as well as any specified by --changelist. */
50 if (opt_state->changelist)
52 SVN_ERR(svn_client_get_changelist(&changelist_targets,
53 opt_state->changelist,
54 "", /* ### FIXME */
55 ctx,
56 pool));
57 if (apr_is_empty_array(changelist_targets))
58 return svn_error_createf(SVN_ERR_UNKNOWN_CHANGELIST, NULL,
59 _("Unknown changelist '%s'"),
60 opt_state->changelist);
63 if (opt_state->targets && changelist_targets)
64 combined_targets = apr_array_append(pool, opt_state->targets,
65 changelist_targets);
66 else if (opt_state->targets)
67 combined_targets = opt_state->targets;
68 else if (changelist_targets)
69 combined_targets = changelist_targets;
71 SVN_ERR(svn_opt_args_to_target_array2(&targets, os, combined_targets, pool));
73 /* Revert has no implicit dot-target `.', so don't you put that code here! */
74 if (! targets->nelts)
75 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
77 if (! opt_state->quiet)
78 svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2, FALSE,
79 FALSE, FALSE, pool);
81 /* Revert is especially conservative, by default it is as
82 nonrecursive as possible. */
83 if (opt_state->depth == svn_depth_unknown)
84 opt_state->depth = svn_depth_empty;
86 err = svn_client_revert2(targets, opt_state->depth, ctx, pool);
88 if (err
89 && (err->apr_err == SVN_ERR_WC_NOT_LOCKED)
90 && (! SVN_DEPTH_IS_RECURSIVE(opt_state->depth)))
92 err = svn_error_quick_wrap
93 (err, _("Try 'svn revert --recursive' instead?"));
96 return err;