2009-04-16 03:25 Stefan Sperling <stsp_at_elego.de> napisał(a):
> Author: stsp
> Date: Wed Apr 15 18:25:31 2009
> New Revision: 37294
>
> Log:
> Remove dependency on GNU patch, and use the new work-in-progress internal
> implementation instead.
>
> This commit was first saved with svn diff, reverted, re-applied
> with the internal svn patch, and diffed again, and the 2 diffs
> were compared with an external diff, and there was no difference.
>
> * subversion/tests/cmdline/svntest/main.py
> (has_patch): Remove.
>
> * subversion/tests/cmdline/patch_tests.py
> (gnupatch_garbage_re): Remove.
> (patch_basic): Track removal of above.
> (patch_unidiff, patch_copy_and_move): Expect output of internal patch only.
>
> * subversion/include/svn_wc.h
> (svn_wc_apply_unidiff): Undeclare.
>
> * subversion/libsvn_wc/patch.c
> (svn_wc_apply_unidiff): Remove.
>
> * subversion/libsvn_client/patch.c
> (svn_client_patch): Track removal of svn_wc_apply_unidiff, and lose the
> env var runtime check.
>
> Suggested by: rhuijben
> (and gstein said "rip out the spawn? yes")
>
> Modified:
> trunk/subversion/include/svn_wc.h
> trunk/subversion/libsvn_client/patch.c
> trunk/subversion/libsvn_wc/patch.c
> trunk/subversion/tests/cmdline/patch_tests.py
> trunk/subversion/tests/cmdline/svntest/main.py
>
> Modified: trunk/subversion/include/svn_wc.h
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/include/svn_wc.h?pathrev=37294&r1=37293&r2=37294
> ==============================================================================
> --- trunk/subversion/include/svn_wc.h Wed Apr 15 18:00:28 2009 (r37293)
> +++ trunk/subversion/include/svn_wc.h Wed Apr 15 18:25:31 2009 (r37294)
> @@ -5870,28 +5870,6 @@ svn_wc_apply_svnpatch(apr_file_t *decode
> void *diff_edit_baton,
> apr_pool_t *pool);
>
> -/**
> - * Run an external patch program against @a patch_path patch file. @a
> - * outfile and @a errfile are respectively connected to the external
> - * program's stdout and stderr pipes when executed. @a config is looked
> - * up for the SVN_CONFIG_OPTION_PATCH_CMD entry to use as the patch
> - * program. If missing or @a config is @c NULL, the function tries to
> - * execute 'patch' literally, which should work on most *NIX systems at
> - * least. This involves searching into $PATH. The external program is
> - * given the patch file via its stdin pipe.
> - *
> - * The program is passed the '--force' argument when @a force is set.
> - *
> - * @since New in 1.7
> - */
> -svn_error_t *
> -svn_wc_apply_unidiff(const char *patch_path,
> - svn_boolean_t force,
> - apr_file_t *outfile,
> - apr_file_t *errfile,
> - apr_hash_t *config,
> - apr_pool_t *pool);
> -
Public svn_wc_apply_svnpatch() function still exists. Would it make
sense to have a public function which applies unidiff parts of
patches?
> Modified: trunk/subversion/libsvn_wc/patch.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/patch.c?pathrev=37294&r1=37293&r2=37294
> ==============================================================================
> --- trunk/subversion/libsvn_wc/patch.c Wed Apr 15 18:00:28 2009 (r37293)
> +++ trunk/subversion/libsvn_wc/patch.c Wed Apr 15 18:25:31 2009 (r37294)
> @@ -437,105 +437,3 @@ svn_wc_apply_svnpatch(apr_file_t *decode
> apr_pool_destroy(subpool);
> return SVN_NO_ERROR;
> }
> -
> -svn_error_t *
> -svn_wc_apply_unidiff(const char *patch_path,
> - svn_boolean_t force,
> - apr_file_t *outfile,
> - apr_file_t *errfile,
> - apr_hash_t *config,
> - apr_pool_t *pool)
> -{
> - const char *patch_cmd = NULL;
> - const char **patch_cmd_args;
> - const char *patch_cmd_tmp = NULL;
> - int exitcode = 0;
> - apr_exit_why_e exitwhy = 0;
> - svn_boolean_t patch_bin_guess = TRUE;
> - apr_file_t *patchfile;
> - int nargs = 3; /* the command, the prefix arg and NULL at least */
> - int i = 0;
> - apr_pool_t *subpool = svn_pool_create(pool);
> - svn_boolean_t dry_run = FALSE; /* disable dry_run for now */
> -
> - if (force)
> - ++nargs;
> -
> - if (dry_run)
> - ++nargs;
> -
> - patch_cmd_args = apr_palloc(subpool, nargs * sizeof(char *));
> -
> - if (config)
> - {
> - svn_config_t *cfg = apr_hash_get(config,
> - SVN_CONFIG_CATEGORY_CONFIG,
> - APR_HASH_KEY_STRING);
> - svn_config_get(cfg, &patch_cmd_tmp, SVN_CONFIG_SECTION_HELPERS,
> - SVN_CONFIG_OPTION_PATCH_CMD, NULL);
SVN_CONFIG_OPTION_PATCH_CMD should be removed from svn_config.h.
> - }
> -
> - if (patch_cmd_tmp)
> - {
> - patch_bin_guess = FALSE;
> - SVN_ERR(svn_path_cstring_to_utf8(&patch_cmd, patch_cmd_tmp,
> - subpool));
> - }
> - else
> - patch_cmd = "patch";
> -
> - patch_cmd_args[i++] = patch_cmd;
> - patch_cmd_args[i++] = "-p0"; /* TODO: make it smarter in detecting CWD */
> -
> - if (force)
> - patch_cmd_args[i++] = "--force";
> -
> - if (dry_run)
> - patch_cmd_args[i++] = "--dry-run";
> -
> - patch_cmd_args[i++] = NULL;
> -
> - assert(i == nargs);
> -
> - /* We want to feed the external program's stdin with the patch itself. */
> - SVN_ERR(svn_io_file_open(&patchfile, patch_path,
> - APR_READ, APR_OS_DEFAULT, subpool));
> -
> - /* Now run the external program. The parent process should close
> - * opened pipes/files. */
> - SVN_ERR(svn_io_run_cmd(".", patch_cmd, patch_cmd_args,
> - &exitcode, &exitwhy, TRUE, patchfile, outfile,
> - errfile, subpool));
> -
> - /* This is where we have to make the assumption that if the exitcode
> - * isn't 0 nor 1 then the external program got into trouble or wasn't
> - * even executed--command not found (see below). Basically we're
> - * trying to stick with patch(1) behaviour as stated in the man page:
> - * "patch's exit status is 0 if all hunks are applied successfully, 1
> - * if some hunks cannot be applied, and 2 if there is more serious
> - * trouble." */
> - if (exitcode != 0 && exitcode != 1)
> - {
> - /* This is the case when we're trying to execute 'patch' and got
> - * some weird exitcode.
> - * XXX: I haven't figured out how to check against the 'command
> - * not found' error, which returns exitcode == 255. Is there a
> - * macro somewhere to compare with? Let's use > 2 for now. */
> - if (patch_bin_guess && exitcode > 2)
> - return svn_error_create
> - (SVN_ERR_EXTERNAL_PROGRAM_MISSING, NULL, NULL);
SVN_ERR_EXTERNAL_PROGRAM_MISSING should be removed from svn_error_codes.h.
> Modified: trunk/subversion/tests/cmdline/patch_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/patch_tests.py?pathrev=37294&r1=37293&r2=37294
> ==============================================================================
> --- trunk/subversion/tests/cmdline/patch_tests.py Wed Apr 15 18:00:28 2009 (r37293)
> +++ trunk/subversion/tests/cmdline/patch_tests.py Wed Apr 15 18:25:31 2009 (r37294)
> ...
> @@ -393,12 +372,9 @@ def patch_copy_and_move(sbox):
>
> # list all tests here, starting with None:
> test_list = [ None,
> - Wimp('Broken on platforms with non-GNU patch or non-\\n newlines',
> - SkipUnless(patch_basic, svntest.main.has_patch)),
> - Wimp('Broken on platforms with non-GNU patch or non-\\n newlines',
> - SkipUnless(patch_unidiff, svntest.main.has_patch)),
> - Wimp('Broken on platforms with non-GNU patch or non-\\n newlines',
> - SkipUnless(patch_copy_and_move, svntest.main.has_patch)),
> + patch_basic,
> + patch_unidiff,
> + patch_copy_and_move,
Definition of Wimp() at the beginning of this file should be removed.
--
Arfrever Frehtes Taifersar Arahesis
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1745104
Received on 2009-04-16 12:55:55 CEST