2 * revert.c: wrapper around wc revert functionality.
4 * ====================================================================
5 * Copyright (c) 2000-2004 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 /* ==================================================================== */
26 #include "svn_client.h"
27 #include "svn_pools.h"
28 #include "svn_error.h"
30 #include "svn_config.h"
32 #include "private/svn_wc_private.h"
38 /* Attempt to revert PATH.
40 If DEPTH is svn_depth_empty, revert just the properties on the
41 directory; else if svn_depth_files, revert the properties and any
42 files immediately under the directory; else if
43 svn_depth_immediates, revert all of the preceding plus properties
44 on immediate subdirectories; else if svn_depth_infinity, revert
45 path and everything under it fully recursively.
47 Consult CTX to determine whether or not to revert timestamp to the
48 time of last commit ('use-commit-times = yes'). Use POOL for
51 If PATH is unversioned, return SVN_ERR_UNVERSIONED_RESOURCE. */
53 revert(const char *path
,
55 svn_boolean_t use_commit_times
,
56 svn_client_ctx_t
*ctx
,
59 svn_wc_adm_access_t
*adm_access
, *target_access
;
62 int adm_lock_level
= SVN_WC__LEVELS_TO_LOCK_FROM_DEPTH(depth
);
64 SVN_ERR(svn_wc_adm_open_anchor(&adm_access
, &target_access
, &target
, path
,
66 ctx
->cancel_func
, ctx
->cancel_baton
,
69 err
= svn_wc_revert3(path
, adm_access
, depth
, use_commit_times
,
70 ctx
->cancel_func
, ctx
->cancel_baton
,
71 ctx
->notify_func2
, ctx
->notify_baton2
,
76 /* If target isn't versioned, just send a 'skip'
77 notification and move on. */
78 if (err
->apr_err
== SVN_ERR_ENTRY_NOT_FOUND
79 || err
->apr_err
== SVN_ERR_UNVERSIONED_RESOURCE
)
81 if (ctx
->notify_func2
)
84 svn_wc_create_notify(path
, svn_wc_notify_skip
, pool
),
92 SVN_ERR(svn_wc_adm_close(adm_access
));
99 svn_client_revert2(const apr_array_header_t
*paths
,
101 svn_client_ctx_t
*ctx
,
105 svn_error_t
*err
= SVN_NO_ERROR
;
108 svn_boolean_t use_commit_times
;
110 cfg
= ctx
->config
? apr_hash_get(ctx
->config
, SVN_CONFIG_CATEGORY_CONFIG
,
111 APR_HASH_KEY_STRING
) : NULL
;
113 SVN_ERR(svn_config_get_bool(cfg
, &use_commit_times
,
114 SVN_CONFIG_SECTION_MISCELLANY
,
115 SVN_CONFIG_OPTION_USE_COMMIT_TIMES
,
118 subpool
= svn_pool_create(pool
);
120 for (i
= 0; i
< paths
->nelts
; i
++)
122 const char *path
= APR_ARRAY_IDX(paths
, i
, const char *);
124 svn_pool_clear(subpool
);
126 /* See if we've been asked to cancel this operation. */
127 if ((ctx
->cancel_func
)
128 && ((err
= ctx
->cancel_func(ctx
->cancel_baton
))))
131 err
= revert(path
, depth
, use_commit_times
, ctx
, subpool
);
138 svn_pool_destroy(subpool
);
140 /* Sleep to ensure timestamp integrity. */
141 svn_sleep_for_timestamps();
148 svn_client_revert(const apr_array_header_t
*paths
,
149 svn_boolean_t recursive
,
150 svn_client_ctx_t
*ctx
,
153 return svn_client_revert2(paths
,
154 recursive
? svn_depth_infinity
: svn_depth_empty
,