]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/libsvn_wc/conflicts.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / libsvn_wc / conflicts.h
1 /*
2  * conflicts.h: declarations related to conflicts
3  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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
20  *    under the License.
21  * ====================================================================
22  */
23
24 #ifndef SVN_WC_CONFLICTS_H
25 #define SVN_WC_CONFLICTS_H
26
27 #include <apr_pools.h>
28
29 #include "svn_types.h"
30 #include "svn_wc.h"
31
32 #include "wc_db.h"
33 #include "private/svn_skel.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39
40
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"
45
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"
51
52 #define SVN_WC__CONFLICT_SRC_SUBVERSION "subversion"
53
54 /* Return a new conflict skel, allocated in RESULT_POOL.
55
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_*().
58
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.
62 */
63 svn_skel_t *
64 svn_wc__conflict_skel_create(apr_pool_t *result_pool);
65
66 /* Return a boolean in *COMPLETE indicating whether CONFLICT_SKEL contains
67    everything needed for installing in the working copy database.
68
69    This typically checks if CONFLICT_SKEL contains at least one conflict
70    and an operation.
71  */
72 svn_error_t *
73 svn_wc__conflict_skel_is_complete(svn_boolean_t *complete,
74                                   const svn_skel_t *conflict_skel);
75
76
77 /* Set 'update' as the conflicting operation in CONFLICT_SKEL.
78    Allocate data stored in the skel in RESULT_POOL.
79
80    ORIGINAL and TARGET specify the BASE node before and after updating.
81
82    It is an error to set another operation to a conflict skel that
83    already has an operation.
84
85    Do temporary allocations in SCRATCH_POOL. The new skel data is
86    completely stored in RESULT-POOL. */
87 svn_error_t *
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);
93
94
95 /* Set 'switch' as the conflicting operation in CONFLICT_SKEL.
96    Allocate data stored in the skel in RESULT_POOL.
97
98    ORIGINAL and TARGET specify the BASE node before and after switching.
99
100    It is an error to set another operation to a conflict skel that
101    already has an operation.
102
103    Do temporary allocations in SCRATCH_POOL. */
104 svn_error_t *
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);
110
111
112 /* Set 'merge' as conflicting operation in CONFLICT_SKEL.
113    Allocate data stored in the skel in RESULT_POOL.
114
115    LEFT and RIGHT paths are the merge-left and merge-right merge
116    sources of the merge.
117
118    It is an error to set another operation to a conflict skel that
119    already has an operation.
120
121    Do temporary allocations in SCRATCH_POOL. */
122 svn_error_t *
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);
128
129
130 /* Add a text conflict to CONFLICT_SKEL.
131    Allocate data stored in the skel in RESULT_POOL.
132
133    The DB, WRI_ABSPATH pair specifies in which working copy the conflict
134    will be recorded. (Needed for making the paths relative).
135
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.
139
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.
143
144    It is an error to add another text conflict to a conflict skel that
145    already contains a text conflict.
146
147    Do temporary allocations in SCRATCH_POOL.
148 */
149 svn_error_t *
150 svn_wc__conflict_skel_add_text_conflict(svn_skel_t *conflict_skel,
151                                         svn_wc__db_t *db,
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);
158
159
160 /* Add property conflict details to CONFLICT_SKEL.
161    Allocate data stored in the skel in RESULT_POOL.
162
163    The DB, WRI_ABSPATH pair specifies in which working copy the conflict
164    will be recorded. (Needed for making the paths relative).
165
166    The MARKER_ABSPATH is NULL when raising a conflict in v1.8+.  See below.
167
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.
170
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
173    property values.
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.
178
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.
183
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.)
187
188    Do temporary allocations in SCRATCH_POOL.
189 */
190 svn_error_t *
191 svn_wc__conflict_skel_add_prop_conflict(svn_skel_t *conflict_skel,
192                                         svn_wc__db_t *db,
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);
201
202
203 /* Add a tree conflict to CONFLICT_SKEL.
204    Allocate data stored in the skel in RESULT_POOL.
205
206    LOCAL_CHANGE is the local tree change made to the node.
207    INCOMING_CHANGE is the incoming change made to the node.
208
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:
215        A/B/C moved away (1)
216        A deleted and replaced
217        A/B/C moved away (2)
218        A/B deleted
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
221    associated with (2).
222
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.)
226
227    Do temporary allocations in SCRATCH_POOL.
228 */
229 svn_error_t *
230 svn_wc__conflict_skel_add_tree_conflict(svn_skel_t *conflict_skel,
231                                         svn_wc__db_t *db,
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);
238
239 /* Allows resolving specific conflicts stored in CONFLICT_SKEL.
240
241    When RESOLVE_TEXT is TRUE and CONFLICT_SKEL contains a text conflict,
242    resolve/remove the text conflict in CONFLICT_SKEL.
243
244    When RESOLVE_PROP is "" and CONFLICT_SKEL contains a property conflict,
245    resolve/remove all property conflicts in CONFLICT_SKEL.
246
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
250    CONFLICT_SKEL.
251
252    When RESOLVE_TREE is TRUE and CONFLICT_SKEL contains a tree conflict,
253    resolve/remove the tree conflict in CONFLICT_SKEL.
254
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,
257    otherwise to FALSE.
258
259    Allocate data stored in the skel in RESULT_POOL.
260
261    This functions edits CONFLICT_SKEL. New skels might be created in
262    RESULT_POOL. Temporary allocations will use SCRATCH_POOL.
263  */
264 /* ### db, wri_abspath is currently unused. Remove? */
265 svn_error_t *
266 svn_wc__conflict_skel_resolve(svn_boolean_t *completely_resolved,
267                               svn_skel_t *conflict_skel,
268                               svn_wc__db_t *db,
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);
275
276 /*
277  * -----------------------------------------------------------
278  * Reading conflict skels. Maybe this can be made private later
279  * -----------------------------------------------------------
280  */
281
282 /* Read common information from CONFLICT_SKEL to determine the operation
283  * and merge origins.
284  *
285  * Output arguments can be NULL if the value is not necessary.
286  *
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.
290  *
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.
293  *
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
296  * to false.
297  *
298  * Allocate the result in RESULT_POOL. Perform temporary allocations in
299  * SCRATCH_POOL.
300  */
301 svn_error_t *
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,
307                            svn_wc__db_t *db,
308                            const char *wri_abspath,
309                            const svn_skel_t *conflict_skel,
310                            apr_pool_t *result_pool,
311                            apr_pool_t *scratch_pool);
312
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.
315  *
316  * Values as documented for svn_wc__conflict_skel_add_text_conflict().
317  *
318  * Output arguments can be NULL if the value is not necessary.
319  *
320  * Allocate the result in RESULT_POOL. Perform temporary allocations in
321  * SCRATCH_POOL.
322  */
323 svn_error_t *
324 svn_wc__conflict_read_text_conflict(const char **mine_abspath,
325                                     const char **their_old_abspath,
326                                     const char **their_abspath,
327                                     svn_wc__db_t *db,
328                                     const char *wri_abspath,
329                                     const svn_skel_t *conflict_skel,
330                                     apr_pool_t *result_pool,
331                                     apr_pool_t *scratch_pool);
332
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.
335  *
336  * Values as documented for svn_wc__conflict_skel_add_prop_conflict().
337  *
338  * Output arguments can be NULL if the value is not necessary
339  * Allocate the result in RESULT_POOL. Perform temporary allocations in
340  * SCRATCH_POOL.
341  */
342 svn_error_t *
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,
348                                     svn_wc__db_t *db,
349                                     const char *wri_abspath,
350                                     const svn_skel_t *conflict_skel,
351                                     apr_pool_t *result_pool,
352                                     apr_pool_t *scratch_pool);
353
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.
356  *
357  * Values as documented for svn_wc__conflict_skel_add_tree_conflict().
358  *
359  * Output arguments can be NULL if the value is not necessary
360  * Allocate the result in RESULT_POOL. Perform temporary allocations in
361  * SCRATCH_POOL.
362  */
363 svn_error_t *
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,
367                                     svn_wc__db_t *db,
368                                     const char *wri_abspath,
369                                     const svn_skel_t *conflict_skel,
370                                     apr_pool_t *result_pool,
371                                     apr_pool_t *scratch_pool);
372
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
376  * SCRATCH_POOL.
377  */
378 svn_error_t *
379 svn_wc__conflict_read_markers(const apr_array_header_t **markers,
380                               svn_wc__db_t *db,
381                               const char *wri_abspath,
382                               const svn_skel_t *conflict_skel,
383                               apr_pool_t *result_pool,
384                               apr_pool_t *scratch_pool);
385
386 /* Create the necessary marker files for the conflicts stored in
387  * CONFLICT_SKEL and return the work items to fill the markers from
388  * the work queue.
389  *
390  * Currently only used for property conflicts as text conflict markers
391  * are just in-wc files.
392  *
393  * Allocate the result in RESULT_POOL. Perform temporary allocations in
394  * SCRATCH_POOL.
395  */
396 svn_error_t *
397 svn_wc__conflict_create_markers(svn_skel_t **work_item,
398                                 svn_wc__db_t *db,
399                                 const char *local_abspath,
400                                 svn_skel_t *conflict_skel,
401                                 apr_pool_t *result_pool,
402                                 apr_pool_t *scratch_pool);
403
404 /* Call the interactive conflict resolver RESOLVER_FUNC with RESOLVER_BATON to
405    allow resolving the conflicts on LOCAL_ABSPATH.
406
407    Call RESOLVER_FUNC once for each property conflict, and again for any
408    text conflict, and again for any tree conflict on the node.
409
410    CONFLICT_SKEL contains the details of the conflicts on LOCAL_ABSPATH.
411
412    Resolver actions are directly applied to the in-db state of LOCAL_ABSPATH,
413    so the conflict and the state in CONFLICT_SKEL must already be installed in
414    wc.db. */
415 svn_error_t *
416 svn_wc__conflict_invoke_resolver(svn_wc__db_t *db,
417                                  const char *local_abspath,
418                                  const svn_skel_t *conflict_skel,
419                                  const apr_array_header_t *merge_options,
420                                  svn_wc_conflict_resolver_func2_t resolver_func,
421                                  void *resolver_baton,
422                                  svn_cancel_func_t cancel_func,
423                                  void *cancel_baton,
424                                  apr_pool_t *scratch_pool);
425
426
427 /* Mark as resolved any text conflict on the node at DB/LOCAL_ABSPATH.  */
428 svn_error_t *
429 svn_wc__mark_resolved_text_conflict(svn_wc__db_t *db,
430                                     const char *local_abspath,
431                                     apr_pool_t *scratch_pool);
432
433 /* Mark as resolved any prop conflicts on the node at DB/LOCAL_ABSPATH.  */
434 svn_error_t *
435 svn_wc__mark_resolved_prop_conflicts(svn_wc__db_t *db,
436                                      const char *local_abspath,
437                                      apr_pool_t *scratch_pool);
438
439 #ifdef __cplusplus
440 }
441 #endif /* __cplusplus */
442
443 #endif /* SVN_WC_CONFLICTS_H */