2 * conflicts.h: declarations related to conflicts
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 #ifndef SVN_WC_CONFLICTS_H
25 #define SVN_WC_CONFLICTS_H
27 #include <apr_pools.h>
29 #include "svn_types.h"
33 #include "private/svn_skel.h"
37 #endif /* __cplusplus */
41 #define SVN_WC__CONFLICT_OP_UPDATE "update"
42 #define SVN_WC__CONFLICT_OP_SWITCH "switch"
43 #define SVN_WC__CONFLICT_OP_MERGE "merge"
44 #define SVN_WC__CONFLICT_OP_PATCH "patch"
46 #define SVN_WC__CONFLICT_KIND_TEXT "text"
47 #define SVN_WC__CONFLICT_KIND_PROP "prop"
48 #define SVN_WC__CONFLICT_KIND_TREE "tree"
49 #define SVN_WC__CONFLICT_KIND_REJECT "reject"
50 #define SVN_WC__CONFLICT_KIND_OBSTRUCTED "obstructed"
52 #define SVN_WC__CONFLICT_SRC_SUBVERSION "subversion"
54 /* Return a new conflict skel, allocated in RESULT_POOL.
56 Typically creating a conflict starts with calling this function and then
57 collecting details via one or more calls to svn_wc__conflict_skel_add_*().
59 The caller can then (when necessary) add operation details via
60 svn_wc__conflict_skel_set_op_*() and store the resulting conflict together
61 with the result of its operation in the working copy database.
64 svn_wc__conflict_skel_create(apr_pool_t *result_pool);
66 /* Return a boolean in *COMPLETE indicating whether CONFLICT_SKEL contains
67 everything needed for installing in the working copy database.
69 This typically checks if CONFLICT_SKEL contains at least one conflict
73 svn_wc__conflict_skel_is_complete(svn_boolean_t *complete,
74 const svn_skel_t *conflict_skel);
77 /* Set 'update' as the conflicting operation in CONFLICT_SKEL.
78 Allocate data stored in the skel in RESULT_POOL.
80 ORIGINAL and TARGET specify the BASE node before and after updating.
82 It is an error to set another operation to a conflict skel that
83 already has an operation.
85 Do temporary allocations in SCRATCH_POOL. The new skel data is
86 completely stored in RESULT-POOL. */
88 svn_wc__conflict_skel_set_op_update(svn_skel_t *conflict_skel,
89 const svn_wc_conflict_version_t *original,
90 const svn_wc_conflict_version_t *target,
91 apr_pool_t *result_pool,
92 apr_pool_t *scratch_pool);
95 /* Set 'switch' as the conflicting operation in CONFLICT_SKEL.
96 Allocate data stored in the skel in RESULT_POOL.
98 ORIGINAL and TARGET specify the BASE node before and after switching.
100 It is an error to set another operation to a conflict skel that
101 already has an operation.
103 Do temporary allocations in SCRATCH_POOL. */
105 svn_wc__conflict_skel_set_op_switch(svn_skel_t *conflict_skel,
106 const svn_wc_conflict_version_t *original,
107 const svn_wc_conflict_version_t *target,
108 apr_pool_t *result_pool,
109 apr_pool_t *scratch_pool);
112 /* Set 'merge' as conflicting operation in CONFLICT_SKEL.
113 Allocate data stored in the skel in RESULT_POOL.
115 LEFT and RIGHT paths are the merge-left and merge-right merge
116 sources of the merge.
118 It is an error to set another operation to a conflict skel that
119 already has an operation.
121 Do temporary allocations in SCRATCH_POOL. */
123 svn_wc__conflict_skel_set_op_merge(svn_skel_t *conflict_skel,
124 const svn_wc_conflict_version_t *left,
125 const svn_wc_conflict_version_t *right,
126 apr_pool_t *result_pool,
127 apr_pool_t *scratch_pool);
130 /* Add a text conflict to CONFLICT_SKEL.
131 Allocate data stored in the skel in RESULT_POOL.
133 The DB, WRI_ABSPATH pair specifies in which working copy the conflict
134 will be recorded. (Needed for making the paths relative).
136 MINE_ABSPATH, THEIR_OLD_ABSPATH and THEIR_ABSPATH specify the marker
137 files for this text conflict. Each of these values can be NULL to specify
138 that the node doesn't exist in this case.
140 ### It is expected that in a future version we will also want to store
141 ### the sha1 checksum of these files to allow reinstalling the conflict
142 ### markers from the pristine store.
144 It is an error to add another text conflict to a conflict skel that
145 already contains a text conflict.
147 Do temporary allocations in SCRATCH_POOL.
150 svn_wc__conflict_skel_add_text_conflict(svn_skel_t *conflict_skel,
152 const char *wri_abspath,
153 const char *mine_abspath,
154 const char *their_old_abspath,
155 const char *their_abspath,
156 apr_pool_t *result_pool,
157 apr_pool_t *scratch_pool);
160 /* Add property conflict details to CONFLICT_SKEL.
161 Allocate data stored in the skel in RESULT_POOL.
163 The DB, WRI_ABSPATH pair specifies in which working copy the conflict
164 will be recorded. (Needed for making the paths relative).
166 The MARKER_ABSPATH is NULL when raising a conflict in v1.8+. See below.
168 The MINE_PROPS, THEIR_OLD_PROPS and THEIR_PROPS are hashes mapping a
169 const char * property name to a const svn_string_t* value.
171 The CONFLICTED_PROP_NAMES is a const char * property name value mapping
172 to "", recording which properties aren't resolved yet in the current
174 ### Needed for creating the marker file from this conflict data.
175 ### Would also allow per property marking as resolved.
176 ### Maybe useful for calling (legacy) conflict resolvers that expect one
177 ### property conflict per invocation.
179 When raising a property conflict in the course of upgrading an old WC,
180 MARKER_ABSPATH is the path to the file containing a human-readable
181 description of the conflict, MINE_PROPS and THEIR_OLD_PROPS and
182 THEIR_PROPS are all NULL, and CONFLICTED_PROP_NAMES is an empty hash.
184 It is an error to add another prop conflict to a conflict skel that
185 already contains a prop conflict. (A single call to this function can
186 record that multiple properties are in conflict.)
188 Do temporary allocations in SCRATCH_POOL.
191 svn_wc__conflict_skel_add_prop_conflict(svn_skel_t *conflict_skel,
193 const char *wri_abspath,
194 const char *marker_abspath,
195 const apr_hash_t *mine_props,
196 const apr_hash_t *their_old_props,
197 const apr_hash_t *their_props,
198 const apr_hash_t *conflicted_prop_names,
199 apr_pool_t *result_pool,
200 apr_pool_t *scratch_pool);
203 /* Add a tree conflict to CONFLICT_SKEL.
204 Allocate data stored in the skel in RESULT_POOL.
206 LOCAL_CHANGE is the local tree change made to the node.
207 INCOMING_CHANGE is the incoming change made to the node.
209 MOVE_SRC_OP_ROOT_ABSPATH must be set when LOCAL_CHANGE is
210 svn_wc_conflict_reason_moved_away and NULL otherwise and the operation
211 is svn_wc_operation_update or svn_wc_operation_switch. It should be
212 set to the op-root of the move-away unless the move is inside a
213 delete in which case it should be set to the op-root of the delete
214 (the delete can be a replace). So given:
216 A deleted and replaced
219 MOVE_SRC_OP_ROOT_ABSPATH should be A for a conflict associated
220 with (1), MOVE_SRC_OP_ROOT_ABSPATH should be A/B for a conflict
223 It is an error to add another tree conflict to a conflict skel that
224 already contains a tree conflict. (It is not an error, at this level,
225 to add a tree conflict to an existing text or property conflict skel.)
227 Do temporary allocations in SCRATCH_POOL.
230 svn_wc__conflict_skel_add_tree_conflict(svn_skel_t *conflict_skel,
232 const char *wri_abspath,
233 svn_wc_conflict_reason_t local_change,
234 svn_wc_conflict_action_t incoming_change,
235 const char *move_src_op_root_abspath,
236 apr_pool_t *result_pool,
237 apr_pool_t *scratch_pool);
239 /* Allows resolving specific conflicts stored in CONFLICT_SKEL.
241 When RESOLVE_TEXT is TRUE and CONFLICT_SKEL contains a text conflict,
242 resolve/remove the text conflict in CONFLICT_SKEL.
244 When RESOLVE_PROP is "" and CONFLICT_SKEL contains a property conflict,
245 resolve/remove all property conflicts in CONFLICT_SKEL.
247 When RESOLVE_PROP is not NULL and not "", remove the property conflict on
248 the property RESOLVE_PROP in CONFLICT_SKEL. When RESOLVE_PROP was the last
249 property in CONFLICT_SKEL remove the property conflict info from
252 When RESOLVE_TREE is TRUE and CONFLICT_SKEL contains a tree conflict,
253 resolve/remove the tree conflict in CONFLICT_SKEL.
255 If COMPLETELY_RESOLVED is not NULL, then set *COMPLETELY_RESOLVED to TRUE,
256 when no conflict registration is left in CONFLICT_SKEL after editting,
259 Allocate data stored in the skel in RESULT_POOL.
261 This functions edits CONFLICT_SKEL. New skels might be created in
262 RESULT_POOL. Temporary allocations will use SCRATCH_POOL.
264 /* ### db, wri_abspath is currently unused. Remove? */
266 svn_wc__conflict_skel_resolve(svn_boolean_t *completely_resolved,
267 svn_skel_t *conflict_skel,
269 const char *wri_abspath,
270 svn_boolean_t resolve_text,
271 const char *resolve_prop,
272 svn_boolean_t resolve_tree,
273 apr_pool_t *result_pool,
274 apr_pool_t *scratch_pool);
277 * -----------------------------------------------------------
278 * Reading conflict skels. Maybe this can be made private later
279 * -----------------------------------------------------------
282 /* Read common information from CONFLICT_SKEL to determine the operation
285 * Output arguments can be NULL if the value is not necessary.
287 * Set *LOCATIONS to an array of (svn_wc_conflict_version_t *). For
288 * conflicts written by current code, there are 2 elements: index [0] is
289 * the 'old' or 'left' side and [1] is the 'new' or 'right' side.
291 * For conflicts written by 1.6 or 1.7 there are 2 locations for a tree
292 * conflict, but none for a text or property conflict.
294 * TEXT_, PROP_ and TREE_CONFLICTED (when not NULL) will be set to TRUE
295 * when the conflict contains the specified kind of conflict, otherwise
298 * Allocate the result in RESULT_POOL. Perform temporary allocations in
302 svn_wc__conflict_read_info(svn_wc_operation_t *operation,
303 const apr_array_header_t **locations,
304 svn_boolean_t *text_conflicted,
305 svn_boolean_t *prop_conflicted,
306 svn_boolean_t *tree_conflicted,
308 const char *wri_abspath,
309 const svn_skel_t *conflict_skel,
310 apr_pool_t *result_pool,
311 apr_pool_t *scratch_pool);
313 /* Reads back the original data stored by svn_wc__conflict_skel_add_text_conflict()
314 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH.
316 * Values as documented for svn_wc__conflict_skel_add_text_conflict().
318 * Output arguments can be NULL if the value is not necessary.
320 * Allocate the result in RESULT_POOL. Perform temporary allocations in
324 svn_wc__conflict_read_text_conflict(const char **mine_abspath,
325 const char **their_old_abspath,
326 const char **their_abspath,
328 const char *wri_abspath,
329 const svn_skel_t *conflict_skel,
330 apr_pool_t *result_pool,
331 apr_pool_t *scratch_pool);
333 /* Reads back the original data stored by svn_wc__conflict_skel_add_prop_conflict()
334 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH.
336 * Values as documented for svn_wc__conflict_skel_add_prop_conflict().
338 * Output arguments can be NULL if the value is not necessary
339 * Allocate the result in RESULT_POOL. Perform temporary allocations in
343 svn_wc__conflict_read_prop_conflict(const char **marker_abspath,
344 apr_hash_t **mine_props,
345 apr_hash_t **their_old_props,
346 apr_hash_t **their_props,
347 apr_hash_t **conflicted_prop_names,
349 const char *wri_abspath,
350 const svn_skel_t *conflict_skel,
351 apr_pool_t *result_pool,
352 apr_pool_t *scratch_pool);
354 /* Reads back the original data stored by svn_wc__conflict_skel_add_tree_conflict()
355 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH.
357 * Values as documented for svn_wc__conflict_skel_add_tree_conflict().
359 * Output arguments can be NULL if the value is not necessary
360 * Allocate the result in RESULT_POOL. Perform temporary allocations in
364 svn_wc__conflict_read_tree_conflict(svn_wc_conflict_reason_t *local_change,
365 svn_wc_conflict_action_t *incoming_change,
366 const char **move_src_op_root_abspath,
368 const char *wri_abspath,
369 const svn_skel_t *conflict_skel,
370 apr_pool_t *result_pool,
371 apr_pool_t *scratch_pool);
373 /* Reads in *MARKERS a list of const char * absolute paths of the marker files
374 referenced from CONFLICT_SKEL.
375 * Allocate the result in RESULT_POOL. Perform temporary allocations in
379 svn_wc__conflict_read_markers(const apr_array_header_t **markers,
381 const char *wri_abspath,
382 const svn_skel_t *conflict_skel,
383 apr_pool_t *result_pool,
384 apr_pool_t *scratch_pool);
386 /* Create the necessary marker files for the conflicts stored in
387 * CONFLICT_SKEL and return the work items to fill the markers from
390 * Currently only used for property conflicts as text conflict markers
391 * are just in-wc files.
393 * Allocate the result in RESULT_POOL. Perform temporary allocations in
397 svn_wc__conflict_create_markers(svn_skel_t **work_item,
399 const char *local_abspath,
400 svn_skel_t *conflict_skel,
401 apr_pool_t *result_pool,
402 apr_pool_t *scratch_pool);
404 /* Call the conflict resolver RESOLVER_FUNC with RESOLVER_BATON for each
405 of the conflicts on LOCAL_ABSPATH. Depending on the results that
406 the callback returns, perhaps resolve the conflicts, and perhaps mark
407 them as resolved in the WC DB.
409 Call RESOLVER_FUNC once for each property conflict, and again for any
410 text conflict, and again for any tree conflict on the node.
412 CONFLICT_SKEL contains the details of the conflicts on LOCAL_ABSPATH.
414 Use MERGE_OPTIONS when the resolver requests a merge.
416 Resolver actions are directly applied to the in-db state of LOCAL_ABSPATH,
417 so the conflict and the state in CONFLICT_SKEL must already be installed in
420 svn_wc__conflict_invoke_resolver(svn_wc__db_t *db,
421 const char *local_abspath,
422 svn_node_kind_t kind,
423 const svn_skel_t *conflict_skel,
424 const apr_array_header_t *merge_options,
425 svn_wc_conflict_resolver_func2_t resolver_func,
426 void *resolver_baton,
427 svn_cancel_func_t cancel_func,
429 apr_pool_t *scratch_pool);
432 /* Mark as resolved any text conflict on the node at DB/LOCAL_ABSPATH. */
434 svn_wc__mark_resolved_text_conflict(svn_wc__db_t *db,
435 const char *local_abspath,
436 svn_cancel_func_t cancel_func,
438 apr_pool_t *scratch_pool);
440 /* Mark as resolved any prop conflicts on the node at DB/LOCAL_ABSPATH. */
442 svn_wc__mark_resolved_prop_conflicts(svn_wc__db_t *db,
443 const char *local_abspath,
444 apr_pool_t *scratch_pool);
448 #endif /* __cplusplus */
450 #endif /* SVN_WC_CONFLICTS_H */