summaryrefslogtreecommitdiff
path: root/subversion/libsvn_wc/conflicts.h
blob: 0a9324b89a61821e42cc136f2e9139889a5e2d8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
/*
 * conflicts.h: declarations related to conflicts
 *
 * ====================================================================
 *    Licensed to the Apache Software Foundation (ASF) under one
 *    or more contributor license agreements.  See the NOTICE file
 *    distributed with this work for additional information
 *    regarding copyright ownership.  The ASF licenses this file
 *    to you under the Apache License, Version 2.0 (the
 *    "License"); you may not use this file except in compliance
 *    with the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing,
 *    software distributed under the License is distributed on an
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *    KIND, either express or implied.  See the License for the
 *    specific language governing permissions and limitations
 *    under the License.
 * ====================================================================
 */

#ifndef SVN_WC_CONFLICTS_H
#define SVN_WC_CONFLICTS_H

#include <apr_pools.h>

#include "svn_types.h"
#include "svn_wc.h"

#include "wc_db.h"
#include "private/svn_skel.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */



#define SVN_WC__CONFLICT_OP_UPDATE "update"
#define SVN_WC__CONFLICT_OP_SWITCH "switch"
#define SVN_WC__CONFLICT_OP_MERGE "merge"
#define SVN_WC__CONFLICT_OP_PATCH "patch"

#define SVN_WC__CONFLICT_KIND_TEXT "text"
#define SVN_WC__CONFLICT_KIND_PROP "prop"
#define SVN_WC__CONFLICT_KIND_TREE "tree"
#define SVN_WC__CONFLICT_KIND_REJECT "reject"
#define SVN_WC__CONFLICT_KIND_OBSTRUCTED "obstructed"

#define SVN_WC__CONFLICT_SRC_SUBVERSION "subversion"

/* Return a new conflict skel, allocated in RESULT_POOL.

   Typically creating a conflict starts with calling this function and then
   collecting details via one or more calls to svn_wc__conflict_skel_add_*().

   The caller can then (when necessary) add operation details via
   svn_wc__conflict_skel_set_op_*() and store the resulting conflict together
   with the result of its operation in the working copy database.
*/
svn_skel_t *
svn_wc__conflict_skel_create(apr_pool_t *result_pool);

/* Return a boolean in *COMPLETE indicating whether CONFLICT_SKEL contains
   everything needed for installing in the working copy database.

   This typically checks if CONFLICT_SKEL contains at least one conflict
   and an operation.
 */
svn_error_t *
svn_wc__conflict_skel_is_complete(svn_boolean_t *complete,
                                  const svn_skel_t *conflict_skel);


/* Set 'update' as the conflicting operation in CONFLICT_SKEL.
   Allocate data stored in the skel in RESULT_POOL.

   ORIGINAL and TARGET specify the BASE node before and after updating.

   It is an error to set another operation to a conflict skel that
   already has an operation.

   Do temporary allocations in SCRATCH_POOL. The new skel data is
   completely stored in RESULT-POOL. */
svn_error_t *
svn_wc__conflict_skel_set_op_update(svn_skel_t *conflict_skel,
                                    const svn_wc_conflict_version_t *original,
                                    const svn_wc_conflict_version_t *target,
                                    apr_pool_t *result_pool,
                                    apr_pool_t *scratch_pool);


/* Set 'switch' as the conflicting operation in CONFLICT_SKEL.
   Allocate data stored in the skel in RESULT_POOL.

   ORIGINAL and TARGET specify the BASE node before and after switching.

   It is an error to set another operation to a conflict skel that
   already has an operation.

   Do temporary allocations in SCRATCH_POOL. */
svn_error_t *
svn_wc__conflict_skel_set_op_switch(svn_skel_t *conflict_skel,
                                    const svn_wc_conflict_version_t *original,
                                    const svn_wc_conflict_version_t *target,
                                    apr_pool_t *result_pool,
                                    apr_pool_t *scratch_pool);


/* Set 'merge' as conflicting operation in CONFLICT_SKEL.
   Allocate data stored in the skel in RESULT_POOL.

   LEFT and RIGHT paths are the merge-left and merge-right merge
   sources of the merge.

   It is an error to set another operation to a conflict skel that
   already has an operation.

   Do temporary allocations in SCRATCH_POOL. */
svn_error_t *
svn_wc__conflict_skel_set_op_merge(svn_skel_t *conflict_skel,
                                   const svn_wc_conflict_version_t *left,
                                   const svn_wc_conflict_version_t *right,
                                   apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool);


/* Add a text conflict to CONFLICT_SKEL.
   Allocate data stored in the skel in RESULT_POOL.

   The DB, WRI_ABSPATH pair specifies in which working copy the conflict
   will be recorded. (Needed for making the paths relative).

   MINE_ABSPATH, THEIR_OLD_ABSPATH and THEIR_ABSPATH specify the marker
   files for this text conflict. Each of these values can be NULL to specify
   that the node doesn't exist in this case.

   ### It is expected that in a future version we will also want to store
   ### the sha1 checksum of these files to allow reinstalling the conflict
   ### markers from the pristine store.

   It is an error to add another text conflict to a conflict skel that
   already contains a text conflict.

   Do temporary allocations in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__conflict_skel_add_text_conflict(svn_skel_t *conflict_skel,
                                        svn_wc__db_t *db,
                                        const char *wri_abspath,
                                        const char *mine_abspath,
                                        const char *their_old_abspath,
                                        const char *their_abspath,
                                        apr_pool_t *result_pool,
                                        apr_pool_t *scratch_pool);


/* Add property conflict details to CONFLICT_SKEL.
   Allocate data stored in the skel in RESULT_POOL.

   The DB, WRI_ABSPATH pair specifies in which working copy the conflict
   will be recorded. (Needed for making the paths relative).

   The MARKER_ABSPATH is NULL when raising a conflict in v1.8+.  See below.

   The MINE_PROPS, THEIR_OLD_PROPS and THEIR_PROPS are hashes mapping a
   const char * property name to a const svn_string_t* value.

   The CONFLICTED_PROP_NAMES is a const char * property name value mapping
   to "", recording which properties aren't resolved yet in the current
   property values.
   ### Needed for creating the marker file from this conflict data.
   ### Would also allow per property marking as resolved.
   ### Maybe useful for calling (legacy) conflict resolvers that expect one
   ### property conflict per invocation.

   When raising a property conflict in the course of upgrading an old WC,
   MARKER_ABSPATH is the path to the file containing a human-readable
   description of the conflict, MINE_PROPS and THEIR_OLD_PROPS and
   THEIR_PROPS are all NULL, and CONFLICTED_PROP_NAMES is an empty hash.

   It is an error to add another prop conflict to a conflict skel that
   already contains a prop conflict.  (A single call to this function can
   record that multiple properties are in conflict.)

   Do temporary allocations in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__conflict_skel_add_prop_conflict(svn_skel_t *conflict_skel,
                                        svn_wc__db_t *db,
                                        const char *wri_abspath,
                                        const char *marker_abspath,
                                        const apr_hash_t *mine_props,
                                        const apr_hash_t *their_old_props,
                                        const apr_hash_t *their_props,
                                        const apr_hash_t *conflicted_prop_names,
                                        apr_pool_t *result_pool,
                                        apr_pool_t *scratch_pool);


/* Add a tree conflict to CONFLICT_SKEL.
   Allocate data stored in the skel in RESULT_POOL.

   LOCAL_CHANGE is the local tree change made to the node.
   INCOMING_CHANGE is the incoming change made to the node.

   MOVE_SRC_OP_ROOT_ABSPATH must be set when LOCAL_CHANGE is
   svn_wc_conflict_reason_moved_away and NULL otherwise and the operation
   is svn_wc_operation_update or svn_wc_operation_switch.  It should be
   set to the op-root of the move-away unless the move is inside a
   delete in which case it should be set to the op-root of the delete
   (the delete can be a replace). So given:
       A/B/C moved away (1)
       A deleted and replaced
       A/B/C moved away (2)
       A/B deleted
   MOVE_SRC_OP_ROOT_ABSPATH should be A for a conflict associated
   with (1), MOVE_SRC_OP_ROOT_ABSPATH should be A/B for a conflict
   associated with (2).

   It is an error to add another tree conflict to a conflict skel that
   already contains a tree conflict.  (It is not an error, at this level,
   to add a tree conflict to an existing text or property conflict skel.)

   Do temporary allocations in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__conflict_skel_add_tree_conflict(svn_skel_t *conflict_skel,
                                        svn_wc__db_t *db,
                                        const char *wri_abspath,
                                        svn_wc_conflict_reason_t local_change,
                                        svn_wc_conflict_action_t incoming_change,
                                        const char *move_src_op_root_abspath,
                                        apr_pool_t *result_pool,
                                        apr_pool_t *scratch_pool);

/* Allows resolving specific conflicts stored in CONFLICT_SKEL.

   When RESOLVE_TEXT is TRUE and CONFLICT_SKEL contains a text conflict,
   resolve/remove the text conflict in CONFLICT_SKEL.

   When RESOLVE_PROP is "" and CONFLICT_SKEL contains a property conflict,
   resolve/remove all property conflicts in CONFLICT_SKEL.

   When RESOLVE_PROP is not NULL and not "", remove the property conflict on
   the property RESOLVE_PROP in CONFLICT_SKEL. When RESOLVE_PROP was the last
   property in CONFLICT_SKEL remove the property conflict info from
   CONFLICT_SKEL.

   When RESOLVE_TREE is TRUE and CONFLICT_SKEL contains a tree conflict,
   resolve/remove the tree conflict in CONFLICT_SKEL.

   If COMPLETELY_RESOLVED is not NULL, then set *COMPLETELY_RESOLVED to TRUE,
   when no conflict registration is left in CONFLICT_SKEL after editting,
   otherwise to FALSE.

   Allocate data stored in the skel in RESULT_POOL.

   This functions edits CONFLICT_SKEL. New skels might be created in
   RESULT_POOL. Temporary allocations will use SCRATCH_POOL.
 */
/* ### db, wri_abspath is currently unused. Remove? */
svn_error_t *
svn_wc__conflict_skel_resolve(svn_boolean_t *completely_resolved,
                              svn_skel_t *conflict_skel,
                              svn_wc__db_t *db,
                              const char *wri_abspath,
                              svn_boolean_t resolve_text,
                              const char *resolve_prop,
                              svn_boolean_t resolve_tree,
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool);

/*
 * -----------------------------------------------------------
 * Reading conflict skels. Maybe this can be made private later
 * -----------------------------------------------------------
 */

/* Read common information from CONFLICT_SKEL to determine the operation
 * and merge origins.
 *
 * Output arguments can be NULL if the value is not necessary.
 *
 * Set *LOCATIONS to an array of (svn_wc_conflict_version_t *).  For
 * conflicts written by current code, there are 2 elements: index [0] is
 * the 'old' or 'left' side and [1] is the 'new' or 'right' side.
 *
 * For conflicts written by 1.6 or 1.7 there are 2 locations for a tree
 * conflict, but none for a text or property conflict.
 *
 * TEXT_, PROP_ and TREE_CONFLICTED (when not NULL) will be set to TRUE
 * when the conflict contains the specified kind of conflict, otherwise
 * to false.
 *
 * Allocate the result in RESULT_POOL. Perform temporary allocations in
 * SCRATCH_POOL.
 */
svn_error_t *
svn_wc__conflict_read_info(svn_wc_operation_t *operation,
                           const apr_array_header_t **locations,
                           svn_boolean_t *text_conflicted,
                           svn_boolean_t *prop_conflicted,
                           svn_boolean_t *tree_conflicted,
                           svn_wc__db_t *db,
                           const char *wri_abspath,
                           const svn_skel_t *conflict_skel,
                           apr_pool_t *result_pool,
                           apr_pool_t *scratch_pool);

/* Reads back the original data stored by svn_wc__conflict_skel_add_text_conflict()
 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH.
 *
 * Values as documented for svn_wc__conflict_skel_add_text_conflict().
 *
 * Output arguments can be NULL if the value is not necessary.
 *
 * Allocate the result in RESULT_POOL. Perform temporary allocations in
 * SCRATCH_POOL.
 */
svn_error_t *
svn_wc__conflict_read_text_conflict(const char **mine_abspath,
                                    const char **their_old_abspath,
                                    const char **their_abspath,
                                    svn_wc__db_t *db,
                                    const char *wri_abspath,
                                    const svn_skel_t *conflict_skel,
                                    apr_pool_t *result_pool,
                                    apr_pool_t *scratch_pool);

/* Reads back the original data stored by svn_wc__conflict_skel_add_prop_conflict()
 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH.
 *
 * Values as documented for svn_wc__conflict_skel_add_prop_conflict().
 *
 * Output arguments can be NULL if the value is not necessary
 * Allocate the result in RESULT_POOL. Perform temporary allocations in
 * SCRATCH_POOL.
 */
svn_error_t *
svn_wc__conflict_read_prop_conflict(const char **marker_abspath,
                                    apr_hash_t **mine_props,
                                    apr_hash_t **their_old_props,
                                    apr_hash_t **their_props,
                                    apr_hash_t **conflicted_prop_names,
                                    svn_wc__db_t *db,
                                    const char *wri_abspath,
                                    const svn_skel_t *conflict_skel,
                                    apr_pool_t *result_pool,
                                    apr_pool_t *scratch_pool);

/* Reads back the original data stored by svn_wc__conflict_skel_add_tree_conflict()
 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH.
 *
 * Values as documented for svn_wc__conflict_skel_add_tree_conflict().
 *
 * Output arguments can be NULL if the value is not necessary
 * Allocate the result in RESULT_POOL. Perform temporary allocations in
 * SCRATCH_POOL.
 */
svn_error_t *
svn_wc__conflict_read_tree_conflict(svn_wc_conflict_reason_t *local_change,
                                    svn_wc_conflict_action_t *incoming_change,
                                    const char **move_src_op_root_abspath,
                                    svn_wc__db_t *db,
                                    const char *wri_abspath,
                                    const svn_skel_t *conflict_skel,
                                    apr_pool_t *result_pool,
                                    apr_pool_t *scratch_pool);

/* Reads in *MARKERS a list of const char * absolute paths of the marker files
   referenced from CONFLICT_SKEL.
 * Allocate the result in RESULT_POOL. Perform temporary allocations in
 * SCRATCH_POOL.
 */
svn_error_t *
svn_wc__conflict_read_markers(const apr_array_header_t **markers,
                              svn_wc__db_t *db,
                              const char *wri_abspath,
                              const svn_skel_t *conflict_skel,
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool);

/* Create the necessary marker files for the conflicts stored in
 * CONFLICT_SKEL and return the work items to fill the markers from
 * the work queue.
 *
 * Currently only used for property conflicts as text conflict markers
 * are just in-wc files.
 *
 * Allocate the result in RESULT_POOL. Perform temporary allocations in
 * SCRATCH_POOL.
 */
svn_error_t *
svn_wc__conflict_create_markers(svn_skel_t **work_item,
                                svn_wc__db_t *db,
                                const char *local_abspath,
                                svn_skel_t *conflict_skel,
                                apr_pool_t *result_pool,
                                apr_pool_t *scratch_pool);

/* Call the conflict resolver RESOLVER_FUNC with RESOLVER_BATON for each
   of the conflicts on LOCAL_ABSPATH.  Depending on the results that
   the callback returns, perhaps resolve the conflicts, and perhaps mark
   them as resolved in the WC DB.

   Call RESOLVER_FUNC once for each property conflict, and again for any
   text conflict, and again for any tree conflict on the node.

   CONFLICT_SKEL contains the details of the conflicts on LOCAL_ABSPATH.

   Use MERGE_OPTIONS when the resolver requests a merge.

   Resolver actions are directly applied to the in-db state of LOCAL_ABSPATH,
   so the conflict and the state in CONFLICT_SKEL must already be installed in
   wc.db. */
svn_error_t *
svn_wc__conflict_invoke_resolver(svn_wc__db_t *db,
                                 const char *local_abspath,
                                 svn_node_kind_t kind,
                                 const svn_skel_t *conflict_skel,
                                 const apr_array_header_t *merge_options,
                                 svn_wc_conflict_resolver_func2_t resolver_func,
                                 void *resolver_baton,
                                 svn_cancel_func_t cancel_func,
                                 void *cancel_baton,
                                 apr_pool_t *scratch_pool);


/* Mark as resolved any text conflict on the node at DB/LOCAL_ABSPATH.  */
svn_error_t *
svn_wc__mark_resolved_text_conflict(svn_wc__db_t *db,
                                    const char *local_abspath,
                                    svn_cancel_func_t cancel_func,
                                    void *cancel_baton,
                                    apr_pool_t *scratch_pool);

/* Mark as resolved any prop conflicts on the node at DB/LOCAL_ABSPATH.  */
svn_error_t *
svn_wc__mark_resolved_prop_conflicts(svn_wc__db_t *db,
                                     const char *local_abspath,
                                     apr_pool_t *scratch_pool);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* SVN_WC_CONFLICTS_H */