# Update and switch (update-like functionality)
[Working copy management]

## Typedefs
typedef svn_error_t *(* | svn_wc_get_file_t )(void *baton, const char *path, svn_revnum_t revision, svn_stream_t *stream, svn_revnum_t *fetched_rev, apr_hash_t **props, apr_pool_t *pool)
| A simple callback type to wrap svn_ra_get_file(); see that docstring for more information.
typedef svn_error_t *(* | svn_wc_dirents_func_t )(void *baton, apr_hash_t **dirents, const char *repos_root_url, const char *repos_relpath, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
| A simple callback type to wrap svn_ra_get_dir2() for avoiding issue #3569, where a directory is updated to a revision without some of its children recorded in the working copy.
## Functions
svn_error_t * | svn_wc_get_update_editor4 (const svn_delta_editor_t **editor, void **edit_baton, svn_revnum_t *target_revision, svn_wc_context_t *wc_ctx, const char *anchor_abspath, const char *target_basename, svn_boolean_t use_commit_times, svn_depth_t depth, svn_boolean_t depth_is_sticky, svn_boolean_t allow_unver_obstructions, svn_boolean_t adds_as_modification, svn_boolean_t server_performs_filtering, svn_boolean_t clean_checkout, const char *diff3_cmd, const apr_array_header_t *preserved_exts, svn_wc_dirents_func_t fetch_dirents_func, void *fetch_dirents_baton, svn_wc_conflict_resolver_func2_t conflict_func, void *conflict_baton, svn_wc_external_update_t external_func, void *external_baton, svn_cancel_func_t cancel_func, void *cancel_baton, svn_wc_notify_func2_t notify_func, void *notify_baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
| Set *editor and *edit_baton to an editor and baton for updating a working copy.
svn_error_t * | svn_wc_get_update_editor3 (svn_revnum_t *target_revision, svn_wc_adm_access_t *anchor, const char *target, svn_boolean_t use_commit_times, svn_depth_t depth, svn_boolean_t depth_is_sticky, svn_boolean_t allow_unver_obstructions, svn_wc_notify_func2_t notify_func, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, svn_wc_conflict_resolver_func_t conflict_func, void *conflict_baton, svn_wc_get_file_t fetch_func, void *fetch_baton, const char *diff3_cmd, const apr_array_header_t *preserved_exts, const svn_delta_editor_t **editor, void **edit_baton, svn_wc_traversal_info_t *ti, apr_pool_t *pool)
| Similar to svn_wc_get_update_editor4, but uses access batons and relative path instead of a working copy context-abspath pair and svn_wc_traversal_info_t instead of an externals callback.
svn_error_t * | svn_wc_get_update_editor2 (svn_revnum_t *target_revision, svn_wc_adm_access_t *anchor, const char *target, svn_boolean_t use_commit_times, svn_boolean_t recurse, svn_wc_notify_func2_t notify_func, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, const char *diff3_cmd, const svn_delta_editor_t **editor, void **edit_baton, svn_wc_traversal_info_t *ti, apr_pool_t *pool)
| Similar to svn_wc_get_update_editor3() but with the allow_unver_obstructions parameter always set to FALSE, conflict_func and baton set to NULL, fetch_func and baton set to NULL, preserved_exts set to NULL, depth_is_sticky set to FALSE, and depth set according to recurse: if recurse is TRUE, pass svn_depth_infinity, if FALSE, pass svn_depth_files.
svn_error_t * | svn_wc_get_update_editor (svn_revnum_t *target_revision, svn_wc_adm_access_t *anchor, const char *target, svn_boolean_t use_commit_times, svn_boolean_t recurse, svn_wc_notify_func_t notify_func, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, const char *diff3_cmd, const svn_delta_editor_t **editor, void **edit_baton, svn_wc_traversal_info_t *ti, apr_pool_t *pool)
| Similar to svn_wc_get_update_editor2(), but takes an svn_wc_notify_func_t instead.
svn_error_t * | svn_wc_get_switch_editor4 (const svn_delta_editor_t **editor, void **edit_baton, svn_revnum_t *target_revision, svn_wc_context_t *wc_ctx, const char *anchor_abspath, const char *target_basename, const char *switch_url, svn_boolean_t use_commit_times, svn_depth_t depth, svn_boolean_t depth_is_sticky, svn_boolean_t allow_unver_obstructions, svn_boolean_t server_performs_filtering, const char *diff3_cmd, const apr_array_header_t *preserved_exts, svn_wc_dirents_func_t fetch_dirents_func, void *fetch_dirents_baton, svn_wc_conflict_resolver_func2_t conflict_func, void *conflict_baton, svn_wc_external_update_t external_func, void *external_baton, svn_cancel_func_t cancel_func, void *cancel_baton, svn_wc_notify_func2_t notify_func, void *notify_baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
| A variant of svn_wc_get_update_editor4().
svn_error_t * | svn_wc_get_switch_editor3 (svn_revnum_t *target_revision, svn_wc_adm_access_t *anchor, const char *target, const char *switch_url, svn_boolean_t use_commit_times, svn_depth_t depth, svn_boolean_t depth_is_sticky, svn_boolean_t allow_unver_obstructions, svn_wc_notify_func2_t notify_func, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, svn_wc_conflict_resolver_func_t conflict_func, void *conflict_baton, const char *diff3_cmd, const apr_array_header_t *preserved_exts, const svn_delta_editor_t **editor, void **edit_baton, svn_wc_traversal_info_t *ti, apr_pool_t *pool)
| Similar to svn_wc_get_switch_editor4, but uses access batons and relative path instead of a working copy context and svn_wc_traversal_info_t instead of an externals callback.
svn_error_t * | svn_wc_get_switch_editor2 (svn_revnum_t *target_revision, svn_wc_adm_access_t *anchor, const char *target, const char *switch_url, svn_boolean_t use_commit_times, svn_boolean_t recurse, svn_wc_notify_func2_t notify_func, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, const char *diff3_cmd, const svn_delta_editor_t **editor, void **edit_baton, svn_wc_traversal_info_t *ti, apr_pool_t *pool)
| Similar to svn_wc_get_switch_editor3() but with the allow_unver_obstructions parameter always set to FALSE, preserved_exts set to NULL, conflict_func and baton set to NULL, depth_is_sticky set to FALSE, and depth set according to recurse: if recurse is TRUE, pass svn_depth_infinity, if FALSE, pass svn_depth_files.
svn_error_t * | svn_wc_get_switch_editor (svn_revnum_t *target_revision, svn_wc_adm_access_t *anchor, const char *target, const char *switch_url, svn_boolean_t use_commit_times, svn_boolean_t recurse, svn_wc_notify_func_t notify_func, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, const char *diff3_cmd, const svn_delta_editor_t **editor, void **edit_baton, svn_wc_traversal_info_t *ti, apr_pool_t *pool)
| Similar to svn_wc_get_switch_editor2(), but takes an svn_wc_notify_func_t instead.

## Typedef Documentation

typedef svn_error_t*(* svn_wc_dirents_func_t)(void *baton, apr_hash_t **dirents, const char *repos_root_url, const char *repos_relpath, apr_pool_t *result_pool, apr_pool_t *scratch_pool)

A simple callback type to wrap svn_ra_get_dir2() for avoiding issue #3569, where a directory is updated to a revision without some of its children recorded in the working copy.

A future update won't bring these files in because the repository assumes they are already there.

We really only need the names of the dirents for a not-present marking, but we also store the node-kind if we receive one.

*dirents should be set to a hash mapping `const char *` child names, to `const svn_dirent_t *` instances.

Since:
  New in 1.7.

Definition at line 5406 of file svn_wc.h.

typedef svn_error_t*(* svn_wc_get_file_t)(void *baton, const char *path, svn_revnum_t revision, svn_stream_t *stream, svn_revnum_t *fetched_rev, apr_hash_t **props, apr_pool_t *pool)

A simple callback type to wrap svn_ra_get_file(); see that docstring for more information.

This technique allows libsvn_client to 'wrap' svn_ra_get_file() and pass it down into libsvn_wc functions, thus allowing the WC layer to legally call the RA function via (blind) callback.

Since:
  New in 1.5

Deprecated:
  Provided for backward compatibility with the 1.6 API.

Definition at line 5384 of file svn_wc.h.

## Function Documentation

svn_error_t* svn_wc_get_switch_editor | ( | svn_revnum_t * | target_revision,
|  | svn_wc_adm_access_t * | anchor,
|  | const char * | target,
|  | const char * | switch_url,
|  | svn_boolean_t | use_commit_times,
|  | svn_boolean_t | recurse,
|  | svn_wc_notify_func_t | notify_func,
|  | void * | notify_baton,
|  | svn_cancel_func_t | cancel_func,
|  | void * | cancel_baton,
|  | const char * | diff3_cmd,
|  | const svn_delta_editor_t ** | editor,
|  | void ** | edit_baton,
|  | svn_wc_traversal_info_t * | ti,
|  | apr_pool_t * | pool |
| ) |  |  |

Similar to svn_wc_get_switch_editor2(), but takes an svn_wc_notify_func_t instead.

Deprecated:
  Provided for backward compatibility with the 1.1 API.

svn_error_t* svn_wc_get_switch_editor2 | ( | svn_revnum_t * | target_revision,
|  | svn_wc_adm_access_t * | anchor,
|  | const char * | target,
|  | const char * | switch_url,
|  | svn_boolean_t | use_commit_times,
|  | svn_boolean_t | recurse,
|  | svn_wc_notify_func2_t | notify_func,
|  | void * | notify_baton,
|  | svn_cancel_func_t | cancel_func,
|  | void * | cancel_baton,
|  | const char * | diff3_cmd,
|  | const svn_delta_editor_t ** | editor,
|  | void ** | edit_baton,
|  | svn_wc_traversal_info_t * | ti,
|  | apr_pool_t * | pool |
| ) |  |  |

Similar to svn_wc_get_switch_editor3() but with the allow_unver_obstructions parameter always set to FALSE, preserved_exts set to NULL, conflict_func and baton set to NULL, depth_is_sticky set to FALSE, and depth set according to recurse: if recurse is TRUE, pass svn_depth_infinity, if FALSE, pass svn_depth_files.

Deprecated:
  Provided for backward compatibility with the 1.4 API.

svn_error_t* svn_wc_get_switch_editor3 | ( | svn_revnum_t * | target_revision,
|  | svn_wc_adm_access_t * | anchor,
|  | const char * | target,
|  | const char * | switch_url,
|  | svn_boolean_t | use_commit_times,
|  | svn_depth_t | depth,
|  | svn_boolean_t | depth_is_sticky,
|  | svn_boolean_t | allow_unver_obstructions,
|  | svn_wc_notify_func2_t | notify_func,
|  | void * | notify_baton,
|  | svn_cancel_func_t | cancel_func,
|  | void * | cancel_baton,
|  | svn_wc_conflict_resolver_func_t | conflict_func,
|  | void * | conflict_baton,
|  | const char * | diff3_cmd,
|  | const apr_array_header_t * | preserved_exts,
|  | const svn_delta_editor_t ** | editor,
|  | void ** | edit_baton,
|  | svn_wc_traversal_info_t * | ti,
|  | apr_pool_t * | pool |
| ) |  |  |

Similar to svn_wc_get_switch_editor4, but uses access batons and relative path instead of a working copy context and svn_wc_traversal_info_t instead of an externals callback.

If ti is non-NULL, record traversal info in ti, for use by post-traversal accessors such as svn_wc_edited_externals().

All locks, both those in anchor and newly acquired ones, will be released when the editor driver calls `close_edit`.

Always sets server_performs_filtering to FALSE.

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 backward compatibility with the 1.6 API.

svn_error_t* svn_wc_get_switch_editor4 | ( | const svn_delta_editor_t ** | editor,
|  | void ** | edit_baton,
|  | svn_revnum_t * | target_revision,
|  | svn_wc_context_t * | wc_ctx,
|  | const char * | anchor_abspath,
|  | const char * | target_basename,
|  | const char * | switch_url,
|  | svn_boolean_t | use_commit_times,
|  | svn_depth_t | depth,
|  | svn_boolean_t | depth_is_sticky,
|  | svn_boolean_t | allow_unver_obstructions,
|  | svn_boolean_t | server_performs_filtering,
|  | const char * | diff3_cmd,
|  | const apr_array_header_t * | preserved_exts,
|  | svn_wc_dirents_func_t | fetch_dirents_func,
|  | void * | fetch_dirents_baton,
|  | svn_wc_conflict_resolver_func2_t | conflict_func,
|  | void * | conflict_baton,
|  | svn_wc_external_update_t | external_func,
|  | void * | external_baton,
|  | svn_cancel_func_t | cancel_func,
|  | void * | cancel_baton,
|  | svn_wc_notify_func2_t | notify_func,
|  | void * | notify_baton,
|  | apr_pool_t * | result_pool,
|  | apr_pool_t * | scratch_pool |
| ) |  |  |

A variant of svn_wc_get_update_editor4().

Set *editor and *edit_baton to an editor and baton for "switching" a working copy to a new switch_url. (Right now, this URL must be within the same repository that the working copy already comes from.) switch_url must not be `NULL`.

All other parameters behave as for svn_wc_get_update_editor4().

Since:
  New in 1.7.

svn_error_t* svn_wc_get_update_editor | ( | svn_revnum_t * | target_revision,
|  | svn_wc_adm_access_t * | anchor,
|  | const char * | target,
|  | svn_boolean_t | use_commit_times,
|  | svn_boolean_t | recurse,
|  | svn_wc_notify_func_t | notify_func,
|  | void * | notify_baton,
|  | svn_cancel_func_t | cancel_func,
|  | void * | cancel_baton,
|  | const char * | diff3_cmd,
|  | const svn_delta_editor_t ** | editor,
|  | void ** | edit_baton,
|  | svn_wc_traversal_info_t * | ti,
|  | apr_pool_t * | pool |
| ) |  |  |

Similar to svn_wc_get_update_editor2(), but takes an svn_wc_notify_func_t instead.

Deprecated:
  Provided for backward compatibility with the 1.1 API.

svn_error_t* svn_wc_get_update_editor2 | ( | svn_revnum_t * | target_revision,
|  | svn_wc_adm_access_t * | anchor,
|  | const char * | target,
|  | svn_boolean_t | use_commit_times,
|  | svn_boolean_t | recurse,
|  | svn_wc_notify_func2_t | notify_func,
|  | void * | notify_baton,
|  | svn_cancel_func_t | cancel_func,
|  | void * | cancel_baton,
|  | const char * | diff3_cmd,
|  | const svn_delta_editor_t ** | editor,
|  | void ** | edit_baton,
|  | svn_wc_traversal_info_t * | ti,
|  | apr_pool_t * | pool |
| ) |  |  |

Similar to svn_wc_get_update_editor3() but with the allow_unver_obstructions parameter always set to FALSE, conflict_func and baton set to NULL, fetch_func and baton set to NULL, preserved_exts set to NULL, depth_is_sticky set to FALSE, and depth set according to recurse: if recurse is TRUE, pass svn_depth_infinity, if FALSE, pass svn_depth_files.

Deprecated:
  Provided for backward compatibility with the 1.4 API.

svn_error_t* svn_wc_get_update_editor3 | ( | svn_revnum_t * | target_revision,
|  | svn_wc_adm_access_t * | anchor,
|  | const char * | target,
|  | svn_boolean_t | use_commit_times,
|  | svn_depth_t | depth,
|  | svn_boolean_t | depth_is_sticky,
|  | svn_boolean_t | allow_unver_obstructions,
|  | svn_wc_notify_func2_t | notify_func,
|  | void * | notify_baton,
|  | svn_cancel_func_t | cancel_func,
|  | void * | cancel_baton,
|  | svn_wc_conflict_resolver_func_t | conflict_func,
|  | void * | conflict_baton,
|  | svn_wc_get_file_t | fetch_func,
|  | void * | fetch_baton,
|  | const char * | diff3_cmd,
|  | const apr_array_header_t * | preserved_exts,
|  | const svn_delta_editor_t ** | editor,
|  | void ** | edit_baton,
|  | svn_wc_traversal_info_t * | ti,
|  | apr_pool_t * | pool |
| ) |  |  |

Similar to svn_wc_get_update_editor4, but uses access batons and relative path instead of a working copy context-abspath pair and svn_wc_traversal_info_t instead of an externals callback.

Also, fetch_func and fetch_baton are ignored.

If ti is non-NULL, record traversal info in ti, for use by post-traversal accessors such as svn_wc_edited_externals().

All locks, both those in anchor and newly acquired ones, will be released when the editor driver calls `close_edit`.

Always sets adds_as_modification to TRUE, server_performs_filtering and clean_checkout to FALSE.

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.

Always passes a null dirent function.

Since:
  New in 1.5.

Deprecated:
  Provided for backward compatibility with the 1.6 API.

svn_error_t* svn_wc_get_update_editor4 | ( | const svn_delta_editor_t ** | editor,
|  | void ** | edit_baton,
|  | svn_revnum_t * | target_revision,
|  | svn_wc_context_t * | wc_ctx,
|  | const char * | anchor_abspath,
|  | const char * | target_basename,
|  | svn_boolean_t | use_commit_times,
|  | svn_depth_t | depth,
|  | svn_boolean_t | depth_is_sticky,
|  | svn_boolean_t | allow_unver_obstructions,
|  | svn_boolean_t | adds_as_modification,
|  | svn_boolean_t | server_performs_filtering,
|  | svn_boolean_t | clean_checkout,
|  | const char * | diff3_cmd,
|  | const apr_array_header_t * | preserved_exts,
|  | svn_wc_dirents_func_t | fetch_dirents_func,
|  | void * | fetch_dirents_baton,
|  | svn_wc_conflict_resolver_func2_t | conflict_func,
|  | void * | conflict_baton,
|  | svn_wc_external_update_t | external_func,
|  | void * | external_baton,
|  | svn_cancel_func_t | cancel_func,
|  | void * | cancel_baton,
|  | svn_wc_notify_func2_t | notify_func,
|  | void * | notify_baton,
|  | apr_pool_t * | result_pool,
|  | apr_pool_t * | scratch_pool |
| ) |  |  |

Set *editor and *edit_baton to an editor and baton for updating a working copy.

anchor_abspath is a local working copy directory, with a fully recursive write lock in wc_ctx, which will be used as the root of our editor.

target_basename is the entry in anchor_abspath that will actually be updated, or the empty string if all of anchor_abspath should be updated.

The editor invokes notify_func with notify_baton as the update progresses, if notify_func is non-NULL.

If cancel_func is non-NULL, the editor will invoke cancel_func with cancel_baton as the update progresses to see if it should continue.

If conflict_func is non-NULL, then invoke it with conflict_baton whenever a conflict is encountered, giving the callback a chance to resolve the conflict before the editor takes more drastic measures (such as marking a file conflicted, or bailing out of the update).

If external_func is non-NULL, then invoke it with external_baton whenever external changes are encountered, giving the callback a chance to store the external information for processing.

If diff3_cmd is non-NULL, then use it as the diff3 command for any merging; otherwise, use the built-in merge code.

preserved_exts is an array of filename patterns which, when matched against the extensions of versioned files, determine for which such files any related generated conflict files will preserve the original file's extension as their own. If a file's extension does not match any of the patterns in preserved_exts (which is certainly the case if preserved_exts is `NULL` or empty), generated conflict files will carry Subversion's custom extensions.

target_revision is a pointer to a revision location which, after successful completion of the drive of this editor, will be populated with the revision to which the working copy was updated.

If use_commit_times is TRUE, then all edited/added files will have their working timestamp set to the last-committed-time. If FALSE, the working files will be touched with the 'now' time.

If allow_unver_obstructions is TRUE, then allow unversioned obstructions when adding a path.

If adds_as_modification is TRUE, a local addition at the same path as an incoming addition of the same node kind results in a normal node with a possible local modification, instead of a tree conflict.

If depth is svn_depth_infinity, update fully recursively. Else if it is svn_depth_immediates, update the uppermost directory, its file entries, and the presence or absence of subdirectories (but do not descend into the subdirectories). Else if it is svn_depth_files, update the uppermost directory and its immediate file entries, but not subdirectories. Else if it is svn_depth_empty, update exactly the uppermost target, and don't touch its entries.

If depth_is_sticky is set and depth is not svn_depth_unknown, then in addition to updating PATHS, also set their sticky ambient depth value to depth.

If server_performs_filtering is TRUE, assume that the server handles the ambient depth filtering, so this doesn't have to be handled in the editor.

If fetch_dirents_func is not NULL, the update editor may call this callback, when asked to perform a depth restricted update. It will do this before returning the editor to allow using the primary ra session for this.

Since:
  New in 1.7.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines