Loading...
Searching...
No Matches
Apply a patch to the working copy
Client working copy management

## Typedefs

typedef svn_error_t *(* | svn_client_patch_func_t) (void *baton, svn_boolean_t *filtered, const char *canon_path_from_patchfile, const char *patch_abspath, const char *reject_abspath, apr_pool_t *scratch_pool)
| The callback invoked by svn_client_patch() before attempting to patch the target file at canon_path_from_patchfile (the path as parsed from the patch file, but in canonicalized form).

## Functions

svn_error_t * | svn_client_patch (const char *patch_abspath, const char *wc_dir_abspath, svn_boolean_t dry_run, int strip_count, svn_boolean_t reverse, svn_boolean_t ignore_whitespace, svn_boolean_t remove_tempfiles, svn_client_patch_func_t patch_func, void *patch_baton, svn_client_ctx_t *ctx, apr_pool_t *scratch_pool)
| Apply a unidiff patch that's located at absolute path patch_abspath to the working copy directory at wc_dir_abspath.

## Detailed Description

## Typedef Documentation

## svn_client_patch_func_t

typedef svn_error_t *(* svn_client_patch_func_t) (void *baton, svn_boolean_t *filtered, const char *canon_path_from_patchfile, const char *patch_abspath, const char *reject_abspath, apr_pool_t *scratch_pool)

The callback invoked by svn_client_patch() before attempting to patch the target file at canon_path_from_patchfile (the path as parsed from the patch file, but in canonicalized form).

The callback can set *filtered to `TRUE` to prevent the file from being patched, or else must set it to `FALSE`.

The callback is also provided with patch_abspath, the path of a temporary file containing the patched result, and with reject_abspath, the path to a temporary file containing the diff text of any hunks which were rejected during patching.

Because the callback is invoked before the patching attempt is made, there is no guarantee that the target file will actually be patched successfully. Client implementations must pay attention to notification feedback provided by svn_client_patch() to find out which paths were patched successfully.

Note also that the files at patch_abspath and reject_abspath are guaranteed to remain on disk after patching only if the remove_tempfiles parameter for svn_client_patch() is `FALSE`.

The const char * parameters may be allocated in scratch_pool which will be cleared after each invocation.

Since
  New in 1.7.

Definition at line 7590 of file svn_client.h.

## Function Documentation

## svn_client_patch()

svn_error_t * svn_client_patch | ( | const char * | patch_abspath,
|  | const char * | wc_dir_abspath,
|  | svn_boolean_t | dry_run,
|  | int | strip_count,
|  | svn_boolean_t | reverse,
|  | svn_boolean_t | ignore_whitespace,
|  | svn_boolean_t | remove_tempfiles,
|  | svn_client_patch_func_t | patch_func,
|  | void * | patch_baton,
|  | svn_client_ctx_t * | ctx,
|  | apr_pool_t * | scratch_pool )

Apply a unidiff patch that's located at absolute path patch_abspath to the working copy directory at wc_dir_abspath.

This function makes a best-effort attempt at applying the patch. It might skip patch targets which cannot be patched (e.g. targets that are outside of the working copy). It will also reject hunks which cannot be applied to a target in case the hunk's context does not match anywhere in the patch target.

If dry_run is TRUE, the patching process is carried out, and full notification feedback is provided, but the working copy is not modified.

strip_count specifies how many leading path components should be stripped from paths obtained from the patch. It is an error if a negative strip count is passed.

If reverse is `TRUE`, apply patches in reverse, deleting lines the patch would add and adding lines the patch would delete.

If ignore_whitespace is TRUE, allow patches to be applied if they only differ from the target by whitespace.

If remove_tempfiles is TRUE, lifetimes of temporary files created during patching will be managed internally. Otherwise, the caller should take ownership of these files, the names of which can be obtained by passing a patch_func callback.

If patch_func is non-NULL, invoke patch_func with patch_baton for each patch target processed.

If ctx->notify_func2 is non-NULL, invoke ctx->notify_func2 with ctx->notify_baton2 as patching progresses.

If ctx->cancel_func is non-NULL, invoke it passing ctx->cancel_baton at various places during the operation.

Use scratch_pool for temporary allocations.

Since
  New in 1.7.