conflicts.h revision 362181
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 36extern "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*/ 63svn_skel_t * 64svn_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 */ 72svn_error_t * 73svn_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. */ 87svn_error_t * 88svn_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. */ 104svn_error_t * 105svn_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. */ 122svn_error_t * 123svn_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*/ 149svn_error_t * 150svn_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*/ 190svn_error_t * 191svn_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 MOVE_DST_OP_ROOT_ABSPATH is the op-root of the move target (i.e. the 223 op-root of the corresponding copy). This needs to be stored because 224 moves in the NODE table do not always persist after an update, while 225 the conflict resolver may need information about the pre-update state 226 of the move. 227 228 It is an error to add another tree conflict to a conflict skel that 229 already contains a tree conflict. (It is not an error, at this level, 230 to add a tree conflict to an existing text or property conflict skel.) 231 232 Do temporary allocations in SCRATCH_POOL. 233*/ 234svn_error_t * 235svn_wc__conflict_skel_add_tree_conflict(svn_skel_t *conflict_skel, 236 svn_wc__db_t *db, 237 const char *wri_abspath, 238 svn_wc_conflict_reason_t local_change, 239 svn_wc_conflict_action_t incoming_change, 240 const char *move_src_op_root_abspath, 241 const char *move_dst_op_root_abspath, 242 apr_pool_t *result_pool, 243 apr_pool_t *scratch_pool); 244 245/* Allows resolving specific conflicts stored in CONFLICT_SKEL. 246 247 When RESOLVE_TEXT is TRUE and CONFLICT_SKEL contains a text conflict, 248 resolve/remove the text conflict in CONFLICT_SKEL. 249 250 When RESOLVE_PROP is "" and CONFLICT_SKEL contains a property conflict, 251 resolve/remove all property conflicts in CONFLICT_SKEL. 252 253 When RESOLVE_PROP is not NULL and not "", remove the property conflict on 254 the property RESOLVE_PROP in CONFLICT_SKEL. When RESOLVE_PROP was the last 255 property in CONFLICT_SKEL remove the property conflict info from 256 CONFLICT_SKEL. 257 258 When RESOLVE_TREE is TRUE and CONFLICT_SKEL contains a tree conflict, 259 resolve/remove the tree conflict in CONFLICT_SKEL. 260 261 If COMPLETELY_RESOLVED is not NULL, then set *COMPLETELY_RESOLVED to TRUE, 262 when no conflict registration is left in CONFLICT_SKEL after editting, 263 otherwise to FALSE. 264 265 Allocate data stored in the skel in RESULT_POOL. 266 267 This functions edits CONFLICT_SKEL. New skels might be created in 268 RESULT_POOL. Temporary allocations will use SCRATCH_POOL. 269 */ 270/* ### db, wri_abspath is currently unused. Remove? */ 271svn_error_t * 272svn_wc__conflict_skel_resolve(svn_boolean_t *completely_resolved, 273 svn_skel_t *conflict_skel, 274 svn_wc__db_t *db, 275 const char *wri_abspath, 276 svn_boolean_t resolve_text, 277 const char *resolve_prop, 278 svn_boolean_t resolve_tree, 279 apr_pool_t *result_pool, 280 apr_pool_t *scratch_pool); 281 282/* 283 * ----------------------------------------------------------- 284 * Reading conflict skels. Maybe this can be made private later 285 * ----------------------------------------------------------- 286 */ 287 288/* Read common information from CONFLICT_SKEL to determine the operation 289 * and merge origins. 290 * 291 * Output arguments can be NULL if the value is not necessary. 292 * 293 * Set *LOCATIONS to an array of (svn_wc_conflict_version_t *). For 294 * conflicts written by current code, there are 2 elements: index [0] is 295 * the 'old' or 'left' side and [1] is the 'new' or 'right' side. 296 * 297 * For conflicts written by 1.6 or 1.7 there are 2 locations for a tree 298 * conflict, but none for a text or property conflict. 299 * 300 * TEXT_, PROP_ and TREE_CONFLICTED (when not NULL) will be set to TRUE 301 * when the conflict contains the specified kind of conflict, otherwise 302 * to false. 303 * 304 * Allocate the result in RESULT_POOL. Perform temporary allocations in 305 * SCRATCH_POOL. 306 */ 307svn_error_t * 308svn_wc__conflict_read_info(svn_wc_operation_t *operation, 309 const apr_array_header_t **locations, 310 svn_boolean_t *text_conflicted, 311 svn_boolean_t *prop_conflicted, 312 svn_boolean_t *tree_conflicted, 313 svn_wc__db_t *db, 314 const char *wri_abspath, 315 const svn_skel_t *conflict_skel, 316 apr_pool_t *result_pool, 317 apr_pool_t *scratch_pool); 318 319/* Reads back the original data stored by svn_wc__conflict_skel_add_text_conflict() 320 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH. 321 * 322 * Values as documented for svn_wc__conflict_skel_add_text_conflict(). 323 * 324 * Output arguments can be NULL if the value is not necessary. 325 * 326 * Allocate the result in RESULT_POOL. Perform temporary allocations in 327 * SCRATCH_POOL. 328 */ 329svn_error_t * 330svn_wc__conflict_read_text_conflict(const char **mine_abspath, 331 const char **their_old_abspath, 332 const char **their_abspath, 333 svn_wc__db_t *db, 334 const char *wri_abspath, 335 const svn_skel_t *conflict_skel, 336 apr_pool_t *result_pool, 337 apr_pool_t *scratch_pool); 338 339/* Reads back the original data stored by svn_wc__conflict_skel_add_prop_conflict() 340 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH. 341 * 342 * Values as documented for svn_wc__conflict_skel_add_prop_conflict(). 343 * 344 * Output arguments can be NULL if the value is not necessary 345 * Allocate the result in RESULT_POOL. Perform temporary allocations in 346 * SCRATCH_POOL. 347 */ 348svn_error_t * 349svn_wc__conflict_read_prop_conflict(const char **marker_abspath, 350 apr_hash_t **mine_props, 351 apr_hash_t **their_old_props, 352 apr_hash_t **their_props, 353 apr_hash_t **conflicted_prop_names, 354 svn_wc__db_t *db, 355 const char *wri_abspath, 356 const svn_skel_t *conflict_skel, 357 apr_pool_t *result_pool, 358 apr_pool_t *scratch_pool); 359 360/* Reads back the original data stored by svn_wc__conflict_skel_add_tree_conflict() 361 * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH. 362 * 363 * Values as documented for svn_wc__conflict_skel_add_tree_conflict(). 364 * 365 * Output arguments can be NULL if the value is not necessary 366 * Allocate the result in RESULT_POOL. Perform temporary allocations in 367 * SCRATCH_POOL. 368 */ 369svn_error_t * 370svn_wc__conflict_read_tree_conflict(svn_wc_conflict_reason_t *local_change, 371 svn_wc_conflict_action_t *incoming_change, 372 const char **move_src_op_root_abspath, 373 const char **move_dst_op_root_abspath, 374 svn_wc__db_t *db, 375 const char *wri_abspath, 376 const svn_skel_t *conflict_skel, 377 apr_pool_t *result_pool, 378 apr_pool_t *scratch_pool); 379 380/* Reads in *MARKERS a list of const char * absolute paths of the marker files 381 referenced from CONFLICT_SKEL. 382 * Allocate the result in RESULT_POOL. Perform temporary allocations in 383 * SCRATCH_POOL. 384 */ 385svn_error_t * 386svn_wc__conflict_read_markers(const apr_array_header_t **markers, 387 svn_wc__db_t *db, 388 const char *wri_abspath, 389 const svn_skel_t *conflict_skel, 390 apr_pool_t *result_pool, 391 apr_pool_t *scratch_pool); 392 393/* Create the necessary marker files for the conflicts stored in 394 * CONFLICT_SKEL and return the work items to fill the markers from 395 * the work queue. 396 * 397 * Currently only used for property conflicts as text conflict markers 398 * are just in-wc files. 399 * 400 * Allocate the result in RESULT_POOL. Perform temporary allocations in 401 * SCRATCH_POOL. 402 */ 403svn_error_t * 404svn_wc__conflict_create_markers(svn_skel_t **work_item, 405 svn_wc__db_t *db, 406 const char *local_abspath, 407 svn_skel_t *conflict_skel, 408 apr_pool_t *result_pool, 409 apr_pool_t *scratch_pool); 410 411/* Call the conflict resolver RESOLVER_FUNC with RESOLVER_BATON for each 412 of the conflicts on LOCAL_ABSPATH. Depending on the results that 413 the callback returns, perhaps resolve the conflicts, and perhaps mark 414 them as resolved in the WC DB. 415 416 Call RESOLVER_FUNC once for each property conflict, and again for any 417 text conflict, and again for any tree conflict on the node. 418 419 CONFLICT_SKEL contains the details of the conflicts on LOCAL_ABSPATH. 420 421 Use MERGE_OPTIONS when the resolver requests a merge. 422 423 Resolver actions are directly applied to the in-db state of LOCAL_ABSPATH, 424 so the conflict and the state in CONFLICT_SKEL must already be installed in 425 wc.db. */ 426svn_error_t * 427svn_wc__conflict_invoke_resolver(svn_wc__db_t *db, 428 const char *local_abspath, 429 svn_node_kind_t kind, 430 const svn_skel_t *conflict_skel, 431 const apr_array_header_t *merge_options, 432 svn_wc_conflict_resolver_func2_t resolver_func, 433 void *resolver_baton, 434 svn_cancel_func_t cancel_func, 435 void *cancel_baton, 436 apr_pool_t *scratch_pool); 437 438 439/* Mark as resolved any text conflict on the node at DB/LOCAL_ABSPATH. */ 440svn_error_t * 441svn_wc__mark_resolved_text_conflict(svn_wc__db_t *db, 442 const char *local_abspath, 443 svn_cancel_func_t cancel_func, 444 void *cancel_baton, 445 apr_pool_t *scratch_pool); 446 447/* Mark as resolved any prop conflicts on the node at DB/LOCAL_ABSPATH. */ 448svn_error_t * 449svn_wc__mark_resolved_prop_conflicts(svn_wc__db_t *db, 450 const char *local_abspath, 451 apr_pool_t *scratch_pool); 452 453#ifdef __cplusplus 454} 455#endif /* __cplusplus */ 456 457#endif /* SVN_WC_CONFLICTS_H */ 458