2 * resolved.c: wrapper around Subversion <=1.9 wc resolved functionality
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
24 /* ==================================================================== */
30 #include "svn_types.h"
32 #include "svn_client.h"
33 #include "svn_error.h"
34 #include "svn_dirent_uri.h"
36 #include "svn_pools.h"
38 #include "svn_sorts.h"
40 #include "private/svn_sorts_private.h"
41 #include "private/svn_wc_private.h"
43 #include "svn_private_config.h"
49 svn_client__resolve_conflicts(svn_boolean_t
*conflicts_remain
,
50 apr_hash_t
*conflicted_paths
,
51 svn_client_ctx_t
*ctx
,
52 apr_pool_t
*scratch_pool
)
54 apr_pool_t
*iterpool
= svn_pool_create(scratch_pool
);
55 apr_array_header_t
*array
;
59 *conflicts_remain
= FALSE
;
61 SVN_ERR(svn_hash_keys(&array
, conflicted_paths
, scratch_pool
));
62 svn_sort__array(array
, svn_sort_compare_paths
);
64 for (i
= 0; i
< array
->nelts
; i
++)
66 const char *local_abspath
= APR_ARRAY_IDX(array
, i
, const char *);
68 svn_pool_clear(iterpool
);
69 SVN_ERR(svn_wc__resolve_conflicts(ctx
->wc_ctx
, local_abspath
,
71 TRUE
/* resolve_text */,
72 "" /* resolve_prop (ALL props) */,
73 TRUE
/* resolve_tree */,
74 svn_wc_conflict_choose_unspecified
,
77 ctx
->cancel_func
, ctx
->cancel_baton
,
78 ctx
->notify_func2
, ctx
->notify_baton2
,
81 if (conflicts_remain
&& !*conflicts_remain
)
84 svn_boolean_t text_c
, prop_c
, tree_c
;
86 err
= svn_wc_conflicted_p3(&text_c
, &prop_c
, &tree_c
,
87 ctx
->wc_ctx
, local_abspath
,
89 if (err
&& err
->apr_err
== SVN_ERR_WC_PATH_NOT_FOUND
)
92 text_c
= prop_c
= tree_c
= FALSE
;
98 if (text_c
|| prop_c
|| tree_c
)
99 *conflicts_remain
= TRUE
;
102 svn_pool_destroy(iterpool
);
108 svn_client_resolve(const char *path
,
110 svn_wc_conflict_choice_t conflict_choice
,
111 svn_client_ctx_t
*ctx
,
114 const char *local_abspath
;
116 const char *lock_abspath
;
118 if (svn_path_is_url(path
))
119 return svn_error_createf(SVN_ERR_ILLEGAL_TARGET
, NULL
,
120 _("'%s' is not a local path"), path
);
122 SVN_ERR(svn_dirent_get_absolute(&local_abspath
, path
, pool
));
124 /* Similar to SVN_WC__CALL_WITH_WRITE_LOCK but using a custom
127 SVN_ERR(svn_wc__acquire_write_lock_for_resolve(&lock_abspath
, ctx
->wc_ctx
,
128 local_abspath
, pool
, pool
));
129 err
= svn_wc__resolve_conflicts(ctx
->wc_ctx
, local_abspath
,
131 TRUE
/* resolve_text */,
132 "" /* resolve_prop (ALL props) */,
133 TRUE
/* resolve_tree */,
136 ctx
->conflict_baton2
,
137 ctx
->cancel_func
, ctx
->cancel_baton
,
138 ctx
->notify_func2
, ctx
->notify_baton2
,
141 err
= svn_error_compose_create(err
, svn_wc__release_write_lock(ctx
->wc_ctx
,
144 svn_io_sleep_for_timestamps(path
, pool
);
146 return svn_error_trace(err
);