1 | /* |
---|
2 | * revert-cmd.c -- Subversion revert command |
---|
3 | * |
---|
4 | * ==================================================================== |
---|
5 | * Copyright (c) 2000-2007 CollabNet. All rights reserved. |
---|
6 | * |
---|
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. |
---|
12 | * |
---|
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 | * ==================================================================== |
---|
17 | */ |
---|
18 | |
---|
19 | /* ==================================================================== */ |
---|
20 | |
---|
21 | |
---|
22 | |
---|
23 | /*** Includes. ***/ |
---|
24 | |
---|
25 | #include "svn_client.h" |
---|
26 | #include "svn_error_codes.h" |
---|
27 | #include "svn_error.h" |
---|
28 | #include "cl.h" |
---|
29 | |
---|
30 | #include "svn_private_config.h" |
---|
31 | |
---|
32 | |
---|
33 | /*** Code. ***/ |
---|
34 | |
---|
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) |
---|
40 | { |
---|
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 | svn_error_t *err; |
---|
45 | |
---|
46 | SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os, |
---|
47 | opt_state->targets, |
---|
48 | ctx, pool)); |
---|
49 | |
---|
50 | /* Revert has no implicit dot-target `.', so don't you put that code here! */ |
---|
51 | if (! targets->nelts) |
---|
52 | return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL); |
---|
53 | |
---|
54 | if (! opt_state->quiet) |
---|
55 | svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2, FALSE, |
---|
56 | FALSE, FALSE, pool); |
---|
57 | |
---|
58 | /* Revert is especially conservative, by default it is as |
---|
59 | nonrecursive as possible. */ |
---|
60 | if (opt_state->depth == svn_depth_unknown) |
---|
61 | opt_state->depth = svn_depth_empty; |
---|
62 | |
---|
63 | err = svn_client_revert2(targets, opt_state->depth, |
---|
64 | opt_state->changelists, ctx, pool); |
---|
65 | |
---|
66 | if (err |
---|
67 | && (err->apr_err == SVN_ERR_WC_NOT_LOCKED) |
---|
68 | && (! SVN_DEPTH_IS_RECURSIVE(opt_state->depth))) |
---|
69 | { |
---|
70 | err = svn_error_quick_wrap |
---|
71 | (err, _("Try 'svn revert --depth infinity' instead?")); |
---|
72 | } |
---|
73 | |
---|
74 | return err; |
---|
75 | } |
---|