diff options
Diffstat (limited to 'subversion/libsvn_client/resolved.c')
-rw-r--r-- | subversion/libsvn_client/resolved.c | 99 |
1 files changed, 89 insertions, 10 deletions
diff --git a/subversion/libsvn_client/resolved.c b/subversion/libsvn_client/resolved.c index f9e2d9e..0496371 100644 --- a/subversion/libsvn_client/resolved.c +++ b/subversion/libsvn_client/resolved.c @@ -27,12 +27,17 @@ /*** Includes. ***/ +#include <stdlib.h> + #include "svn_types.h" #include "svn_wc.h" #include "svn_client.h" #include "svn_error.h" #include "svn_dirent_uri.h" #include "svn_path.h" +#include "svn_pools.h" +#include "svn_hash.h" +#include "svn_sorts.h" #include "client.h" #include "private/svn_wc_private.h" @@ -41,6 +46,66 @@ /*** Code. ***/ svn_error_t * +svn_client__resolve_conflicts(svn_boolean_t *conflicts_remain, + apr_hash_t *conflicted_paths, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool) +{ + apr_pool_t *iterpool = svn_pool_create(scratch_pool); + apr_array_header_t *array; + int i; + + if (conflicts_remain) + *conflicts_remain = FALSE; + + SVN_ERR(svn_hash_keys(&array, conflicted_paths, scratch_pool)); + qsort(array->elts, array->nelts, array->elt_size, + svn_sort_compare_paths); + + for (i = 0; i < array->nelts; i++) + { + const char *local_abspath = APR_ARRAY_IDX(array, i, const char *); + + svn_pool_clear(iterpool); + SVN_ERR(svn_wc__resolve_conflicts(ctx->wc_ctx, local_abspath, + svn_depth_empty, + TRUE /* resolve_text */, + "" /* resolve_prop (ALL props) */, + TRUE /* resolve_tree */, + svn_wc_conflict_choose_unspecified, + ctx->conflict_func2, + ctx->conflict_baton2, + ctx->cancel_func, ctx->cancel_baton, + ctx->notify_func2, ctx->notify_baton2, + iterpool)); + + if (conflicts_remain) + { + svn_error_t *err; + svn_boolean_t text_c, prop_c, tree_c; + + err = svn_wc_conflicted_p3(&text_c, &prop_c, &tree_c, + ctx->wc_ctx, local_abspath, + iterpool); + if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND) + { + svn_error_clear(err); + text_c = prop_c = tree_c = FALSE; + } + else + { + SVN_ERR(err); + } + if (text_c || prop_c || tree_c) + *conflicts_remain = TRUE; + } + } + svn_pool_destroy(iterpool); + + return SVN_NO_ERROR; +} + +svn_error_t * svn_client_resolve(const char *path, svn_depth_t depth, svn_wc_conflict_choice_t conflict_choice, @@ -48,6 +113,8 @@ svn_client_resolve(const char *path, apr_pool_t *pool) { const char *local_abspath; + svn_error_t *err; + const char *lock_abspath; if (svn_path_is_url(path)) return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL, @@ -55,15 +122,27 @@ svn_client_resolve(const char *path, SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool)); - SVN_ERR(svn_wc_resolved_conflict5(ctx->wc_ctx, local_abspath, - depth, - TRUE /* resolve_text */, - "" /* resolve_prop (ALL props) */, - TRUE /* resolve_tree */, - conflict_choice, - ctx->cancel_func, ctx->cancel_baton, - ctx->notify_func2, ctx->notify_baton2, - pool)); + /* Similar to SVN_WC__CALL_WITH_WRITE_LOCK but using a custom + locking function. */ - return SVN_NO_ERROR; + SVN_ERR(svn_wc__acquire_write_lock_for_resolve(&lock_abspath, ctx->wc_ctx, + local_abspath, pool, pool)); + err = svn_wc__resolve_conflicts(ctx->wc_ctx, local_abspath, + depth, + TRUE /* resolve_text */, + "" /* resolve_prop (ALL props) */, + TRUE /* resolve_tree */, + conflict_choice, + ctx->conflict_func2, + ctx->conflict_baton2, + ctx->cancel_func, ctx->cancel_baton, + ctx->notify_func2, ctx->notify_baton2, + pool); + + err = svn_error_compose_create(err, svn_wc__release_write_lock(ctx->wc_ctx, + lock_abspath, + pool)); + svn_io_sleep_for_timestamps(path, pool); + + return svn_error_trace(err); } |