You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/10/25 20:15:45 UTC

svn commit: r1027222 - in /subversion/trunk/subversion: include/svn_client.h libsvn_client/patch.c svn/cl.h svn/main.c svn/patch-cmd.c tests/cmdline/patch_tests.py tests/libsvn_client/client-test.c

Author: stsp
Date: Mon Oct 25 18:15:44 2010
New Revision: 1027222

URL: http://svn.apache.org/viewvc?rev=1027222&view=rev
Log:
Revert r997249, which added the --old-patch-target-names option to svn patch.

The target filename selection problem will instead be solved by using
a heuristic also used in UNIX patch. See for related discussion:

  Date: Wed, 15 Sep 2010 21:40:16 +0200
  From: Stefan Sperling
  To: Daniel Shahaf
  Cc: dev@
  Subject: Re: svn commit: r996581 - in /subversion/trunk/subversion:
          libsvn_diff/parse-diff.c tests/cmdline/patch_tests.py
  Message-ID: <20...@jack.stsp.name>
  http://svn.haxx.se/dev/archive-2010-09/0309.shtml

In addition to a mostly clean reverse-merge, the following happened:

* subversion/tests/cmdline/patch_tests.py
  (patch_reverse_revert): Drop use of the --old-patch-target-names.
  (test_list): The patch_reverse_revert test now fails, so mark it XFail
   until the new heuristic for using filenames has been implemented.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/patch.c
    subversion/trunk/subversion/svn/cl.h
    subversion/trunk/subversion/svn/main.c
    subversion/trunk/subversion/svn/patch-cmd.c
    subversion/trunk/subversion/tests/cmdline/patch_tests.py
    subversion/trunk/subversion/tests/libsvn_client/client-test.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1027222&r1=1027221&r2=1027222&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Mon Oct 25 18:15:44 2010
@@ -5258,15 +5258,6 @@ typedef svn_error_t *(*svn_client_patch_
  * stripped from paths obtained from the patch. It is an error if a
  * negative strip count is passed.
  *
- * If @a old_patch_target_names is @c TRUE, use target names from the old
- * side of the patch, rather than using target names from the new side of
- * the patch. For instance, if a unidiff header contains
- *   --- foo.c
- *   +++ foo.c.new
- * and @a old_patch_target_names is @c TRUE, the name "foo.c" will be used
- * for the target, and if @a old_patch_target_names is @c FALSE, the target
- * name "foo.c.new" will be used.
- *
  * If @a reverse is @c TRUE, apply patches in reverse, deleting lines
  * the patch would add and adding lines the patch would delete.
  * This is useful when applying a unidiff which was created with the
@@ -5298,7 +5289,6 @@ svn_client_patch(const char *patch_abspa
                  const char *local_abspath,
                  svn_boolean_t dry_run,
                  int strip_count,
-                 svn_boolean_t old_patch_target_names,
                  svn_boolean_t reverse,
                  svn_boolean_t ignore_whitespace,
                  svn_boolean_t remove_tempfiles,

Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=1027222&r1=1027221&r2=1027222&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Mon Oct 25 18:15:44 2010
@@ -532,8 +532,6 @@ init_prop_target(prop_patch_target_t **p
  * described by PATCH. Use working copy context WC_CTX.
  * STRIP_COUNT specifies the number of leading path components
  * which should be stripped from target paths in the patch.
- * OLD_PATCH_TARGET_NAMES indicates whether the old target's name parsed
- * from the patch file should be preferred over the new target's name.
  * The patch target structure is allocated in RESULT_POOL, but if the target
  * should be skipped, PATCH_TARGET->SKIPPED is set and the target should be
  * treated as not fully initialized, e.g. the caller should not not do any
@@ -545,9 +543,7 @@ static svn_error_t *
 init_patch_target(patch_target_t **patch_target,
                   const svn_patch_t *patch,
                   const char *base_dir,
-                  svn_wc_context_t *wc_ctx,
-                  int strip_count,
-                  svn_boolean_t old_patch_target_names,
+                  svn_wc_context_t *wc_ctx, int strip_count,
                   svn_boolean_t remove_tempfiles,
                   apr_pool_t *result_pool, apr_pool_t *scratch_pool)
 {
@@ -593,8 +589,7 @@ init_patch_target(patch_target_t **patch
   target->prop_targets = apr_hash_make(result_pool);
   target->pool = result_pool;
 
-  SVN_ERR(resolve_target_path(target, old_patch_target_names ?
-                                patch->old_filename : patch->new_filename,
+  SVN_ERR(resolve_target_path(target, patch->new_filename,
                               base_dir, strip_count, prop_changes_only,
                               wc_ctx, result_pool, scratch_pool));
   if (! target->skipped)
@@ -1630,8 +1625,6 @@ close_target_streams(const patch_target_
  * in RESULT_POOL. Use WC_CTX as the working copy context.
  * STRIP_COUNT specifies the number of leading path components
  * which should be stripped from target paths in the patch.
- * OLD_PATCH_TARGET_NAMES indicates whether the old filename parsed
- * from the patch file should be preferred over the new filename.
  * REMOVE_TEMPFILES, PATCH_FUNC, and PATCH_BATON as in svn_client_patch().
  * IGNORE_WHITESPACE tells whether whitespace should be considered when
  * doing the matching.
@@ -1641,7 +1634,6 @@ static svn_error_t *
 apply_one_patch(patch_target_t **patch_target, svn_patch_t *patch,
                 const char *abs_wc_path, svn_wc_context_t *wc_ctx,
                 int strip_count,
-                svn_boolean_t old_patch_target_names,
                 svn_boolean_t ignore_whitespace,
                 svn_boolean_t remove_tempfiles,
                 svn_client_patch_func_t patch_func,
@@ -1656,8 +1648,7 @@ apply_one_patch(patch_target_t **patch_t
   static const int MAX_FUZZ = 2;
   apr_hash_index_t *hash_index;
 
-  SVN_ERR(init_patch_target(&target, patch, abs_wc_path, wc_ctx,
-                            strip_count, old_patch_target_names,
+  SVN_ERR(init_patch_target(&target, patch, abs_wc_path, wc_ctx, strip_count,
                             remove_tempfiles, result_pool, scratch_pool));
   if (target->skipped)
     {
@@ -2535,9 +2526,6 @@ typedef struct {
   /* Number of leading components to strip from patch target paths. */
   int strip_count;
 
-  /* Whether to use the old path from the patch file instead of the new one. */
-  svn_boolean_t old_patch_target_names;
-
   /* Whether to apply the patch in reverse. */
   svn_boolean_t reverse;
 
@@ -2603,7 +2591,6 @@ apply_patches(void *baton,
 
           SVN_ERR(apply_one_patch(&target, patch, btn->abs_wc_path,
                                   btn->ctx->wc_ctx, btn->strip_count,
-                                  btn->old_patch_target_names,
                                   btn->ignore_whitespace,
                                   btn->remove_tempfiles,
                                   btn->patch_func, btn->patch_baton,
@@ -2661,7 +2648,6 @@ svn_client_patch(const char *patch_abspa
                  const char *local_abspath,
                  svn_boolean_t dry_run,
                  int strip_count,
-                 svn_boolean_t old_patch_target_names,
                  svn_boolean_t reverse,
                  svn_boolean_t ignore_whitespace,
                  svn_boolean_t remove_tempfiles,
@@ -2682,7 +2668,6 @@ svn_client_patch(const char *patch_abspa
   baton.dry_run = dry_run;
   baton.ctx = ctx;
   baton.strip_count = strip_count;
-  baton.old_patch_target_names = old_patch_target_names;
   baton.reverse = reverse;
   baton.ignore_whitespace = ignore_whitespace;
   baton.remove_tempfiles = remove_tempfiles;

Modified: subversion/trunk/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1027222&r1=1027221&r2=1027222&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Mon Oct 25 18:15:44 2010
@@ -229,7 +229,6 @@ typedef struct svn_cl__opt_state_t
   svn_boolean_t show_diff;        /* produce diff output */
   svn_boolean_t internal_diff;    /* override diff_cmd in config file */
   svn_boolean_t use_git_diff_format; /* Use git's extended diff format */
-  svn_boolean_t old_patch_target_names; /* Use target names from old side */
 } svn_cl__opt_state_t;
 
 

Modified: subversion/trunk/subversion/svn/main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/main.c?rev=1027222&r1=1027221&r2=1027222&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/main.c (original)
+++ subversion/trunk/subversion/svn/main.c Mon Oct 25 18:15:44 2010
@@ -122,7 +122,6 @@ typedef enum {
   opt_show_diff,
   opt_internal_diff,
   opt_use_git_diff_format,
-  opt_old_patch_target_names,
 } svn_cl__longopt_t;
 
 #define SVN_CL__OPTION_CONTINUATION_INDENT "                             "
@@ -325,11 +324,7 @@ const apr_getopt_option_t svn_cl__option
   {"ignore-keywords", opt_ignore_keywords, 0,
                     N_("don't expand keywords")},
   {"reverse-diff", opt_reverse_diff, 0,
-                    N_("apply the unidiff in reverse\n"
-                       SVN_CL__OPTION_CONTINUATION_INDENT
-                       "This option also reverses patch target names; the\n"
-                       SVN_CL__OPTION_CONTINUATION_INDENT
-                       "--old-patch-target-names option will prevent this.")},
+                    N_("apply the unidiff in reverse\n")},
   {"ignore-whitespace", opt_ignore_whitespace, 0,
                        N_("ignore whitespace during pattern matching")},
   {"show-diff", opt_show_diff, 0,
@@ -338,16 +333,6 @@ const apr_getopt_option_t svn_cl__option
                        N_("override diff-cmd specified in config file")},
   {"git", opt_use_git_diff_format, 0,
                        N_("use git's extended diff format")},
-  {"old-patch-target-names", opt_old_patch_target_names, 0,
-                       N_("use target names from the old side of a patch.\n"
-                       SVN_CL__OPTION_CONTINUATION_INDENT
-                       "If a diff header contains\n"
-                       SVN_CL__OPTION_CONTINUATION_INDENT
-                       "  --- foo.c\n"
-                       SVN_CL__OPTION_CONTINUATION_INDENT
-                       "  +++ foo.c.new\n"
-                       SVN_CL__OPTION_CONTINUATION_INDENT
-                       "this option will cause the name \"foo.c\" to be used")},
 
   /* Long-opt Aliases
    *
@@ -377,7 +362,6 @@ const apr_getopt_option_t svn_cl__option
   {"diff",          opt_show_diff, 0, NULL},
   {"idiff",         opt_internal_diff, 0, NULL},
   {"keep-locks",    opt_no_unlock, 0, NULL},
-  {"optn",          opt_old_patch_target_names, 0, NULL},
 
   {0,               0, 0, 0},
 };
@@ -827,7 +811,7 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "  do not agree with.\n"
      ),
     {'q', opt_dry_run, opt_strip_count, opt_reverse_diff,
-     opt_ignore_whitespace, opt_old_patch_target_names} },
+     opt_ignore_whitespace} },
 
   { "propdel", svn_cl__propdel, {"pdel", "pd"}, N_
     ("Remove a property from files, dirs, or revisions.\n"
@@ -1804,9 +1788,6 @@ main(int argc, const char *argv[])
       case opt_use_git_diff_format:
         opt_state.use_git_diff_format = TRUE;
         break;
-      case opt_old_patch_target_names:
-        opt_state.old_patch_target_names = TRUE;
-        break;
       default:
         /* Hmmm. Perhaps this would be a good place to squirrel away
            opts that commands like svn diff might need. Hmmm indeed. */

Modified: subversion/trunk/subversion/svn/patch-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/patch-cmd.c?rev=1027222&r1=1027221&r2=1027222&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/patch-cmd.c (original)
+++ subversion/trunk/subversion/svn/patch-cmd.c Mon Oct 25 18:15:44 2010
@@ -74,7 +74,6 @@ svn_cl__patch(apr_getopt_t *os,
 
   SVN_ERR(svn_client_patch(abs_patch_path, abs_target_path,
                            opt_state->dry_run, opt_state->strip_count,
-                           opt_state->old_patch_target_names,
                            opt_state->reverse_diff,
                            opt_state->ignore_whitespace,
                            TRUE, NULL, NULL, ctx, pool, pool));

Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1027222&r1=1027221&r2=1027222&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Mon Oct 25 18:15:44 2010
@@ -3031,134 +3031,6 @@ def patch_git_empty_files(sbox):
                                        None, # expected err
                                        1, # check-props
                                        1) # dry-run
-
-def patch_old_target_names(sbox):
-  "patch using old target names"
-
-  sbox.build()
-  wc_dir = sbox.wc_dir
-
-  patch_file_path = make_patch_path(sbox)
-  mu_path = os.path.join(wc_dir, 'A', 'mu')
-
-  mu_contents = [
-    "Dear internet user,\n",
-    "\n",
-    "We wish to congratulate you over your email success in our computer\n",
-    "Balloting. This is a Millennium Scientific Electronic Computer Draw\n",
-    "in which email addresses were used. All participants were selected\n",
-    "through a computer ballot system drawn from over 100,000 company\n",
-    "and 50,000,000 individual email addresses from all over the world.\n",
-    "\n",
-    "Your email address drew and have won the sum of  750,000 Euros\n",
-    "( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
-    "file with\n",
-    "    REFERENCE NUMBER: ESP/WIN/008/05/10/MA;\n",
-    "    WINNING NUMBER : 14-17-24-34-37-45-16\n",
-    "    BATCH NUMBERS :\n",
-    "    EULO/1007/444/606/08;\n",
-    "    SERIAL NUMBER: 45327\n",
-    "and PROMOTION DATE: 13th June. 2009\n",
-    "\n",
-    "To claim your winning prize, you are to contact the appointed\n",
-    "agent below as soon as possible for the immediate release of your\n",
-    "winnings with the below details.\n",
-    "\n",
-    "Again, we wish to congratulate you over your email success in our\n"
-    "computer Balloting.\n"
-  ]
-
-  # Set mu contents
-  svntest.main.file_write(mu_path, ''.join(mu_contents))
-  expected_output = svntest.wc.State(wc_dir, {
-    'A/mu'       : Item(verb='Sending'),
-    })
-  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
-  expected_status.tweak('A/mu', wc_rev=2)
-  svntest.actions.run_and_verify_commit(wc_dir, expected_output,
-                                        expected_status, None, wc_dir)
-
-  # Apply patch
-
-  unidiff_patch = [
-    "--- A/mu	2009-06-24 15:23:55.000000000 +0100\n",
-    "+++ A/mu.new	2009-06-24 15:21:23.000000000 +0100\n",
-    "@@ -6,6 +6,9 @@\n",
-    " through a computer ballot system drawn from over 100,000 company\n",
-    " and 50,000,000 individual email addresses from all over the world.\n",
-    " \n",
-    "+It is a promotional program aimed at encouraging internet users;\n",
-    "+therefore you do not need to buy ticket to enter for it.\n",
-    "+\n",
-    " Your email address drew and have won the sum of  750,000 Euros\n",
-    " ( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
-    " file with\n",
-    "@@ -14,11 +17,8 @@\n",
-    "     BATCH NUMBERS :\n",
-    "     EULO/1007/444/606/08;\n",
-    "     SERIAL NUMBER: 45327\n",
-    "-and PROMOTION DATE: 13th June. 2009\n",
-    "+and PROMOTION DATE: 14th June. 2009\n",
-    " \n",
-    " To claim your winning prize, you are to contact the appointed\n",
-    " agent below as soon as possible for the immediate release of your\n",
-    " winnings with the below details.\n",
-    "-\n",
-    "-Again, we wish to congratulate you over your email success in our\n",
-    "-computer Balloting.\n",
-  ]
-
-  svntest.main.file_write(patch_file_path, ''.join(unidiff_patch))
-
-  mu_contents = [
-    "Dear internet user,\n",
-    "\n",
-    "We wish to congratulate you over your email success in our computer\n",
-    "Balloting. This is a Millennium Scientific Electronic Computer Draw\n",
-    "in which email addresses were used. All participants were selected\n",
-    "through a computer ballot system drawn from over 100,000 company\n",
-    "and 50,000,000 individual email addresses from all over the world.\n",
-    "\n",
-    "It is a promotional program aimed at encouraging internet users;\n",
-    "therefore you do not need to buy ticket to enter for it.\n",
-    "\n",
-    "Your email address drew and have won the sum of  750,000 Euros\n",
-    "( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
-    "file with\n",
-    "    REFERENCE NUMBER: ESP/WIN/008/05/10/MA;\n",
-    "    WINNING NUMBER : 14-17-24-34-37-45-16\n",
-    "    BATCH NUMBERS :\n",
-    "    EULO/1007/444/606/08;\n",
-    "    SERIAL NUMBER: 45327\n",
-    "and PROMOTION DATE: 14th June. 2009\n",
-    "\n",
-    "To claim your winning prize, you are to contact the appointed\n",
-    "agent below as soon as possible for the immediate release of your\n",
-    "winnings with the below details.\n",
-  ]
-
-  expected_output = [
-    'U         %s\n' % os.path.join(wc_dir, 'A', 'mu'),
-  ]
-
-  expected_disk = svntest.main.greek_state.copy()
-  expected_disk.tweak('A/mu', contents=''.join(mu_contents))
-
-  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
-  expected_status.tweak('A/mu', status='M ', wc_rev=2)
-
-  expected_skip = wc.State('', { })
-
-  svntest.actions.run_and_verify_patch(wc_dir, os.path.abspath(patch_file_path),
-                                       expected_output,
-                                       expected_disk,
-                                       expected_status,
-                                       expected_skip,
-                                       None, # expected err
-                                       1, # check-props
-                                       1, # dry-run
-                                       "--old-patch-target-names")
-
 def patch_reverse_revert(sbox):
   "revert a patch by reverse patching"
 
@@ -3355,8 +3227,7 @@ def patch_reverse_revert(sbox):
                                        None, # expected err
                                        1, # check-props
                                        1, # dry-run
-                                       '--reverse-diff',
-                                       '--old-patch-target-names')
+                                       '--reverse-diff')
 
 ########################################################################
 #Run the tests
@@ -3388,8 +3259,7 @@ test_list = [ None,
               patch_prop_offset,
               patch_prop_with_fuzz,
               patch_git_empty_files,
-              patch_old_target_names,
-              patch_reverse_revert,
+              XFail(patch_reverse_revert),
             ]
 
 if __name__ == '__main__':

Modified: subversion/trunk/subversion/tests/libsvn_client/client-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_client/client-test.c?rev=1027222&r1=1027221&r2=1027222&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_client/client-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_client/client-test.c Mon Oct 25 18:15:44 2010
@@ -379,7 +379,7 @@ test_patch(const svn_test_opts_t *opts,
   pcb.patched_tempfiles = apr_hash_make(pool);
   pcb.reject_tempfiles = apr_hash_make(pool);
   pcb.state_pool = pool;
-  SVN_ERR(svn_client_patch(patch_file_path, wc_path, FALSE, 0, FALSE, FALSE,
+  SVN_ERR(svn_client_patch(patch_file_path, wc_path, FALSE, 0, FALSE,
                            FALSE, FALSE, patch_collection_func, &pcb,
                            ctx, pool, pool));
   SVN_ERR(svn_io_file_close(patch_file, pool));