2 * unlcok-cmd.c -- Unlock a working copy path.
4 * ====================================================================
5 * Copyright (c) 2004-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 /* ==================================================================== */
25 #include "svn_pools.h"
26 #include "svn_client.h"
27 #include "svn_error_codes.h"
28 #include "svn_error.h"
29 #include "svn_cmdline.h"
31 #include "svn_private_config.h"
37 /* This implements the `svn_opt_subcommand_t' interface. */
39 svn_cl__unlock(apr_getopt_t
*os
,
43 svn_cl__opt_state_t
*opt_state
= ((svn_cl__cmd_baton_t
*) baton
)->opt_state
;
44 svn_client_ctx_t
*ctx
= ((svn_cl__cmd_baton_t
*) baton
)->ctx
;
45 apr_array_header_t
*targets
;
46 apr_array_header_t
*changelist_targets
= NULL
, *combined_targets
= NULL
;
48 /* Before allowing svn_opt_args_to_target_array2() to canonicalize
49 all the targets, we need to build a list of targets made of both
50 ones the user typed, as well as any specified by --changelist. */
51 if (opt_state
->changelist
)
53 SVN_ERR(svn_client_get_changelist(&changelist_targets
,
54 opt_state
->changelist
,
58 if (apr_is_empty_array(changelist_targets
))
59 return svn_error_createf(SVN_ERR_UNKNOWN_CHANGELIST
, NULL
,
60 _("Unknown changelist '%s'"),
61 opt_state
->changelist
);
64 if (opt_state
->targets
&& changelist_targets
)
65 combined_targets
= apr_array_append(pool
, opt_state
->targets
,
67 else if (opt_state
->targets
)
68 combined_targets
= opt_state
->targets
;
69 else if (changelist_targets
)
70 combined_targets
= changelist_targets
;
72 SVN_ERR(svn_opt_args_to_target_array2(&targets
, os
,
73 combined_targets
, pool
));
75 /* We don't support unlock on directories, so "." is not relevant. */
77 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS
, 0, NULL
);
79 svn_cl__get_notifier(&ctx
->notify_func2
, &ctx
->notify_baton2
, FALSE
,
82 SVN_ERR(svn_client_unlock(targets
, opt_state
->force
, ctx
, pool
));