Subversion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Typedefs | Enumerations | Functions
Merging
Working copy management

Typedefs

typedef enum svn_wc_merge_outcome_t svn_wc_merge_outcome_t
 The outcome of a merge carried out (or tried as a dry-run) by svn_wc_merge()
 

Enumerations

enum  svn_wc_merge_outcome_t {
  svn_wc_merge_unchanged,
  svn_wc_merge_merged,
  svn_wc_merge_conflict,
  svn_wc_merge_no_merge
}
 The outcome of a merge carried out (or tried as a dry-run) by svn_wc_merge() More...
 

Functions

svn_error_tsvn_wc_merge5 (enum svn_wc_merge_outcome_t *merge_content_outcome, enum svn_wc_notify_state_t *merge_props_state, svn_wc_context_t *wc_ctx, const char *left_abspath, const char *right_abspath, const char *target_abspath, const char *left_label, const char *right_label, const char *target_label, const svn_wc_conflict_version_t *left_version, const svn_wc_conflict_version_t *right_version, svn_boolean_t dry_run, const char *diff3_cmd, const apr_array_header_t *merge_options, apr_hash_t *original_props, const apr_array_header_t *prop_diff, svn_wc_conflict_resolver_func2_t conflict_func, void *conflict_baton, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool)
 Given absolute paths to three fulltexts, merge the differences between left_abspath and right_abspath into target_abspath.
 
svn_error_tsvn_wc_merge4 (enum svn_wc_merge_outcome_t *merge_outcome, svn_wc_context_t *wc_ctx, const char *left_abspath, const char *right_abspath, const char *target_abspath, const char *left_label, const char *right_label, const char *target_label, const svn_wc_conflict_version_t *left_version, const svn_wc_conflict_version_t *right_version, svn_boolean_t dry_run, const char *diff3_cmd, const apr_array_header_t *merge_options, const apr_array_header_t *prop_diff, svn_wc_conflict_resolver_func2_t conflict_func, void *conflict_baton, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool)
 Similar to svn_wc_merge5() but with merge_props_state and original_props always passed as NULL.
 
svn_error_tsvn_wc_merge3 (enum svn_wc_merge_outcome_t *merge_outcome, const char *left, const char *right, const char *merge_target, svn_wc_adm_access_t *adm_access, const char *left_label, const char *right_label, const char *target_label, svn_boolean_t dry_run, const char *diff3_cmd, const apr_array_header_t *merge_options, const apr_array_header_t *prop_diff, svn_wc_conflict_resolver_func_t conflict_func, void *conflict_baton, apr_pool_t *pool)
 Similar to svn_wc_merge4() but takes relative paths and an access baton.
 
svn_error_tsvn_wc_merge2 (enum svn_wc_merge_outcome_t *merge_outcome, const char *left, const char *right, const char *merge_target, svn_wc_adm_access_t *adm_access, const char *left_label, const char *right_label, const char *target_label, svn_boolean_t dry_run, const char *diff3_cmd, const apr_array_header_t *merge_options, apr_pool_t *pool)
 Similar to svn_wc_merge3(), but with prop_diff, conflict_func, conflict_baton set to NULL.
 
svn_error_tsvn_wc_merge (const char *left, const char *right, const char *merge_target, svn_wc_adm_access_t *adm_access, const char *left_label, const char *right_label, const char *target_label, svn_boolean_t dry_run, enum svn_wc_merge_outcome_t *merge_outcome, const char *diff3_cmd, apr_pool_t *pool)
 Similar to svn_wc_merge2(), but with merge_options set to NULL.
 
svn_error_tsvn_wc_merge_props3 (svn_wc_notify_state_t *state, svn_wc_context_t *wc_ctx, const char *local_abspath, const svn_wc_conflict_version_t *left_version, const svn_wc_conflict_version_t *right_version, apr_hash_t *baseprops, const apr_array_header_t *propchanges, svn_boolean_t dry_run, svn_wc_conflict_resolver_func2_t conflict_func, void *conflict_baton, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool)
 Given a local_abspath under version control, merge an array of propchanges into the path's existing properties.
 
svn_error_tsvn_wc_merge_props2 (svn_wc_notify_state_t *state, const char *path, svn_wc_adm_access_t *adm_access, apr_hash_t *baseprops, const apr_array_header_t *propchanges, svn_boolean_t base_merge, svn_boolean_t dry_run, svn_wc_conflict_resolver_func_t conflict_func, void *conflict_baton, apr_pool_t *pool)
 Similar to svn_wc_merge_props3, but takes an access baton and relative path, no cancel_function, and no left and right version.
 
svn_error_tsvn_wc_merge_props (svn_wc_notify_state_t *state, const char *path, svn_wc_adm_access_t *adm_access, apr_hash_t *baseprops, const apr_array_header_t *propchanges, svn_boolean_t base_merge, svn_boolean_t dry_run, apr_pool_t *pool)
 Same as svn_wc_merge_props2(), but with a conflict_func (and baton) of NULL.
 
svn_error_tsvn_wc_merge_prop_diffs (svn_wc_notify_state_t *state, const char *path, svn_wc_adm_access_t *adm_access, const apr_array_header_t *propchanges, svn_boolean_t base_merge, svn_boolean_t dry_run, apr_pool_t *pool)
 Similar to svn_wc_merge_props(), but no baseprops are given.
 

Detailed Description

Enumeration Type Documentation

The outcome of a merge carried out (or tried as a dry-run) by svn_wc_merge()

Enumerator:
svn_wc_merge_unchanged 

The working copy is (or would be) unchanged.

The changes to be merged were already present in the working copy

svn_wc_merge_merged 

The working copy has been (or would be) changed.

svn_wc_merge_conflict 

The working copy has been (or would be) changed, but there was (or would be) a conflict.

svn_wc_merge_no_merge 

No merge was performed, probably because the target file was either absent or not under version control.

Definition at line 6865 of file svn_wc.h.

Function Documentation

svn_error_t* svn_wc_merge ( const char *  left,
const char *  right,
const char *  merge_target,
svn_wc_adm_access_t adm_access,
const char *  left_label,
const char *  right_label,
const char *  target_label,
svn_boolean_t  dry_run,
enum svn_wc_merge_outcome_t merge_outcome,
const char *  diff3_cmd,
apr_pool_t *  pool 
)

Similar to svn_wc_merge2(), but with merge_options set to NULL.

Deprecated:
Provided for backwards compatibility with the 1.3 API.
svn_error_t* svn_wc_merge2 ( enum svn_wc_merge_outcome_t merge_outcome,
const char *  left,
const char *  right,
const char *  merge_target,
svn_wc_adm_access_t adm_access,
const char *  left_label,
const char *  right_label,
const char *  target_label,
svn_boolean_t  dry_run,
const char *  diff3_cmd,
const apr_array_header_t *  merge_options,
apr_pool_t *  pool 
)

Similar to svn_wc_merge3(), but with prop_diff, conflict_func, conflict_baton set to NULL.

Deprecated:
Provided for backwards compatibility with the 1.4 API.
svn_error_t* svn_wc_merge3 ( enum svn_wc_merge_outcome_t merge_outcome,
const char *  left,
const char *  right,
const char *  merge_target,
svn_wc_adm_access_t adm_access,
const char *  left_label,
const char *  right_label,
const char *  target_label,
svn_boolean_t  dry_run,
const char *  diff3_cmd,
const apr_array_header_t *  merge_options,
const apr_array_header_t *  prop_diff,
svn_wc_conflict_resolver_func_t  conflict_func,
void *  conflict_baton,
apr_pool_t *  pool 
)

Similar to svn_wc_merge4() but takes relative paths and an access baton.

It doesn't support a cancel function or tracking origin version information.

Uses a svn_wc_conflict_resolver_func_t conflict resolver instead of a svn_wc_conflict_resolver_func2_t.

This function assumes that diff3_cmd is path encoded. Later versions assume utf-8.

Since
New in 1.5.
Deprecated:
Provided for backwards compatibility with the 1.6 API.
svn_error_t* svn_wc_merge4 ( enum svn_wc_merge_outcome_t merge_outcome,
svn_wc_context_t wc_ctx,
const char *  left_abspath,
const char *  right_abspath,
const char *  target_abspath,
const char *  left_label,
const char *  right_label,
const char *  target_label,
const svn_wc_conflict_version_t left_version,
const svn_wc_conflict_version_t right_version,
svn_boolean_t  dry_run,
const char *  diff3_cmd,
const apr_array_header_t *  merge_options,
const apr_array_header_t *  prop_diff,
svn_wc_conflict_resolver_func2_t  conflict_func,
void *  conflict_baton,
svn_cancel_func_t  cancel_func,
void *  cancel_baton,
apr_pool_t *  scratch_pool 
)

Similar to svn_wc_merge5() but with merge_props_state and original_props always passed as NULL.

Unlike svn_wc_merge5(), this function doesn't merge property changes. Callers of this function must first use svn_wc_merge_props3() to get this functionality.

Since
New in 1.7.
Deprecated:
Provided for backwards compatibility with the 1.7 API.
svn_error_t* svn_wc_merge5 ( enum svn_wc_merge_outcome_t merge_content_outcome,
enum svn_wc_notify_state_t merge_props_state,
svn_wc_context_t wc_ctx,
const char *  left_abspath,
const char *  right_abspath,
const char *  target_abspath,
const char *  left_label,
const char *  right_label,
const char *  target_label,
const svn_wc_conflict_version_t left_version,
const svn_wc_conflict_version_t right_version,
svn_boolean_t  dry_run,
const char *  diff3_cmd,
const apr_array_header_t *  merge_options,
apr_hash_t *  original_props,
const apr_array_header_t *  prop_diff,
svn_wc_conflict_resolver_func2_t  conflict_func,
void *  conflict_baton,
svn_cancel_func_t  cancel_func,
void *  cancel_baton,
apr_pool_t *  scratch_pool 
)

Given absolute paths to three fulltexts, merge the differences between left_abspath and right_abspath into target_abspath.

It may help to know that left_abspath, right_abspath and target_abspath correspond to "OLDER", "YOURS", and "MINE", respectively, in the diff3 documentation.

wc_ctx should contain a write lock for the directory containing target_abspath.

This function assumes that left_abspath and right_abspath are in repository-normal form (linefeeds, with keywords contracted); if necessary, target_abspath is temporarily converted to this form to receive the changes, then translated back again.

If target_abspath is absent, or present but not under version control, then set *merge_content_outcome to svn_wc_merge_no_merge and return success without merging anything. (The reasoning is that if the file is not versioned, then it is probably unrelated to the changes being considered, so they should not be merged into it. Furthermore, merging into an unversioned file is a lossy operation.)

dry_run determines whether the working copy is modified. When it is FALSE the merge will cause target_abspath to be modified, when it is TRUE the merge will be carried out to determine the result but target_abspath will not be modified.

If diff3_cmd is non-NULL, then use it as the diff3 command for any merging; otherwise, use the built-in merge code. If merge_options is non-NULL, either pass its elements to diff3_cmd or parse it and use as options to the internal merge code (see svn_diff_file_options_parse()). merge_options must contain const char * elements.

If merge_props_state is non-NULL, merge prop_diff into the working properties before merging the text. (If merge_props_state is NULL, do not merge any property changes; in this case, prop_diff is only used to help determine the text merge result.) Handle any conflicts as described for svn_wc_merge_props3(), with the parameters dry_run, conflict_func and conflict_baton. Return the outcome of the property merge in *merge_props_state.

The outcome of the text merge is returned in *merge_content_outcome. If there is a conflict and dry_run is FALSE, then attempt to call conflict_func with conflict_baton (if non-NULL). If the conflict callback cannot resolve the conflict, then:

  • Put conflict markers around the conflicting regions in target_abspath, labeled with left_label, right_label, and target_label. (If any of these labels are NULL, default values will be used.)
  • Copy left_abspath, right_abspath, and the original target_abspath to unique names in the same directory as target_abspath, ending with the suffixes ".LEFT_LABEL", ".RIGHT_LABEL", and ".TARGET_LABEL" respectively.
  • Mark target_abspath as "text-conflicted", and track the above mentioned backup files as well.
  • If left_version and/or right_version are not NULL, provide these values to the conflict handler and track these while the conflict exists.

Binary case:

If target_abspath is a binary file, then no merging is attempted, the merge is deemed to be a conflict. If dry_run is FALSE the working target_abspath is untouched, and copies of left_abspath and right_abspath are created next to it using left_label and right_label. target_abspath is marked as "text-conflicted", and begins tracking the two backup files and the version information.

If dry_run is TRUE no files are changed. The outcome of the merge is returned in *merge_content_outcome.

(and what about *merge_props_state?)

BH: Two kinds of outcome is not how it should be.

For text, we report the outcome as 'merged' if there was some

incoming change that we dealt with (even if we decided to no-op?) but the callers then convert this outcome into a notification of 'merged' only if there was already a local modification; otherwise they notify it as simply 'updated'. But for props we report a notify state of 'merged' here if there was an incoming change regardless of the local-mod state. Inconsistent.

Use scratch_pool for any temporary allocation.

Since
New in 1.8.
svn_error_t* svn_wc_merge_prop_diffs ( svn_wc_notify_state_t state,
const char *  path,
svn_wc_adm_access_t adm_access,
const apr_array_header_t *  propchanges,
svn_boolean_t  base_merge,
svn_boolean_t  dry_run,
apr_pool_t *  pool 
)

Similar to svn_wc_merge_props(), but no baseprops are given.

Instead, it's assumed that the incoming propchanges are based against the working copy's own baseprops. While this assumption is correct for 'svn update', it's incorrect for 'svn merge', and can cause flawed behavior. (See issue #2035.)

Since
The base_merge option is not supported since 1.7.
Deprecated:
Provided for backward compatibility with the 1.2 API. Replaced by svn_wc_merge_props().
svn_error_t* svn_wc_merge_props ( svn_wc_notify_state_t state,
const char *  path,
svn_wc_adm_access_t adm_access,
apr_hash_t *  baseprops,
const apr_array_header_t *  propchanges,
svn_boolean_t  base_merge,
svn_boolean_t  dry_run,
apr_pool_t *  pool 
)

Same as svn_wc_merge_props2(), but with a conflict_func (and baton) of NULL.

Since
New in 1.3. The base_merge option is not supported since 1.7.
Deprecated:
Provided for backward compatibility with the 1.4 API.
svn_error_t* svn_wc_merge_props2 ( svn_wc_notify_state_t state,
const char *  path,
svn_wc_adm_access_t adm_access,
apr_hash_t *  baseprops,
const apr_array_header_t *  propchanges,
svn_boolean_t  base_merge,
svn_boolean_t  dry_run,
svn_wc_conflict_resolver_func_t  conflict_func,
void *  conflict_baton,
apr_pool_t *  pool 
)

Similar to svn_wc_merge_props3, but takes an access baton and relative path, no cancel_function, and no left and right version.

This function has the base_merge parameter which (when TRUE) will apply propchanges to this node's pristine set of properties. This functionality is not supported since API version 1.7 and will give an error if requested (unless dry_run is TRUE). For details see 'notes/api-errata/1.7/wc006.txt'.

Uses a svn_wc_conflict_resolver_func_t conflict resolver instead of a svn_wc_conflict_resolver_func2_t.

For compatibility reasons this function returns SVN_ERR_UNVERSIONED_RESOURCE, when svn_wc_merge_props3 would return either SVN_ERR_WC_PATH_NOT_FOUND or SVN_ERR_WC_PATH_UNEXPECTED_STATUS.

Since
New in 1.5. The base_merge option is not supported since 1.7.
Deprecated:
Provided for backward compatibility with the 1.6 API.
svn_error_t* svn_wc_merge_props3 ( svn_wc_notify_state_t state,
svn_wc_context_t wc_ctx,
const char *  local_abspath,
const svn_wc_conflict_version_t left_version,
const svn_wc_conflict_version_t right_version,
apr_hash_t *  baseprops,
const apr_array_header_t *  propchanges,
svn_boolean_t  dry_run,
svn_wc_conflict_resolver_func2_t  conflict_func,
void *  conflict_baton,
svn_cancel_func_t  cancel_func,
void *  cancel_baton,
apr_pool_t *  scratch_pool 
)

Given a local_abspath under version control, merge an array of propchanges into the path's existing properties.

propchanges is an array of svn_prop_t objects, and baseprops is a hash representing the original set of properties that propchanges is working against. wc_ctx contains a lock for local_abspath.

Only the working properties will be changed.

If state is non-NULL, set *state to the state of the properties after the merge.

If a conflict is found when merging a property, and dry_run is false and conflict_func is not null, then call conflict_func with conflict_baton and a description of the conflict. If any conflicts are not resolved by such callbacks, describe the unresolved conflicts in a temporary .prej file (or append to an already-existing .prej file) and mark the path as conflicted in the WC DB.

If cancel_func is non-NULL, invoke it with cancel_baton at various points during the operation. If it returns an error (typically SVN_ERR_CANCELLED), return that error immediately.

If local_abspath is not under version control, return the error SVN_ERR_WC_PATH_NOT_FOUND and don't touch anyone's properties.

If local_abspath has a status in which it doesn't have properties (E.g. deleted) return the error SVN_ERR_WC_PATH_UNEXPECTED_STATUS.

Since
New in 1.7.