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"
37
/* Attempt to revert PATH, recursively if RECURSIVE is true and PATH
38
is a directory, else non-recursively. Consult CTX to determine
39
whether or not to revert timestamp to the time of last commit
40
('use-commit-times = yes'). Use POOL for temporary allocation.
42
If PATH is unversioned, return SVN_ERR_UNVERSIONED_RESOURCE. */
44
revert (const char *path,
45
svn_boolean_t recursive,
46
svn_client_ctx_t *ctx,
49
svn_wc_adm_access_t *adm_access, *target_access;
50
svn_boolean_t use_commit_times;
55
cfg = ctx->config ? apr_hash_get (ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
56
APR_HASH_KEY_STRING) : NULL;
58
SVN_ERR (svn_config_get_bool (cfg, &use_commit_times,
59
SVN_CONFIG_SECTION_MISCELLANY,
60
SVN_CONFIG_OPTION_USE_COMMIT_TIMES,
63
SVN_ERR (svn_wc_adm_open_anchor (&adm_access, &target_access, &target, path,
64
TRUE, recursive ? -1 : 0,
65
ctx->cancel_func, ctx->cancel_baton,
68
err = svn_wc_revert2 (path, adm_access, recursive, use_commit_times,
69
ctx->cancel_func, ctx->cancel_baton,
70
ctx->notify_func2, ctx->notify_baton2,
73
/* If no error, or SVN_ERR_UNVERSIONED_RESOURCE error, then we want
74
to close up before returning. For any other kind of error, we
75
want to leave things exactly as they were when the error
78
if (err && err->apr_err != SVN_ERR_UNVERSIONED_RESOURCE)
81
SVN_ERR (svn_wc_adm_close (adm_access));
88
svn_client_revert (const apr_array_header_t *paths,
89
svn_boolean_t recursive,
90
svn_client_ctx_t *ctx,
93
apr_pool_t *subpool = svn_pool_create (pool);
94
svn_error_t *err = SVN_NO_ERROR;
97
for (i = 0; i < paths->nelts; i++)
99
const char *path = APR_ARRAY_IDX (paths, i, const char *);
101
svn_pool_clear (subpool);
103
/* See if we've been asked to cancel this operation. */
104
if ((ctx->cancel_func)
105
&& ((err = ctx->cancel_func (ctx->cancel_baton))))
108
err = revert (path, recursive, ctx, subpool);
111
/* If one of the targets isn't versioned, just send a 'skip'
112
notification and move on. */
113
if (err->apr_err == SVN_ERR_ENTRY_NOT_FOUND
114
|| err->apr_err == SVN_ERR_UNVERSIONED_RESOURCE)
116
if (ctx->notify_func2)
119
svn_wc_create_notify (path, svn_wc_notify_skip, subpool),
121
svn_error_clear (err);
132
svn_pool_destroy (subpool);
134
/* Sleep to ensure timestamp integrity. */
135
svn_sleep_for_timestamps ();