Skip to content

Commit f635a88

Browse files
committed
Migrate patch internal implementation to use svn_diff_patch_parser_t API
instead of svn_patch_file_t; Those can be created directly from a file, which we will require in future, as we want to apply a patch from an APR file. * subversion/libsvn_client/patch.c (apply_patches): Change input parameter type as explained above and change parse API method used. (svn_client_patch): Open file manually and create a patch parser instead of opening a patch file. git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1925479 13f79535-47bb-0310-9956-ffa450edef68
1 parent c433ee9 commit f635a88

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

subversion/libsvn_client/patch.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,8 +3613,8 @@ check_ancestor_delete(const char *deleted_target,
36133613

36143614
/* This function is the main entry point into the patch code. */
36153615
static svn_error_t *
3616-
apply_patches(/* The descriptor of the patch file. */
3617-
svn_patch_file_t *patch_file,
3616+
apply_patches(/* The patch parser to read patch from. */
3617+
svn_diff_patch_parser_t *patch_parser,
36183618
/* The abspath to the working copy the patch should be applied to. */
36193619
const char *root_abspath,
36203620
/* Indicates whether we're doing a dry run. */
@@ -3649,9 +3649,9 @@ apply_patches(/* The descriptor of the patch file. */
36493649
if (ctx->cancel_func)
36503650
SVN_ERR(ctx->cancel_func(ctx->cancel_baton));
36513651

3652-
SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file,
3653-
reverse, ignore_whitespace,
3654-
iterpool, iterpool));
3652+
SVN_ERR(svn_diff_patch_parser_next(&patch, patch_parser,
3653+
reverse, ignore_whitespace,
3654+
iterpool, iterpool));
36553655
if (patch)
36563656
{
36573657
patch_target_t *target;
@@ -3735,7 +3735,8 @@ svn_client_patch(const char *patch_abspath,
37353735
apr_pool_t *scratch_pool)
37363736
{
37373737
svn_node_kind_t kind;
3738-
svn_patch_file_t *patch_file;
3738+
apr_file_t *patch_file;
3739+
svn_diff_patch_parser_t *patch_parser;
37393740

37403741
if (strip_count < 0)
37413742
return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
@@ -3771,15 +3772,17 @@ svn_client_patch(const char *patch_abspath,
37713772
svn_dirent_local_style(wc_dir_abspath,
37723773
scratch_pool));
37733774

3774-
SVN_ERR(svn_diff_open_patch_file(&patch_file, patch_abspath, scratch_pool));
3775+
SVN_ERR(svn_io_file_open(&patch_file, patch_abspath, APR_READ | APR_BUFFERED,
3776+
APR_OS_DEFAULT, scratch_pool));
3777+
patch_parser = svn_diff_patch_parser_create(patch_file, scratch_pool);
37753778

37763779
SVN_WC__CALL_WITH_WRITE_LOCK(
3777-
apply_patches(patch_file, wc_dir_abspath, dry_run, strip_count,
3780+
apply_patches(patch_parser, wc_dir_abspath, dry_run, strip_count,
37783781
reverse, ignore_whitespace, remove_tempfiles,
37793782
patch_func, patch_baton, ctx, scratch_pool),
37803783
ctx->wc_ctx, wc_dir_abspath, FALSE /* lock_anchor */, scratch_pool);
37813784

3782-
SVN_ERR(svn_diff_close_patch_file(patch_file, scratch_pool));
3785+
SVN_ERR(svn_io_file_close(patch_file, scratch_pool));
37833786

37843787
return SVN_NO_ERROR;
37853788
}

0 commit comments

Comments
 (0)